Jump to content

kurey

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by kurey

  1. this funtion may have something wrong when run with the unicode version. i use the __StringEncrypt funtion to Encrypt some NON ascii characterS like : 服务器  <------Chinese (means "server") わたし <------Japanese(means "I") and run with the unicode version(3.2.10.0) on Windos xp Simplified Chinese verion ,and the result is : Encrypt: dcrypt : #include <guiconstants.au3> ;#include <string.au3> ; GUI and String stuff $WinMain = GuiCreate('Encryption tool', 400, 400) ; Creates window $EditText = GuiCtrlCreateEdit('',5,5,380,350) ; Creates main edit $InputPass = GuiCtrlCreateInput('',5,360,100,20, 0x21) ; Creates the password box with blured/centered input $InputLevel = GuiCtrlCreateInput(1, 110, 360, 50, 20, 0x2001) $UpDownLevel = GUICtrlSetLimit(GuiCtrlCreateUpDown($inputlevel),10,1) ; These two make the level input with the Up|Down ability $EncryptButton = GuiCtrlCreateButton('Encrypt', 170, 360, 105, 35) ; Encryption button $DecryptButton = GuiCtrlCreateButton('Decrypt', 285, 360, 105, 35) ; Decryption button GUICtrlCreateLabel('Password', 5, 385) GuiCtrlCreateLabel('Level',110,385) ; Simple text labels so you know what is what GuiSetState() ; Shows window Do $Msg = GuiGetMsg() If $msg = $EncryptButton Then GuiSetState(@SW_DISABLE,$WinMain); Stops you from changing anything $string = GuiCtrlRead($EditText); Saves the editbox for later GUICtrlSetData($EditText,'Please wait while the text is Encrypted/Decrypted.'); Friendly message GuiCtrlSetData($EditText,__StringEncrypt(1,$string,GuiCtrlRead($InputPass),GuiCtrlRead($InputLevel))) ; Calls the encryption. Sets the data of editbox with the encrypted string ; The encryption starts with 1/0 to tell it to encrypt/decrypt ; The encryption then has the string that we saved for later from edit box ; It then reads the password box & Reads the level box GuiSetState(@SW_ENABLE,$WinMain); This turns the window back on EndIf If $msg = $DecryptButton Then GuiSetState(@SW_DISABLE,$WinMain); Stops you from changing anything $string = GuiCtrlRead($EditText); Saves the editbox for later GUICtrlSetData($EditText,'Please wait while the text is Encrypted/Decrypted.'); Friendly message GuiCtrlSetData($EditText,__StringEncrypt(0,$string,GuiCtrlRead($InputPass),GuiCtrlRead($InputLevel))) ; Calls the encryption. Sets the data of editbox with the encrypted string ; The encryption starts with 1/0 to tell it to encrypt/decrypt ; The encryption then has the string that we saved for later from edit box ; It then reads the password box & Reads the level box GuiSetState(@SW_ENABLE,$WinMain); This turns the window back on EndIf Until $msg = $GUI_EVENT_CLOSE; Continue loop untill window is closed ;=============================================================================== ; ; Function Name: ___StringEncrypt() ; Description: RC4 Based string encryption/decryption ; 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): (Original __StringEncrypt) Wes Wolfe-Wolvereness <Weswolf at aol dot com> ; (Modified ___StringEncrypt) PsaltyDS at www.autoitscript.com/forum ; (RC4 function) SkinnyWhiteGuy at www.autoitscript.com/forum ;=============================================================================== ; 1.0.0.0 | 03/08/08 | First version posted to Example Scripts Forum ;=============================================================================== Func __StringEncrypt($i_Encrypt, $s_EncryptText, $s_EncryptPassword, $i_EncryptLevel = 1) Local $RET, $sRET = "", $iBinLen, $iHexWords ; Sanity check of parameters If $i_Encrypt <> 0 And $i_Encrypt <> 1 Then SetError(1) Return '' ElseIf $s_EncryptText = '' Or $s_EncryptPassword = '' Then SetError(1) Return '' EndIf If Number($i_EncryptLevel) <= 0 Or Int($i_EncryptLevel) <> $i_EncryptLevel Then $i_EncryptLevel = 1 ; Encrypt/Decrypt If $i_Encrypt Then ; Encrypt selected $RET = $s_EncryptText For $n = 1 To $i_EncryptLevel If $n > 1 Then $RET = Binary(Random(0, 2 ^ 31 - 1, 1)) & $RET & Binary(Random(0, 2 ^ 31 - 1, 1)); prepend/append random 32bits $RET = rc4($s_EncryptPassword, $RET); returns binary Next ; Convert to hex string $iBinLen = BinaryLen($RET) $iHexWords = Int($iBinLen / 4) If Mod($iBinLen, 4) Then $iHexWords += 1 For $n = 1 To $iHexWords $sRET &= Hex(BinaryMid($RET, 1 + (4 * ($n - 1)), 4)) Next $RET = $sRET Else ; Decrypt selected ; Convert input string to primary binary $RET = Binary("0x" & $s_EncryptText); Convert string to binary ; Additional passes, if required For $n = 1 To $i_EncryptLevel If $n > 1 Then $iBinLen = BinaryLen($RET) $RET = BinaryMid($RET, 5, $iBinLen - 8); strip random 32bits from both ends EndIf $RET = rc4($s_EncryptPassword, $RET) Next $RET = BinaryToString($RET) EndIf ; Return result Return $RET EndFunc ;==>___StringEncrypt ; ------------------------------------------------------- ; 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
  2. thank you for your help, __StringEncrypt() is work fine and the reson is the language packs ? i'm useing the windows xp Simplified Chinese verion
  3. as you wish the code is from the help,and i didn't change anything,i run it with 2 version,pls look at the result pictures #include <guiconstants.au3> #include <string.au3> ; GUI and String stuff $WinMain = GuiCreate('Encryption tool', 400, 400) ; Creates window $EditText = GuiCtrlCreateEdit('',5,5,380,350) ; Creates main edit $InputPass = GuiCtrlCreateInput('',5,360,100,20, 0x21) ; Creates the password box with blured/centered input $InputLevel = GuiCtrlCreateInput(1, 110, 360, 50, 20, 0x2001) $UpDownLevel = GUICtrlSetLimit(GuiCtrlCreateUpDown($inputlevel),10,1) ; These two make the level input with the Up|Down ability $EncryptButton = GuiCtrlCreateButton('Encrypt', 170, 360, 105, 35) ; Encryption button $DecryptButton = GuiCtrlCreateButton('Decrypt', 285, 360, 105, 35) ; Decryption button GUICtrlCreateLabel('Password', 5, 385) GuiCtrlCreateLabel('Level',110,385) ; Simple text labels so you know what is what GuiSetState() ; Shows window Do $Msg = GuiGetMsg() If $msg = $EncryptButton Then GuiSetState(@SW_DISABLE,$WinMain); Stops you from changing anything $string = GuiCtrlRead($EditText); Saves the editbox for later GUICtrlSetData($EditText,'Please wait while the text is Encrypted/Decrypted.'); Friendly message GuiCtrlSetData($EditText,_StringEncrypt(1,$string,GuiCtrlRead($InputPass),GuiCtrlRead($InputLevel))) ; Calls the encryption. Sets the data of editbox with the encrypted string ; The encryption starts with 1/0 to tell it to encrypt/decrypt ; The encryption then has the string that we saved for later from edit box ; It then reads the password box & Reads the level box GuiSetState(@SW_ENABLE,$WinMain); This turns the window back on EndIf If $msg = $DecryptButton Then GuiSetState(@SW_DISABLE,$WinMain); Stops you from changing anything $string = GuiCtrlRead($EditText); Saves the editbox for later GUICtrlSetData($EditText,'Please wait while the text is Encrypted/Decrypted.'); Friendly message GuiCtrlSetData($EditText,_StringEncrypt(0,$string,GuiCtrlRead($InputPass),GuiCtrlRead($InputLevel))) ; Calls the encryption. Sets the data of editbox with the encrypted string ; The encryption starts with 1/0 to tell it to encrypt/decrypt ; The encryption then has the string that we saved for later from edit box ; It then reads the password box & Reads the level box GuiSetState(@SW_ENABLE,$WinMain); This turns the window back on EndIf Until $msg = $GUI_EVENT_CLOSE; Continue loop untill window is closed
  4. part 2 Example.part02.rar
  5. pls unrar and copy the AutoIt3.exe and AutoIt3A.exe into the floder,then run "run_unicode.cmd" and "run_ansi.cmd" the AutoIt3.exe/ AutoIt3A.exe wil run the Example.au3(from the help.chm) then 'Encrypt' or 'Decrypt' something in two windows Example.part01.rar
  6. RC4 function can't work in th Unicode version function : _StringEncrypt _StringEncryptRC4 (Author(s):RazerM) _StringDecryptRC4 (Author(s):RazerM) au3 version: 3.2.10.0 3.2.4.9
×
×
  • Create New...