Jump to content
Sign in to follow this  
Innovative

_StringEncrypt is returning ""

Recommended Posts

Can anyone see why this:

$s_EncryptText = 'Test'
$i_EncryptCountG = ''
$i_EncryptCountH = ''
$s_EncryptPassword = 'test'
$v_EncryptModified = ''
$cnt = StringLen($s_EncryptText)

For $i_EncryptCountG = 1 To StringLen($s_EncryptText)
    ConsoleWrite(">> Loop G>> " & $i_EncryptCountG & "/" & $cnt & @CRLF)
    If $i_EncryptCountH = StringLen($s_EncryptPassword) Then
        $i_EncryptCountH = 1
    Else
        $i_EncryptCountH += 1
        ConsoleWrite(">> Loop G>> Var = $i_EncryptCountH>>" & $i_EncryptCountH & @CRLF)
    EndIf
    $stringmid1 = StringMid($s_EncryptText, $i_EncryptCountG, 1)
    $stringmid2 = StringMid($s_EncryptPassword, $i_EncryptCountH, 1)
    $asc1 = Asc($stringmid2)
    $asc2 = Asc($stringmid2)
    $bitxor = BitXOR($asc1, $asc2, 255)
    $chr = Chr($bitxor)
    $v_EncryptModified = $v_EncryptModified & $chr
    ConsoleWrite(">> Loop G>> Var = $v_EncryptModified>>" & $v_EncryptModified & @CRLF)
Next

Returns different from:

For $i_EncryptCountG = 1 To StringLen($s_EncryptText)
    ConsoleWrite(">> Loop G>> " & $i_EncryptCountG & "/" & $cnt & @CRLF)
    If $i_EncryptCountH = StringLen($s_EncryptPassword) Then
        $i_EncryptCountH = 1
    Else
        $i_EncryptCountH += 1
        ConsoleWrite(">> Loop G>> Var = $i_EncryptCountH>>" & $i_EncryptCountH & @CRLF)
    EndIf
    $v_EncryptModified = $v_EncryptModified & Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255))
    ConsoleWrite(">> Loop G>> Var = $v_EncryptModified>>" & $v_EncryptModified & @CRLF)
Next

Share this post


Link to post
Share on other sites

Nvm , i'll post the result again

i tried running

I asked to ATTACH the script not to Cut& Paste the scriptcode into the post. I would like to see the ORIGINAL input file and be able to test with the exact same input as you are doing. Reason is I want to make sure we are using the same encoding in the source file.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I asked to ATTACH the script not to Cut& Paste the scriptcode into the post. I would like to see the ORIGINAL input file and be able to test with the exact same input as you are doing. Reason is I want to make sure we are using the same encoding in the source file.

Jos

You got to bold to get a result :)

Share this post


Link to post
Share on other sites

I asked to ATTACH the script not to Cut& Paste the scriptcode into the post. I would like to see the ORIGINAL input file and be able to test with the exact same input as you are doing. Reason is I want to make sure we are using the same encoding in the source file.

Jos

Ok , heres the attached .au3 and the returned value.

StringEncrypt.au3

Share this post


Link to post
Share on other sites

Ok... It didn't change anything for me and is still working, but that excluded the file encoding being an issue.

We need to go through some steps now to try end find the root cause of the probem so bare with me.

Please run the attached script, which is stripped and has some consolewrite() debug statements, and Cut&Paste the information from the SciTE Output pane into your reply:

$enc = _StringEncrypt(1, "test", "test")
ConsoleWrite("--" & $enc & "--" & @crlf)
;
Func _StringEncrypt($i_Encrypt, $s_EncryptText, $s_EncryptPassword)
    If $i_Encrypt <> 0 And $i_Encrypt <> 1 Then
        SetError(1)
        Return ''
    ElseIf $s_EncryptText = '' Or $s_EncryptPassword = '' Then
        SetError(1)
        Return ''
    EndIf
    $i_EncryptLevel = 1
    Local $v_EncryptModified
    Local $i_EncryptCountH
    Local $i_EncryptCountG
    Local $v_EncryptSwap
    Local $av_EncryptBox[256][2]
    Local $i_EncryptCountA
    Local $i_EncryptCountB
    Local $i_EncryptCountC
    Local $i_EncryptCountD
    Local $i_EncryptCountE
    Local $v_EncryptCipher
    Local $v_EncryptCipherBy
    If $i_Encrypt = 1 Then
        ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $i_Encrypt = ' & $i_Encrypt & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
        For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $i_EncryptCountF = ' & $i_EncryptCountF & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
            $i_EncryptCountG = ''
            $i_EncryptCountH = ''
            $v_EncryptModified = ''
            For $i_EncryptCountG = 1 To StringLen($s_EncryptText)
                If $i_EncryptCountH = StringLen($s_EncryptPassword) Then
                    $i_EncryptCountH = 1
                Else
                    $i_EncryptCountH += 1
                EndIf
                ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $i_EncryptCountH = ' & $i_EncryptCountH & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
                $v_EncryptModified = $v_EncryptModified & Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255))
                ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $v_EncryptModified = ' & $v_EncryptModified & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
            Next
            $s_EncryptText = $v_EncryptModified
            $i_EncryptCountA = ''
            $i_EncryptCountB = 0
            $i_EncryptCountC = ''
            $i_EncryptCountD = ''
            $i_EncryptCountE = ''
            $v_EncryptCipherBy = ''
            $v_EncryptCipher = ''
            $v_EncryptSwap = ''
            $av_EncryptBox = ''
            Local $av_EncryptBox[256][2]
            For $i_EncryptCountA = 0 To 255
                $av_EncryptBox[$i_EncryptCountA][1] = Asc(StringMid($s_EncryptPassword, Mod($i_EncryptCountA, StringLen($s_EncryptPassword)) + 1, 1))
                $av_EncryptBox[$i_EncryptCountA][0] = $i_EncryptCountA
            Next
            For $i_EncryptCountA = 0 To 255
                $i_EncryptCountB = Mod(($i_EncryptCountB + $av_EncryptBox[$i_EncryptCountA][0] + $av_EncryptBox[$i_EncryptCountA][1]), 256)
                $v_EncryptSwap = $av_EncryptBox[$i_EncryptCountA][0]
                $av_EncryptBox[$i_EncryptCountA][0] = $av_EncryptBox[$i_EncryptCountB][0]
                $av_EncryptBox[$i_EncryptCountB][0] = $v_EncryptSwap
            Next
            For $i_EncryptCountA = 1 To StringLen($s_EncryptText)
                $i_EncryptCountC = Mod(($i_EncryptCountC + 1), 256)
                $i_EncryptCountD = Mod(($i_EncryptCountD + $av_EncryptBox[$i_EncryptCountC][0]), 256)
                $i_EncryptCountE = $av_EncryptBox[Mod(($av_EncryptBox[$i_EncryptCountC][0] + $av_EncryptBox[$i_EncryptCountD][0]), 256) ][0]
                $v_EncryptCipherBy = BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountA, 1)), $i_EncryptCountE)
                $v_EncryptCipher &= Hex($v_EncryptCipherBy, 2)
                ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $v_EncryptCipher = ' & $v_EncryptCipher & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
            Next
            $s_EncryptText = $v_EncryptCipher
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $s_EncryptText = ' & $s_EncryptText & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
        Next
    EndIf
    Return $s_EncryptText
EndFunc ;==>_StringEncrypt
Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\user\Desktop\StringEncrypt.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams   
+>20:21:18 Starting AutoIt3Wrapper v.1.9.5.6    Environment(Language:0409  Keyboard:00000409  OS:WIN_XP/Service Pack 2  CPU:X86)
>Running AU3Check (1.54.10.0)  from:C:\Program Files\AutoIt3
+>20:21:19 AU3Check ended.rc:0
>Running:(3.2.10.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\user\Desktop\StringEncrypt.au3" 
@@ Debug(26) : $i_Encrypt = 1
>Error code: 0
@@ Debug(28) : $i_EncryptCountF = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 1
>Error code: 0
@@ Debug(40) : $v_EncryptModified = 
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 2
>Error code: 0
@@ Debug(40) : $v_EncryptModified = 
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 3
>Error code: 0
@@ Debug(40) : $v_EncryptModified = 
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 4
>Error code: 0
@@ Debug(40) : $v_EncryptModified = 
>Error code: 0
@@ Debug(69) : $v_EncryptCipher = 51
>Error code: 0
@@ Debug(69) : $v_EncryptCipher = 5170
>Error code: 0
@@ Debug(69) : $v_EncryptCipher = 5170D8
>Error code: 0
@@ Debug(69) : $v_EncryptCipher = 5170D8EE
>Error code: 0
@@ Debug(72) : $s_EncryptText = 5170D8EE
>Error code: 0
@@ Debug(28) : $i_EncryptCountF = 1
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 1
>Error code: 0
@@ Debug(40) : $v_EncryptModified = 
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 2
>Error code: 0
@@ Debug(40) : $v_EncryptModified = 
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 3
>Error code: 0
@@ Debug(40) : $v_EncryptModified = 
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 4
>Error code: 0
@@ Debug(40) : $v_EncryptModified = 
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 1
>Error code: 0
@@ Debug(40) : $v_EncryptModified = 
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 2
>Error code: 0
@@ Debug(40) : $v_EncryptModified = 
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 3
>Error code: 0
@@ Debug(40) : $v_EncryptModified = 
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 4
>Error code: 0
@@ Debug(40) : $v_EncryptModified = 
>Error code: 0
@@ Debug(72) : $s_EncryptText = 
>Error code: 0
----
+>20:21:19 AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 3.380

Share this post


Link to post
Share on other sites

Ok looks like the $v_EncryptModified contains a wrong value at the 2nd iteration.

This will display the values generated to get to its final value.... run and give us the results please :

$enc = _StringEncrypt(1, "test", "test")
ConsoleWrite("--" & $enc & "--" & @crlf)
;
Func _StringEncrypt($i_Encrypt, $s_EncryptText, $s_EncryptPassword)
    If $i_Encrypt <> 0 And $i_Encrypt <> 1 Then
        SetError(1)
        Return ''
    ElseIf $s_EncryptText = '' Or $s_EncryptPassword = '' Then
        SetError(1)
        Return ''
    EndIf
    $i_EncryptLevel = 1
    Local $v_EncryptModified
    Local $i_EncryptCountH
    Local $i_EncryptCountG
    Local $v_EncryptSwap
    Local $av_EncryptBox[256][2]
    Local $i_EncryptCountA
    Local $i_EncryptCountB
    Local $i_EncryptCountC
    Local $i_EncryptCountD
    Local $i_EncryptCountE
    Local $v_EncryptCipher
    Local $v_EncryptCipherBy
    If $i_Encrypt = 1 Then
        ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $i_Encrypt = ' & $i_Encrypt & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
        For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $i_EncryptCountF = ' & $i_EncryptCountF & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
            $i_EncryptCountG = ''
            $i_EncryptCountH = ''
            $v_EncryptModified = ''
            For $i_EncryptCountG = 1 To StringLen($s_EncryptText)
                If $i_EncryptCountH = StringLen($s_EncryptPassword) Then
                    $i_EncryptCountH = 1
                Else
                    $i_EncryptCountH += 1
                EndIf
                ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $i_EncryptCountH = ' & $i_EncryptCountH & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
                $v_EncryptModified = $v_EncryptModified & Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255))
                    Asc(Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)))
                    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = ' & BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
                    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = ' & Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
                    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = ' & Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
                    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Asc($v_EncryptModified) = ' & Asc(Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255))) & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
            Next
            $s_EncryptText = $v_EncryptModified
            $i_EncryptCountA = ''
            $i_EncryptCountB = 0
            $i_EncryptCountC = ''
            $i_EncryptCountD = ''
            $i_EncryptCountE = ''
            $v_EncryptCipherBy = ''
            $v_EncryptCipher = ''
            $v_EncryptSwap = ''
            $av_EncryptBox = ''
            Local $av_EncryptBox[256][2]
            For $i_EncryptCountA = 0 To 255
                $av_EncryptBox[$i_EncryptCountA][1] = Asc(StringMid($s_EncryptPassword, Mod($i_EncryptCountA, StringLen($s_EncryptPassword)) + 1, 1))
                $av_EncryptBox[$i_EncryptCountA][0] = $i_EncryptCountA
            Next
            For $i_EncryptCountA = 0 To 255
                $i_EncryptCountB = Mod(($i_EncryptCountB + $av_EncryptBox[$i_EncryptCountA][0] + $av_EncryptBox[$i_EncryptCountA][1]), 256)
                $v_EncryptSwap = $av_EncryptBox[$i_EncryptCountA][0]
                $av_EncryptBox[$i_EncryptCountA][0] = $av_EncryptBox[$i_EncryptCountB][0]
                $av_EncryptBox[$i_EncryptCountB][0] = $v_EncryptSwap
            Next
            For $i_EncryptCountA = 1 To StringLen($s_EncryptText)
                $i_EncryptCountC = Mod(($i_EncryptCountC + 1), 256)
                $i_EncryptCountD = Mod(($i_EncryptCountD + $av_EncryptBox[$i_EncryptCountC][0]), 256)
                $i_EncryptCountE = $av_EncryptBox[Mod(($av_EncryptBox[$i_EncryptCountC][0] + $av_EncryptBox[$i_EncryptCountD][0]), 256) ][0]
                $v_EncryptCipherBy = BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountA, 1)), $i_EncryptCountE)
                $v_EncryptCipher &= Hex($v_EncryptCipherBy, 2)
                ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $v_EncryptCipher = ' & $v_EncryptCipher & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
            Next
            $s_EncryptText = $v_EncryptCipher
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $s_EncryptText = ' & $s_EncryptText & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
        Next
    EndIf
    Return $s_EncryptText
EndFunc  ;==>_StringEncrypt

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

here

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\user\Desktop\StringEncrypt.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams   
+>21:03:05 Starting AutoIt3Wrapper v.1.9.5.6    Environment(Language:0409  Keyboard:00000409  OS:WIN_XP/Service Pack 2  CPU:X86)
>Running AU3Check (1.54.10.0)  from:C:\Program Files\AutoIt3
+>21:03:05 AU3Check ended.rc:0
>Running:(3.2.10.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\user\Desktop\StringEncrypt.au3" 
@@ Debug(26) : $i_Encrypt = 1
>Error code: 0
@@ Debug(28) : $i_EncryptCountF = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 1
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 255
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 116
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 116
>Error code: 0
@@ Debug(44) : Asc($v_EncryptModified) = 255
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 2
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 255
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 101
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 101
>Error code: 0
@@ Debug(44) : Asc($v_EncryptModified) = 255
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 3
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 255
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 115
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 115
>Error code: 0
@@ Debug(44) : Asc($v_EncryptModified) = 255
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 4
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 255
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 116
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 116
>Error code: 0
@@ Debug(44) : Asc($v_EncryptModified) = 255
>Error code: 0
@@ Debug(73) : $v_EncryptCipher = 51
>Error code: 0
@@ Debug(73) : $v_EncryptCipher = 5170
>Error code: 0
@@ Debug(73) : $v_EncryptCipher = 5170D8
>Error code: 0
@@ Debug(73) : $v_EncryptCipher = 5170D8EE
>Error code: 0
@@ Debug(76) : $s_EncryptText = 5170D8EE
>Error code: 0
@@ Debug(28) : $i_EncryptCountF = 1
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 1
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 190
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 53
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 116
>Error code: 0
@@ Debug(44) : Asc($v_EncryptModified) = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 2
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 171
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 49
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 101
>Error code: 0
@@ Debug(44) : Asc($v_EncryptModified) = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 3
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 187
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 55
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 115
>Error code: 0
@@ Debug(44) : Asc($v_EncryptModified) = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 4
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 187
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 48
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 116
>Error code: 0
@@ Debug(44) : Asc($v_EncryptModified) = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 1
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 207
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 68
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 116
>Error code: 0
@@ Debug(44) : Asc($v_EncryptModified) = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 2
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 162
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 56
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 101
>Error code: 0
@@ Debug(44) : Asc($v_EncryptModified) = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 3
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 201
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 69
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 115
>Error code: 0
@@ Debug(44) : Asc($v_EncryptModified) = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 4
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 206
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 69
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 116
>Error code: 0
@@ Debug(44) : Asc($v_EncryptModified) = 0
>Error code: 0
@@ Debug(76) : $s_EncryptText = 
>Error code: 0
----
+>21:03:07 AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 3.302

Share this post


Link to post
Share on other sites

That is really weird. The BitXOR() result =190, but the Asc(Chr(BitXor) = 0. Those should be the same value.

I added one extra Debug statement to show the result of the CHR() in that line since it looks like its going wrong there ...

$enc = _StringEncrypt(1, "test", "test")
ConsoleWrite("--" & $enc & "--" & @crlf)
;
Func _StringEncrypt($i_Encrypt, $s_EncryptText, $s_EncryptPassword)
    If $i_Encrypt <> 0 And $i_Encrypt <> 1 Then
        SetError(1)
        Return ''
    ElseIf $s_EncryptText = '' Or $s_EncryptPassword = '' Then
        SetError(1)
        Return ''
    EndIf
    $i_EncryptLevel = 1
    Local $v_EncryptModified
    Local $i_EncryptCountH
    Local $i_EncryptCountG
    Local $v_EncryptSwap
    Local $av_EncryptBox[256][2]
    Local $i_EncryptCountA
    Local $i_EncryptCountB
    Local $i_EncryptCountC
    Local $i_EncryptCountD
    Local $i_EncryptCountE
    Local $v_EncryptCipher
    Local $v_EncryptCipherBy
    If $i_Encrypt = 1 Then
        ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $i_Encrypt = ' & $i_Encrypt & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
        For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $i_EncryptCountF = ' & $i_EncryptCountF & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
            $i_EncryptCountG = ''
            $i_EncryptCountH = ''
            $v_EncryptModified = ''
            For $i_EncryptCountG = 1 To StringLen($s_EncryptText)
                If $i_EncryptCountH = StringLen($s_EncryptPassword) Then
                    $i_EncryptCountH = 1
                Else
                    $i_EncryptCountH += 1
                EndIf
                ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $i_EncryptCountH = ' & $i_EncryptCountH & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
                $v_EncryptModified = $v_EncryptModified & Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255))
                    Asc(Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)))
                    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = ' & BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
                    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = ' & Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
                    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = ' & Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
                    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) = ' & Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
                    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Asc($v_EncryptModified) = ' & Asc(Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255))) & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
            Next
            $s_EncryptText = $v_EncryptModified
            $i_EncryptCountA = ''
            $i_EncryptCountB = 0
            $i_EncryptCountC = ''
            $i_EncryptCountD = ''
            $i_EncryptCountE = ''
            $v_EncryptCipherBy = ''
            $v_EncryptCipher = ''
            $v_EncryptSwap = ''
            $av_EncryptBox = ''
            Local $av_EncryptBox[256][2]
            For $i_EncryptCountA = 0 To 255
                $av_EncryptBox[$i_EncryptCountA][1] = Asc(StringMid($s_EncryptPassword, Mod($i_EncryptCountA, StringLen($s_EncryptPassword)) + 1, 1))
                $av_EncryptBox[$i_EncryptCountA][0] = $i_EncryptCountA
            Next
            For $i_EncryptCountA = 0 To 255
                $i_EncryptCountB = Mod(($i_EncryptCountB + $av_EncryptBox[$i_EncryptCountA][0] + $av_EncryptBox[$i_EncryptCountA][1]), 256)
                $v_EncryptSwap = $av_EncryptBox[$i_EncryptCountA][0]
                $av_EncryptBox[$i_EncryptCountA][0] = $av_EncryptBox[$i_EncryptCountB][0]
                $av_EncryptBox[$i_EncryptCountB][0] = $v_EncryptSwap
            Next
            For $i_EncryptCountA = 1 To StringLen($s_EncryptText)
                $i_EncryptCountC = Mod(($i_EncryptCountC + 1), 256)
                $i_EncryptCountD = Mod(($i_EncryptCountD + $av_EncryptBox[$i_EncryptCountC][0]), 256)
                $i_EncryptCountE = $av_EncryptBox[Mod(($av_EncryptBox[$i_EncryptCountC][0] + $av_EncryptBox[$i_EncryptCountD][0]), 256) ][0]
                $v_EncryptCipherBy = BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountA, 1)), $i_EncryptCountE)
                $v_EncryptCipher &= Hex($v_EncryptCipherBy, 2)
                ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $v_EncryptCipher = ' & $v_EncryptCipher & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
            Next
            $s_EncryptText = $v_EncryptCipher
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $s_EncryptText = ' & $s_EncryptText & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
        Next
    EndIf
    Return $s_EncryptText
EndFunc  ;==>_StringEncrypt

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\user\Desktop\StringEncrypt.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams   
+>21:11:58 Starting AutoIt3Wrapper v.1.9.5.6    Environment(Language:0409  Keyboard:00000409  OS:WIN_XP/Service Pack 2  CPU:X86)
>Running AU3Check (1.54.10.0)  from:C:\Program Files\AutoIt3
+>21:11:59 AU3Check ended.rc:0
>Running:(3.2.10.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\user\Desktop\StringEncrypt.au3" 
@@ Debug(26) : $i_Encrypt = 1
>Error code: 0
@@ Debug(28) : $i_EncryptCountF = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 1
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 255
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 116
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 116
>Error code: 0
@@ Debug(44) : Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) = 
>Error code: 0
@@ Debug(45) : Asc($v_EncryptModified) = 255
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 2
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 255
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 101
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 101
>Error code: 0
@@ Debug(44) : Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) = 
>Error code: 0
@@ Debug(45) : Asc($v_EncryptModified) = 255
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 3
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 255
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 115
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 115
>Error code: 0
@@ Debug(44) : Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) = 
>Error code: 0
@@ Debug(45) : Asc($v_EncryptModified) = 255
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 4
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 255
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 116
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 116
>Error code: 0
@@ Debug(44) : Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) = 
>Error code: 0
@@ Debug(45) : Asc($v_EncryptModified) = 255
>Error code: 0
@@ Debug(74) : $v_EncryptCipher = 51
>Error code: 0
@@ Debug(74) : $v_EncryptCipher = 5170
>Error code: 0
@@ Debug(74) : $v_EncryptCipher = 5170D8
>Error code: 0
@@ Debug(74) : $v_EncryptCipher = 5170D8EE
>Error code: 0
@@ Debug(77) : $s_EncryptText = 5170D8EE
>Error code: 0
@@ Debug(28) : $i_EncryptCountF = 1
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 1
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 190
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 53
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 116
>Error code: 0
@@ Debug(44) : Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) = 
>Error code: 0
@@ Debug(45) : Asc($v_EncryptModified) = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 2
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 171
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 49
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 101
>Error code: 0
@@ Debug(44) : Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) = 
>Error code: 0
@@ Debug(45) : Asc($v_EncryptModified) = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 3
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 187
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 55
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 115
>Error code: 0
@@ Debug(44) : Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) = 
>Error code: 0
@@ Debug(45) : Asc($v_EncryptModified) = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 4
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 187
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 48
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 116
>Error code: 0
@@ Debug(44) : Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) = 
>Error code: 0
@@ Debug(45) : Asc($v_EncryptModified) = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 1
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 207
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 68
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 116
>Error code: 0
@@ Debug(44) : Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) = 
>Error code: 0
@@ Debug(45) : Asc($v_EncryptModified) = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 2
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 162
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 56
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 101
>Error code: 0
@@ Debug(44) : Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) = 
>Error code: 0
@@ Debug(45) : Asc($v_EncryptModified) = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 3
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 201
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 69
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 115
>Error code: 0
@@ Debug(44) : Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) = 
>Error code: 0
@@ Debug(45) : Asc($v_EncryptModified) = 0
>Error code: 0
@@ Debug(38) : $i_EncryptCountH = 4
>Error code: 0
@@ Debug(41) : BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255) = 206
>Error code: 0
@@ Debug(42) : Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)) = 69
>Error code: 0
@@ Debug(43) : Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)) = 116
>Error code: 0
@@ Debug(44) : Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) = 
>Error code: 0
@@ Debug(45) : Asc($v_EncryptModified) = 0
>Error code: 0
@@ Debug(77) : $s_EncryptText = 
>Error code: 0
----
+>21:11:59 AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 2.542

Share this post


Link to post
Share on other sites

ok.. now totally stripped down to the issue that seems to be there... lets see if this also fails:

$x = BitXOR(53,116,255)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : BitXOR(53,116,255) = ' & BitXOR(53,116,255) & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $x = ' & $x & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Binary($x) = ' & Binary($x) & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Chr($x) = ' & Chr($x) & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Binary(Chr($x)) = ' & Binary(Chr($x)) & @crlf & '>Error code: ' & @error & @crlf);### Debug Console
Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\user\Desktop\StringEncrypt.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams   
+>21:25:00 Starting AutoIt3Wrapper v.1.9.5.6    Environment(Language:0409  Keyboard:00000409  OS:WIN_XP/Service Pack 2  CPU:X86)
>Running AU3Check (1.54.10.0)  from:C:\Program Files\AutoIt3
+>21:25:00 AU3Check ended.rc:0
>Running:(3.2.10.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\user\Desktop\StringEncrypt.au3" 
@@ Debug(2) : BitXOR(53,116,255) = 190
>Error code: 0
@@ Debug(3) : $x = 190
>Error code: 0
@@ Debug(4) : Binary($x) = 0xBE000000
>Error code: 0
@@ Debug(5) : Chr($x) = 
>Error code: 0
@@ Debug(6) : Binary(Chr($x)) = 
>Error code: 0
+>21:25:00 AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 2.133

Share this post


Link to post
Share on other sites

That clearly is why it doesn't work for you BUT the zilliondollar question is why CHR(190) doesn't seem to return anything and doesn't give an error.

Lets see for which values it has this problem :

For $x = 1 To 255
    ConsoleWrite(" $x:" & $x)
    ConsoleWrite(" Chr($x):" & Chr($x))
    ConsoleWrite(" Binary($x):" & Binary($x))
    ConsoleWrite(" Binary(Chr($x)) = " & Binary(Chr($x)) & @CRLF)
Next

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

could you also run it with the ANSI version of Autoit3 using this script to see if that gives the same result? :

#AutoIt3Wrapper_UseAnsi=y
For $x = 1 To 255
    ConsoleWrite(" $x:" & $x)
    ConsoleWrite(" Chr($x):" & Chr($x))
    ConsoleWrite(" Binary($x):" & Binary($x))
    ConsoleWrite(" Binary(Chr($x)) = " & Binary(Chr($x)) & @CRLF)
Next
Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Your test results should confirm this but I think this problem is due to the loaded codepage. Chr() translates values > 127 using the Codepage loaded.

I think this UDF needs to be rewritten to use HEX() and DEC() instead of CHR() to do the Encryption/Decryption..

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I've attached the returned of the results..

The one without "#AutoIt3Wrapper_UseAnsi=y" is the first one..

The one with "#AutoIt3Wrapper_UseAnsi=y" is the second one..

P.S : But the _StringEncrypt used to work very successfully until now ..

First.txt

Second.txt

Edited by CrazeStar1074

Share this post


Link to post
Share on other sites

P.S : But the _StringEncrypt used to work very successfully until now ..

AutoIt was fairly recently changed for Unicode compatibility (ver 3.2.4.0 in May 2007). Perhaps some character handling assumptions had to be changed as a result.

I still think a binary encryption function that doesn't care what kind of data you are working with makes more sense, which is why I was pushing SkinnyWhiteGuy's RC4().

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

As I expected, its the Codepage mapping.

Do you know what regional setting you have (when going in it via the control panel) ?

Curious to understand what code pages you havce selected.

Anyways, I still think that the CHR() function should be avoided when doing Encryption since it uses the CodePage for translating a ASC() code to a character. It should be done using Hex() and Dec() ....

Any takers ?

:)


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

As I expected, its the Codepage mapping.

Do you know what regional setting you have (when going in it via the control panel) ?

Curious to understand what code pages you havce selected.

Anyways, I still think that the CHR() function should be avoided when doing Encryption since it uses the CodePage for translating a ASC() code to a character. It should be done using Hex() and Dec() ....

Any takers ?

:)

Will it mean something more than just replacing CHR with Hex...? :) I'd be willing to give it a try. Lemme see what I can do before I go out.

It will won't it :)

Edited by Bert

Share this post


Link to post
Share on other sites

As I expected, its the Codepage mapping.

Do you know what regional setting you have (when going in it via the control panel) ?

Curious to understand what code pages you havce selected.

LOL, almost 70% has been selected .. You need me to tell you all ?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...