Jump to content
Sign in to follow this  
Innovative

_StringEncrypt is returning ""

Recommended Posts

Try this, which uses a different RC4 encryption function, that is acutally more "standard" than the one AutoIt's String.au3 UDF uses (that function is by SkinnyWhiteGuy):

$sString = "This is a text string."
$sKey = "This is my key phrase."
$sCrypt = rc4($sKey, $sString) ; encrypted binary
ConsoleWrite("Debug: $sCrypt = " & $sCrypt & @LF)
$sString = rc4($sKey, $sCrypt) ; decrypted binary
ConsoleWrite("Debug: $sString = " & $sString & @LF)
$sString = BinaryToString($sString) ; plain string
ConsoleWrite("Debug: $sString = " & $sString & @LF)
$bh = StringToBinary($sString) ; plain binary
ConsoleWrite("Debug: $bh = " & $bh & @LF)
$reString = rc4($sKey, $bh) ; encrypted binary
ConsoleWrite("Debug: $reString = " & $reString & @LF)
$reString = rc4($sKey, $reString) ; decrypted binary
ConsoleWrite("Debug: $reString = " & $reString & @LF)
$reString = BinaryToString($reString) ; plain string
ConsoleWrite("Debug: $reString = " & $reString & @LF)


; -------------------------------------------------------
; Function:  rc4
; Purpose:  An encryption/decryption RC4 implementation in AutoIt
; Syntax:  rc4($key, $value)
;   Where:  $key = encrypt/decrypt key
;       $value = value to be encrypted/decrypted
; On success returns encrypted/decrypted version of $value
; Author:  SkinnyWhiteGuy on the AutoIt forums at www.autoitscript.com/forum
; Notes:  The same function encrypts and decrypts $value.
; -------------------------------------------------------
Func rc4($key, $value)
    Local $S[256], $i, $j, $c, $t, $x, $y, $output
    Local $keyLength = BinaryLen($key), $valLength = BinaryLen($value)
    For $i = 0 To 255
        $S[$i] = $i
    Next
    For $i = 0 To 255
        $j = Mod($j + $S[$i] + Dec(StringTrimLeft(BinaryMid($key, Mod($i, $keyLength) + 1, 1), 2)), 256)
        $t = $S[$i]
        $S[$i] = $S[$j]
        $S[$j] = $t
    Next
    For $i = 1 To $valLength
        $x = Mod($x + 1, 256)
        $y = Mod($S[$x] + $y, 256)
        $t = $S[$x]
        $S[$x] = $S[$y]
        $S[$y] = $t
        $j = Mod($S[$x] + $S[$y], 256)
        $c = BitXOR(Dec(StringTrimLeft(BinaryMid($value, $i, 1), 2)), $S[$j])
        $output = Binary($output) & Binary('0x' & Hex($c, 2))
    Next
    Return $output
EndFunc   ;==>rc4

All the talk of UTF encoding your strings made me think of another topic. A true binary function won't care if you hand it ASCII/ANSI/UTF-8/UTF-16/Binary/etc.

:)

Edit: Put missing first line back in demo.

Edited by PsaltyDS

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

I think theres an error

it returned

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\user\Desktop\client.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams  
+>21:56:14 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
C:\Documents and Settings\user\Desktop\client.au3(2,30) : WARNING: $sString: possibly used before declaration.
$sCrypt = rc4($sKey, $sString)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\user\Desktop\client.au3 - 0 error(s), 1 warning(s)
->21:56:20 AU3Check ended.rc:1
>Running:(3.2.10.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\user\Desktop\client.au3"    
C:\Documents and Settings\user\Desktop\client.au3 (2) : ==> Variable used without being declared.: 
$sCrypt = rc4($sKey, $sString) 
$sCrypt = rc4($sKey, ^ ERROR
->21:56:21 AutoIT3.exe ended.rc:1
>Exit code: 1   Time: 19.042

Share this post


Link to post
Share on other sites

Thats because its the string you want to encrypt:

$sString = "Jesus i'm tired of seeing this thread"

Share this post


Link to post
Share on other sites

This works. But i really wish to solve my _StringEncrypt problem.. Someone please help me ! There will be alot of inconvenice without _StringEncrypt function

Share this post


Link to post
Share on other sites

I think theres an error

Oops. Clipped the first line when I pasted it in. With this as the first line of the demo:
$sString = "This is a text string."

I get:

>Running:(3.2.10.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Temp\Test\Test1.au3"   
Debug: $sCrypt = 0x70848A8193A21D259EA7F69858CE59C59C7CF4F45561
Debug: $sString = 0x546869732069732061207465787420737472696E672E
Debug: $sString = This is a text string.
Debug: $bh = 0x546869732069732061207465787420737472696E672E
Debug: $reString = 0x70848A8193A21D259EA7F69858CE59C59C7CF4F45561
Debug: $reString = 0x546869732069732061207465787420737472696E672E
Debug: $reString = This is a text string.
+>10:12:32 AutoIT3.exe ended.rc:0

I prefer this function over StringEncrypt() for this reason: This RC4() function from SkinnyWhiteGuy() returns/reads data that can be directly interchanged with a "standard" RC4 encryption in another program, or another language. AutoIt's native StringEncrypt() does not. I would like to see it included in some one of the UDF's as perhaps _BinaryRC4() or some-such, giving AutoIt an INTEROPERABLE encryption.

:)

P.S. SkinnyWhiteGuy also posted DES and AES functions.

Edited by PsaltyDS

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

nice lengthy thread :)

Useless to pm.. They will only get irritated instead

Cannot remember getting irritated at you but I do prefer not to get tons of PMs about script issues .... but I hadn't read this one yet till Bert PMed me, been busy with other things.

Now to the issue at hand. I have no clue why things go wrong at this point.

Lets start with: Open the String.au3 located in Autoit3\includes and copy/paste the _StringEncrypt function into your testscrip.au3 and remove the #include string.au3. try again to see if it fails.

When it still fails then attach the testscript.au3 a post allowing us to download it and to see what the file encoding is?

Jos

Share this post


Link to post
Share on other sites

nice lengthy thread :)

Cannot remember getting irritated at you but I do prefer not to get tons of PMs about script issues .... but I hadn't read this one yet till Bert PMed me, been busy with other things.

Now to the issue at hand. I have no clue why things go wrong at this point.

Lets start with: Open the String.au3 located in Autoit3\includes and copy/paste the _StringEncrypt function into your testscrip.au3 and remove the #include string.au3. try again to see if it fails.

When it still fails then attach the testscript.au3 a post allowing us to download it and to see what the file encoding is?

Jos

I dont think it was you that i pmed.. it was other dev.

Anyway , we tried this already.. Around 2nd ~ 3rd page in this thread.

Share this post


Link to post
Share on other sites

Oops. Clipped the first line when I pasted it in. Whith this as the first line of the demo:

$sString = "This is a text string."

I get:

>Running:(3.2.10.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Temp\Test\Test1.au3"   
Debug: $sCrypt = 0x70848A8193A21D259EA7F69858CE59C59C7CF4F45561
Debug: $sString = 0x546869732069732061207465787420737472696E672E
Debug: $sString = This is a text string.
Debug: $bh = 0x546869732069732061207465787420737472696E672E
Debug: $reString = 0x70848A8193A21D259EA7F69858CE59C59C7CF4F45561
Debug: $reString = 0x546869732069732061207465787420737472696E672E
Debug: $reString = This is a text string.
+>10:12:32 AutoIT3.exe ended.rc:0

I prefer this function over StringEncrypt() for this reason: This RC4() function from SkinnyWhiteGuy() returns/reads data that can be directly interchanged with a "standard" RC4 encryption in another program, or another language. AutoIt's native StringEncrypt() does not. I would like to see it included in some one of the UDF's as perhaps _BinaryRC4() or some-such, giving AutoIt an INTEROPERABLE encryption.

:)

P.S. SkinnyWhiteGuy also posted DES and AES functions.

I dont want to use that now.. Because i wish to solve my problem . WIthout _StringEncrypt , its a load of problems.

Share this post


Link to post
Share on other sites

PsantlyDS and Jos .. Please help !!

Settle down there lad. People in different parts of the world sleep at different times to you. They will get back, when and if they have something for you but that definitlt will not be when they are sleeping. On the other hand Jos dreams in AutoIt.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

I dont think it was you that i pmed.. it was other dev.

Anyway , we tried this already.. Around 2nd ~ 3rd page in this thread.

Listen... If you want help you need to work with me because I am not going to search for things when its easy for you to do it.

PsantlyDS and Jos .. Please help !!

Settle down there lad. People in different parts of the world sleep at different times to you. They will get back, when and if they have something for you but that definitlt will not be when they are sleeping. On the other hand Jos dreams in AutoIt.

Look at the (MY) time you posted in your quoted replies ... I am living in the Netherlands in the GMT+1 timezone and at my age you need the sleep :) Edited by Jos

Share this post


Link to post
Share on other sites

Listen... If you want help you need to work with me because I am not going to search for things when its easy for you to do it.

@Jos: He did do what you asked earlier at my request, and the results were posted (sort of). I don't like getting the results back as an annoying screen shot vice simple copy/paste from the console, though.

That all seems to isolate the problem down to a part of the encrypt portion (in that function the decrypt is only throwing an error because of the null fed back to it from the failed encrypt).

CrazeStar1074 then said something about having trouble with english, and Sheville and Bert started looking at language/keyboard settings and maybe some UTF weirdness. That lead me to recommend a binary encryption (by SkinnyWhiteGuy) vice the string method in _StringEncrypt(). The binary encryption works fine, but he doesn't want to use it (go figure).

I would still like to know what the issue is, just for my own sense of closure. But if his problem (which no one else has duplicated) is related to language/UTF stuff then it's gone over my head. Maybe the results of those two posts linked above could help.

Look at the (MY) time you posted in your quoted replies ... I am living in the Netherlands in the GMT+1 timezone and at my age you need the sleep :)

Good point (the first point, I won't comment on the later...) :)

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

@Jos: He did do what you asked earlier at my request, and the results were posted (sort of). I don't like getting the results back as an annoying screen shot vice simple copy/paste from the console, though.

That all seems to isolate the problem down to a part of the encrypt portion (in that function the decrypt is only throwing an error because of the null fed back to it from the failed encrypt).

He didn't do what I asked since there is no original scriptfile attached ... and I don't think I asked for much but am getting annoyed when people respond like that when you are trying to help.

I guess he gets what he already assumed before ...

Share this post


Link to post
Share on other sites

Nvm , i'll post the result again

i tried running

$encrypt = _StringEncrypt(1, "test", "test")
ConsoleWrite("-" & $encrypt & "-" & @crlf)
;===============================================================================
;
; Function Name:    _StringEncrypt()
; Description:      RC4 Based string encryption
; Parameter(s):     $i_Encrypt - 1 to encrypt, 0 to decrypt
;                   $s_EncryptText - string to encrypt
;                   $s_EncryptPassword - string to use as an encryption password
;                   $i_EncryptLevel - integer to use as number of times to encrypt string
; Requirement(s):   None
; Return Value(s):  On Success - Returns the string encrypted (blank) times with (blank) password
;                   On Failure - Returns a blank string and sets @error = 1
; Author(s):        Wes Wolfe-Wolvereness <Weswolf at aol dot com>
;
;===============================================================================
;
Func _StringEncrypt($i_Encrypt, $s_EncryptText, $s_EncryptPassword, $i_EncryptLevel = 1)
    If $i_Encrypt <> 0 And $i_Encrypt <> 1 Then
        SetError(1)
        Return ''
    ElseIf $s_EncryptText = '' Or $s_EncryptPassword = '' Then
        SetError(1)
        Return ''
    Else
        If Number($i_EncryptLevel) <= 0 Or Int($i_EncryptLevel) <> $i_EncryptLevel Then $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
            For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1
                $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
                    $v_EncryptModified = $v_EncryptModified & Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255))
                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)
                Next
                $s_EncryptText = $v_EncryptCipher
            Next
        Else
            For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1
                $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) Step 2
                    $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(Dec(StringMid($s_EncryptText, $i_EncryptCountA, 2)), $i_EncryptCountE)
                    $v_EncryptCipher = $v_EncryptCipher & Chr($v_EncryptCipherBy)
                Next
                $s_EncryptText = $v_EncryptCipher
                $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
                    $v_EncryptModified &= Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255))
                Next
                $s_EncryptText = $v_EncryptModified
            Next
        EndIf
        Return $s_EncryptText
    EndIf
EndFunc   ;==>_StringEncrypt

and it returned

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\user\Desktop\commandme.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams   
+>12:49:29 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
+>12:49:29 AU3Check ended.rc:0
>Running:(3.2.10.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\user\Desktop\commandme.au3" 
--
+>12:49:29 AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 2.112

Share this post


Link to post
Share on other sites

Could you please upload the results of following into a text file so we are able to compare.

Basically, before the script starts, before you press run, clear the console, then run the scripts. Copy the output. It will be long.

Thank you,

Brett

Script:

$encrypt = _StringEncrypt(1, "test", "test")
ConsoleWrite("-" & $encrypt & "-" & @crlf)
;===============================================================================
;
; Function Name:    _StringEncrypt()
; Description:    RC4 Based string encryption
; Parameter(s):  $i_Encrypt - 1 to encrypt, 0 to decrypt
;                  $s_EncryptText - string to encrypt
;                  $s_EncryptPassword - string to use as an encryption password
;                  $i_EncryptLevel - integer to use as number of times to encrypt string
; Requirement(s):   None
; Return Value(s):  On Success - Returns the string encrypted (blank) times with (blank) password
;                  On Failure - Returns a blank string and sets @error = 1
; Author(s):        Wes Wolfe-Wolvereness <Weswolf at aol dot com>
;
;===============================================================================
;
Func _StringEncrypt($i_Encrypt, $s_EncryptText, $s_EncryptPassword, $i_EncryptLevel = 1)
    If $i_Encrypt <> 0 And $i_Encrypt <> 1 Then
        SetError(1)
        Return ''
    ElseIf $s_EncryptText = '' Or $s_EncryptPassword = '' Then
        SetError(1)
        Return ''
    Else
        If Number($i_EncryptLevel) <= 0 Or Int($i_EncryptLevel) <> $i_EncryptLevel Then $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
            For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1
                ConsoleWrite (">> Loop F>> " & $i_EncryptCountF & "/" & $i_EncryptLevel & @CRLF)
                $i_EncryptCountG = ''
                $i_EncryptCountH = ''
                $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
                    $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
                $s_EncryptText = $v_EncryptModified
                ConsoleWrite (">> Var = >>" & $s_EncryptText & @CRLF)
                $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
                        ConsoleWrite (">> Loop A_1>> " & $i_EncryptCountA & "/255" & @CRLF)
                    $av_EncryptBox[$i_EncryptCountA][1] = Asc(StringMid($s_EncryptPassword, Mod($i_EncryptCountA, StringLen($s_EncryptPassword)) + 1, 1))
                        ConsoleWrite (">> Loop A_1>> Var = $av_EncryptBox["&$i_EncryptCountA&"][1]>> " & $av_EncryptBox[$i_EncryptCountA][1] & @CRLF)
                    $av_EncryptBox[$i_EncryptCountA][0] = $i_EncryptCountA
                        ConsoleWrite (">> Loop G_1>> Var = $av_EncryptBox["&$i_EncryptCountA&"][0]>> " & $i_EncryptCountA & @CRLF)
                Next
                For $i_EncryptCountA = 0 To 255
                        ConsoleWrite (">> Loop A_2>> " & $i_EncryptCountA & "/255" & @CRLF)
                    $i_EncryptCountB = Mod(($i_EncryptCountB + $av_EncryptBox[$i_EncryptCountA][0] + $av_EncryptBox[$i_EncryptCountA][1]), 256)
                        ConsoleWrite (">> Loop A_2>> Var = $i_EncryptCountB>> " & $i_EncryptCountB & @CRLF)
                    $v_EncryptSwap = $av_EncryptBox[$i_EncryptCountA][0]
                        ConsoleWrite (">> Loop A_2>> Var = $v_EncryptSwap>> " & $v_EncryptSwap & @CRLF)
                    $av_EncryptBox[$i_EncryptCountA][0] = $av_EncryptBox[$i_EncryptCountB][0]
                        ConsoleWrite (">> Loop A_2>> Var = $av_EncryptBox["&$i_EncryptCountA&"][0]>> " & $av_EncryptBox[$i_EncryptCountA][0] & @CRLF)
                    $av_EncryptBox[$i_EncryptCountB][0] = $v_EncryptSwap
                        ConsoleWrite (">> Loop A_2>> Var = $av_EncryptBox["&$i_EncryptCountB&"][0]>> " & $av_EncryptBox[$i_EncryptCountB][0] & @CRLF)
                Next
                $cnt = StringLen($s_EncryptText)
                For $i_EncryptCountA = 1 To StringLen($s_EncryptText)
                        ConsoleWrite (">> Loop A_3>> " & $i_EncryptCountA & "/" & $cnt & @CRLF)
                    $i_EncryptCountC = Mod(($i_EncryptCountC + 1), 256)
                        ConsoleWrite (">> Loop A_3>> Var = $i_EncryptCountC>> " & $i_EncryptCountC & @CRLF)
                    $i_EncryptCountD = Mod(($i_EncryptCountD + $av_EncryptBox[$i_EncryptCountC][0]), 256)
                        ConsoleWrite (">> Loop A_3>> Var = $i_EncryptCountD>> " & $i_EncryptCountD & @CRLF)
                    $i_EncryptCountE = $av_EncryptBox[Mod(($av_EncryptBox[$i_EncryptCountC][0] + $av_EncryptBox[$i_EncryptCountD][0]), 256) ][0]
                        ConsoleWrite (">> Loop A_3>> Var = $i_EncryptCountE>> " & $i_EncryptCountE & @CRLF)
                    $v_EncryptCipherBy = BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountA, 1)), $i_EncryptCountE)
                        ConsoleWrite (">> Loop A_3>> Var = $v_EncryptCipherBy>> " & $v_EncryptCipherBy & @CRLF)
                    $v_EncryptCipher &= Hex($v_EncryptCipherBy, 2)
                        ConsoleWrite (">> Loop A_3>> Var = $v_EncryptCipher>> " & $v_EncryptCipher & @CRLF)
                Next
                $s_EncryptText = $v_EncryptCipher
                ConsoleWrite (">> End Output = $v_EncryptCipher>> " & $s_EncryptText & @CRLF) 
            Next
        Else
            For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1
                $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) Step 2
                    $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(Dec(StringMid($s_EncryptText, $i_EncryptCountA, 2)), $i_EncryptCountE)
                    $v_EncryptCipher = $v_EncryptCipher & Chr($v_EncryptCipherBy)
                Next
                $s_EncryptText = $v_EncryptCipher
                $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
                    $v_EncryptModified &= Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255))
                Next
                $s_EncryptText = $v_EncryptModified
            Next
        EndIf
        Return $s_EncryptText
    EndIf
EndFunc  ;==>_StringEncrypt

Share this post


Link to post
Share on other sites

Thanks,

Are you sure that is the full results? Because I am not seeing you actually getting into Loop_A3.

Otherwise everything is as should.

How is it possible for loop_A3 not to be done?

Edited by Bert

Share this post


Link to post
Share on other sites

You're missing around 50 lines in comparision. You are not even starting loop_a3. It just ends? Otherwise every single line that you are running, every number, every varible is correct. Your missing this bit here:

>> Loop A_3>> 1/8
>> Loop A_3>> Var = $i_EncryptCountC>> 1
>> Loop A_3>> Var = $i_EncryptCountD>> 218
>> Loop A_3>> Var = $i_EncryptCountE>> 174
>> Loop A_3>> Var = $v_EncryptCipherBy>> 16
>> Loop A_3>> Var = $v_EncryptCipher>> 10
>> Loop A_3>> 2/8
>> Loop A_3>> Var = $i_EncryptCountC>> 2
>> Loop A_3>> Var = $i_EncryptCountD>> 241
>> Loop A_3>> Var = $i_EncryptCountE>> 143
>> Loop A_3>> Var = $v_EncryptCipherBy>> 36
>> Loop A_3>> Var = $v_EncryptCipher>> 1024
>> Loop A_3>> 3/8
>> Loop A_3>> Var = $i_EncryptCountC>> 3
>> Loop A_3>> Var = $i_EncryptCountD>> 248
>> Loop A_3>> Var = $i_EncryptCountE>> 39
>> Loop A_3>> Var = $v_EncryptCipherBy>> 156
>> Loop A_3>> Var = $v_EncryptCipher>> 10249C
>> Loop A_3>> 4/8
>> Loop A_3>> Var = $i_EncryptCountC>> 4
>> Loop A_3>> Var = $i_EncryptCountD>> 56
>> Loop A_3>> Var = $i_EncryptCountE>> 17
>> Loop A_3>> Var = $v_EncryptCipherBy>> 170
>> Loop A_3>> Var = $v_EncryptCipher>> 10249CAA
>> Loop A_3>> 5/8
>> Loop A_3>> Var = $i_EncryptCountC>> 5
>> Loop A_3>> Var = $i_EncryptCountD>> 30
>> Loop A_3>> Var = $i_EncryptCountE>> 224
>> Loop A_3>> Var = $v_EncryptCipherBy>> 47
>> Loop A_3>> Var = $v_EncryptCipher>> 10249CAA2F
>> Loop A_3>> 6/8
>> Loop A_3>> Var = $i_EncryptCountC>> 6
>> Loop A_3>> Var = $i_EncryptCountD>> 60
>> Loop A_3>> Var = $i_EncryptCountE>> 42
>> Loop A_3>> Var = $v_EncryptCipherBy>> 136
>> Loop A_3>> Var = $v_EncryptCipher>> 10249CAA2F88
>> Loop A_3>> 7/8
>> Loop A_3>> Var = $i_EncryptCountC>> 7
>> Loop A_3>> Var = $i_EncryptCountD>> 15
>> Loop A_3>> Var = $i_EncryptCountE>> 125
>> Loop A_3>> Var = $v_EncryptCipherBy>> 180
>> Loop A_3>> Var = $v_EncryptCipher>> 10249CAA2F88B4
>> Loop A_3>> 8/8
>> Loop A_3>> Var = $i_EncryptCountC>> 8
>> Loop A_3>> Var = $i_EncryptCountD>> 39
>> Loop A_3>> Var = $i_EncryptCountE>> 37
>> Loop A_3>> Var = $v_EncryptCipherBy>> 235
>> Loop A_3>> Var = $v_EncryptCipher>> 10249CAA2F88B4EB
>> End Output = $v_EncryptCipher>> 10249CAA2F88B4EB
-10249CAA2F88B4EB-
+>19:37:18 AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 6.819

Share this post


Link to post
Share on other sites

Something I missed as well...

The reason why Loop_A3 never exists, is because of Loop G. It never returns a value for you. It should be:

>> Loop G>> 1/8
>> Loop G>> Var = $i_EncryptCountH>>1
>> Loop G>> Var = $v_EncryptModified>>¾
>> Loop G>> 2/8
>> Loop G>> Var = $i_EncryptCountH>>2
>> Loop G>> Var = $v_EncryptModified>>¾«
>> Loop G>> 3/8
>> Loop G>> Var = $i_EncryptCountH>>3
>> Loop G>> Var = $v_EncryptModified>>¾«»
>> Loop G>> 4/8
>> Loop G>> Var = $i_EncryptCountH>>4
>> Loop G>> Var = $v_EncryptModified>>¾«»»
>> Loop G>> 5/8
>> Loop G>> Var = $v_EncryptModified>>¾«»»Ï
>> Loop G>> 6/8
>> Loop G>> Var = $i_EncryptCountH>>2
>> Loop G>> Var = $v_EncryptModified>>¾«»»Ï¢
>> Loop G>> 7/8
>> Loop G>> Var = $i_EncryptCountH>>3
>> Loop G>> Var = $v_EncryptModified>>¾«»»Ï¢É
>> Loop G>> 8/8
>> Loop G>> Var = $i_EncryptCountH>>4
>> Loop G>> Var = $v_EncryptModified>>¾«»»Ï¢ÉÎ
>> Var = >>¾«»»Ï¢ÉÎ

$v_EncryptModified = $v_EncryptModified & Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255))

And look where we end up again. Back to this line all over again.

Let me work on another example to see what's happening... :)

Edited by Bert

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...