Added _EncryptString("string","password")
Added _DecryptString("string","password")
These functions use the built in RSA/RC4/MD5 functions that windows has. Here is an example of how you can use it, you will need DLLSTRUCT.AU3.
Simple Example on decrypting a string
#include <crypto.au3> Local $password,$encryptedstring = "HBukowWHoqGJ7QkfRnX8FbOGY/+sO3yq5aA=" $password = InputBox("Enter Password","Type 'PASSWORD' to decrypt","","*") MsgBox(0,"Result",_DecryptString($encryptedstring,$password))
#cs vi:ts=4 sw=4: Ejoc #ce #include <crypto.au3> Opt("MustDeclareVars",1) Global $s = "This is a plain text line" Global $password = "PASSWORD" Global $filename = "encrypted.txt" Global $decrypted = "" ;encrypt the string and write a new file If Not _EncryptStringToFile($s,$password,$filename) Then MsgBox(0,"error","Error Encrypting") exit EndIf $decrypted = _DecryptFileToString($filename,$password) MsgBox(0,"decrypted",$decrypted)
Headers for the functions:
;===================================================== ; _DecryptString($szString,$szPassword) ; Decrypt an ASCII armoured string ; $szString string to decrypt ; $szPassword password to Decrypt it with ; Return Success New ASCII string, Failure @error is set ; $plain = _DecryptString("HBukowWHoqGJ7QkfRnX8FbOGY/+sO3yq5aA=","PASSWORD") ;===================================================== ;===================================================== ; _EncryptString($szString,$szPassword) ; encrypt a string and ASCII armour it ; $szString string to encrypt ; $szPassword password to encrypt it with ; Return Success New ASCII string, Failure @error is set ; $encrypted = _EncryptString("A string","My password") ;===================================================== ;===================================================== ; _EncryptStringToFile($szString,$szPassword,$szFileName) ; encrypt a string and save it to disk ; $szString string to encrypt ; $szPassword password to encrypt it with ; $szFileName name of the encrypted File ; Return Success 1, Failure 0 ;===================================================== ;===================================================== ; _DecryptFileToString($szFileName,$szPassword) ; Read a file that was encrypted, and decrypt ; $szFileName name of the encrypted File ; $szPassword password to decrypt it with ; Return Success a string that is the whole file, Failure "" ;===================================================== ;===================================================== ; _EncryptFile($szSource,$szDest,$szPassword) ; Encrypt a file using RSA and RC4 with an MD5 Hashed password ; $szSource Filename of the source file ; $szDest Filename of the new encrypted file ; $szPassword Password to use to encrypt ; Return Success 1, Failure 0 @ERROR is set ; -2 Error opening the source file ; -3 Error creating CryptProv ; -4 Error creating HASH ; -5 Error hashing password ; -6 Error creating KEY ; -7 Error encrypting data ; -8 Error writing the new file ;===================================================== ;===================================================== ; _DecryptFile($szSource,$szDest,$szPassword) ; Decrypt a file using RSA and RC4 with an MD5 Hashed password ; Just a wrapper to _FileEncrypt() as it decodes ; $szSource Filename of the encrypted file ; $szDest Filename of the new decrypted file ; $szPassword Password to use to decrypt ; Return Success 1, Failure 0 @ERROR is set ; -2 Error opening the source file ; -3 Error creating CryptProv ; -4 Error creating HASH ; -5 Error hashing password ; -6 Error creating KEY ; -7 Error decrypting data ; -8 Error writing the new file ;=====================================================
Attached Files
Edited by Ejoc, 04 June 2005 - 04:20 PM.






