bcording Posted November 14, 2004 Share Posted November 14, 2004 (edited) A while back I posted an RC4 function, but it wasn't 100%. This was due to AutoIt not supporting NULs. Some additional work resulted in this itteration. To get around the NUL issue the function returns a HEX string rather than a character string. By the way this makes it easy to read/write encrypted text to/from the registry as REG_BINARY. Test Code: $pw = "~#[.ab!@MNmn6UVuv2-<EFef`$KLkl7&\XwABW{,CDcdx1+>}/GHgh9%]IJij8^|YZyz0=?*:OPop 5(""QRqr4);STst3_'" $text = "AutoIt has been designed to work on Windows 95, 98, ME, NT 4, 2000, XP and 2003." $Encrypted = RC4($text, $pw, 0) MsgBox(0,"Encrypted Text",$Encrypted) $Decrypted = RC4($Encrypted, $pw, 1) MsgBox(0,"Decrypted Text",$Decrypted) MsgBox(0,"Original = Decrypted",$text = $Decrypted) RC4 Function expandcollapse popupFunc RC4($Data, $Phrase, $Decrypt) Local $a, $b, $i, $j, $k, $cipherby, $cipher Local $tempSwap, $temp, $PLen Local $sbox[256], $key[256] $PLen = StringLen($Phrase) For $a = 0 To 255 $key[$a] = Asc(StringMid($Phrase, Mod($a, $PLen) + 1, 1)) $sbox[$a] = $a Next $b = 0 For $a = 0 To 255 $b = Mod( ($b + $sbox[$a] + $key[$a]), 256) $tempSwap = $sbox[$a] $sbox[$a] = $sbox[$b] $sbox[$b] = $tempSwap Next If $Decrypt Then For $a = 1 To StringLen($Data) Step 2 $i = Mod(($i + 1), 256) $j = Mod(($j + $sbox[$i]), 256) $k = $sbox[Mod(($sbox[$i] + $sbox[$j]), 256)] $cipherby = BitXOR(Dec(StringMid($Data, $a, 2)), $k) $cipher = $cipher & Chr($cipherby) Next Else For $a = 1 To StringLen($Data) $i = Mod(($i + 1), 256) $j = Mod(($j + $sbox[$i]), 256) $k = $sbox[Mod(($sbox[$i] + $sbox[$j]), 256)] $cipherby = BitXOR(Asc(StringMid($Data, $a, 1)), $k) $cipher = $cipher & Hex($cipherby, 2) Next EndIf Return $cipher EndFunc ;==>RC4 Edited November 14, 2004 by bcording Link to comment Share on other sites More sharing options...
piccaso Posted November 15, 2004 Share Posted November 15, 2004 nice CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map Link to comment Share on other sites More sharing options...
layer Posted November 16, 2004 Share Posted November 16, 2004 I don't get it, how do you use it? FootbaG Link to comment Share on other sites More sharing options...
killaz219 Posted November 16, 2004 Share Posted November 16, 2004 (edited) Never mind, I answered myself. How dumb i was to think otherwise..... :"> Edited November 17, 2004 by killaz219 Link to comment Share on other sites More sharing options...
JSThePatriot Posted November 16, 2004 Share Posted November 16, 2004 I don't get it, how do you use it?<{POST_SNAPBACK}>His post shows how to use it. You have to use his function. Just like all UDF's (user defined functions). Look in the first code box. It shows you what to do. The second one just shows you how it works and gives you the code so you can implement it.JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008Â Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
layer Posted November 16, 2004 Share Posted November 16, 2004 Wow! Thanks JS, and nice little script =D FootbaG Link to comment Share on other sites More sharing options...
ernesthan Posted May 7, 2008 Share Posted May 7, 2008 Very Nice!!!!! Link to comment Share on other sites More sharing options...
YOUF Posted May 7, 2008 Share Posted May 7, 2008 good~! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now