AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AES Encrypt/Decrypt of A File in WXP or Higher
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Tue May 20, 2008 5:08 am    Post subject: Reply with quote

After reading the post below, I tried to write this one. HTH.
http://www.autohotkey.com/forum/topic31420.html&sid=7338d160f7bf3e9194c9335275e974dd

Code:
sTextOriginl := "These are a few tests of AES Encryption/Decryption!"
sPassword  := "AutoHotkey"

SID := 128   ; 128bit AES
nSize := Text_AES(sTextEncrypt, &sTextOriginl, StrLen(sTextOriginl), sPassword, SID, True)   ; Encryption
MsgBox % sTextEncrypt
nSize := Text_AES(sTextDecrypt, &sTextEncrypt, nSize, sPassword, SID, False)   ; Decryption
MsgBox % sTextDecrypt

SID := 192   ; 192bit AES
nSize := Text_AES(sTextEncrypt, &sTextOriginl, StrLen(sTextOriginl), sPassword, SID, True)   ; Encryption
MsgBox % sTextEncrypt
nSize := Text_AES(sTextDecrypt, &sTextEncrypt, nSize, sPassword, SID, False)   ; Decryption
MsgBox % sTextDecrypt

SID := 256   ; 256bit AES
nSize := Text_AES(sTextEncrypt, &sTextOriginl, StrLen(sTextOriginl), sPassword, SID, True)   ; Encryption
MsgBox % sTextEncrypt
nSize := Text_AES(sTextDecrypt, &sTextEncrypt, nSize, sPassword, SID, False)   ; Decryption
MsgBox % sTextDecrypt
Return

Text_AES(ByRef sResult, pData, nSize, sPassword, SID = 256, bEncrypt = True)
{
   VarSetCapacity(sResult, bEncrypt ? nSize+16 : nSize)
   DllCall("RtlMoveMemory", "Uint", &sResult, "Uint", pData, "Uint", nSize)
   nSize := Crypt_AES(&sResult, nSize, sPassword, SID, bEncrypt)
   NumPut(0, sResult, nSize, "char"), VarSetCapacity(sResult,-1)
   Return   nSize
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group