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
}
|