RazerM Posted May 16, 2006 Posted May 16, 2006 (edited) I have made an RC4 Text Encryption UDF. I know RC4 isn't the strongest encryption but anyway here it is: expandcollapse popup;=============================================================================== ; ; Function Name: _StringEncryptRC4 ; Description:: Encrypts text using RC4 Encryption ; Parameter(s): $text, $encryptkey ; Requirement(s): AutoIt ; Return Value(s): Encrypted String ; Author(s): RazerM ; ;=============================================================================== ; Func _StringEncryptRC4($text, $encryptkey) Local $sbox[256] Local $key[256] Local $temp Local $a Local $i Local $j Local $k Local $cipherby Local $cipher $i = 0 $j = 0 __RC4Initialize($encryptkey, $key, $sbox) For $a = 1 To StringLen($text) $i = Mod(($i + 1),256) $j = Mod(($j + $sbox[$i]),256) $temp = $sbox[$i] $sbox[$i] = $sbox[$j] $sbox[$j] = $temp $k = $sbox[Mod(($sbox[$i] + $sbox[$j]),256)] $cipherby = BitXOR(Asc(StringMid($text, $a, 1)),$k) $cipher = $cipher & Chr($cipherby) Next Return _StringToHexEx($cipher) EndFunc ;==>_StringEncryptRC4 ;=============================================================================== ; ; Function Name: _StringDecryptRC4 ; Description:: Decrypts text using RC4 Encryption ; Parameter(s): $text, $encryptkey ; Requirement(s): AutoIt ; Return Value(s): Decrypted String ; Author(s): RazerM ; Note(s): RC4 uses the same algorithm to encrypt and decrypt ; ;=============================================================================== ; Func _StringDecryptRC4($text, $encryptkey) Local $sbox[256] Local $key[256] Local $temp Local $a Local $i Local $j Local $k Local $cipherby Local $cipher $text = _HexToStringEx($text) $i = 0 $j = 0 __RC4Initialize($encryptkey, $key, $sbox) For $a = 1 To StringLen($text) $i = Mod(($i + 1),256) $j = Mod(($j + $sbox[$i]),256) $temp = $sbox[$i] $sbox[$i] = $sbox[$j] $sbox[$j] = $temp $k = $sbox[Mod(($sbox[$i] + $sbox[$j]),256)] $cipherby = BitXOR(Asc(StringMid($text, $a, 1)),$k) $cipher = $cipher & Chr($cipherby) Next Return $cipher EndFunc ;==>_StringDecryptRC4 ; Helper function Func __RC4Initialize($strPwd, ByRef $key, ByRef $sbox) Dim $tempSwap Dim $a Dim $b $intLength = StringLen($strPwd) For $a = 0 To 255 $key[$a] = Asc(StringMid($strPwd, (Mod($a,$intLength))+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 EndFunc ;==>__RC4Initialize Func _HexToStringEx($strHex) Return BinaryToString("0x" & $strHex) EndFunc ;==>_HexToStringEx Func _StringToHexEx($strChar) Return Hex(StringToBinary($strChar)) EndFunc ;==>_StringToHexEx oÝ÷ Øw«z+-ç±jjey«¢+Ø¥¹±ÕÅÕ½ÐíIйÔÌÅÕ½Ðì(ÀÌØíÑáÐô%¹ÁÕÑ ½à ÅÕ½ÐíQáÐÅÕ½Ðì°ÅÕ½Ðí¹ÑÈÑáÐѼ¹ÉåÁÐÅÕ½Ðì¤(ÀÌØí¹ÉåÁÑäô%¹ÁÕÑ ½à ÅÕ½Ðí-äÅÕ½Ðì°ÅÕ½Ðí¹ÑÈäѼ¹ÉåÁÐÑ¡ÑáÐÅÕ½Ðì¤(ÀÌØíÉÐôQ¥µÉ%¹¥Ð ¤(ÀÌØí¹ÉåÁÑô}MÑÉ¥¹¹ÉåÁÑIÐ ÀÌØíÑáаÀÌØí¹ÉåÁÑä¤)5Í ½à À°ÅÕ½Ðí¹ÉåÁÑ¥½¸Q½½¬èÅÕ½Ðì°Q¥µÉ¥ ÀÌØíÉФµÀìÅÕ½ÐìµÌÅÕ½Ðì¤)5Í ½à À°ÅÕ½Ðí¹ÉåÁÑÅÕ½Ðì°ÅÕ½Ðí¹ÉåÁÑÑáÐ¥ÌèÅÕ½ÐìµÀìÀÌØí¹ÉåÁѤ)5Í ½à À°ÅÕ½ÐíÉåÁÑÅÕ½Ðì°ÅÕ½ÐíÉåÁÑÑáÐ¥ÌèÅÕ½ÐìµÀì}MÑÉ¥¹ÉåÁÑIÐ ÀÌØí¹ÉåÁѰÀÌØí¹ÉåÁÑ䤤(( Edited June 4, 2007 by RazerM My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
RazerM Posted May 17, 2006 Author Posted May 17, 2006 Thanks. It is about half the time of the built in _StringEncrypt function. My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
M a k a v e l ! Posted August 12, 2006 Posted August 12, 2006 Nicely done RazerM. [font="Lucida Sans Unicode"]M a k. a v e L ![/font]
Moderators SmOke_N Posted August 12, 2006 Moderators Posted August 12, 2006 (edited) Very nice indeed, nice job Razer. Edit: A suggestion though, since you're not using unique vars, is to keep them in a local scope. Edited August 12, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
RazerM Posted August 12, 2006 Author Posted August 12, 2006 I updated it. Thanks SmOke_N My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
erifash Posted August 13, 2006 Posted August 13, 2006 Faster string->hex functions:Func _HexToStringEX($strHex) Return BinaryString("0x" & $strHex) EndFunc Func _StringToHexEx($strChar) Return Hex(BinaryString($strChar)) EndFunc My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver
RazerM Posted August 13, 2006 Author Posted August 13, 2006 I would never have thought of doing that! Im implementing it now My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
lyledg Posted June 4, 2007 Posted June 4, 2007 Hey Razerm It seems this script no longer works with the latest released version of the Autoit?? Return [b]BinaryString[/b]("0x" & $strHex) The BinaryString function no longer works?? Any ideas?
RazerM Posted June 4, 2007 Author Posted June 4, 2007 (edited) I'll update in a few minutes. Edit: Updated Edited June 4, 2007 by RazerM My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
RazerM Posted June 4, 2007 Author Posted June 4, 2007 It doesn't need one, but if you do, don't post it in this topic. My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
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