Hello All--
I have been trying to use the string encryption from this post:
http://www.autohotkey.com/forum/topic23 ... s&start=15
Pretty much I take the encrypted string and write it to an INI file for reading/decryption later. Running tests with the code, however, only allows me to successfully decrypt once.
Code:
!+F12::
SID := 128 ; 256bit AES
pKey := "n0disassemble"
KeyWait, Alt, L
KeyWait, LShift, L
InputBox, pPassword, Macro Password, Please Specify Windows Password (It will be encrypted):,,300,125
pPassword = %pPassword%
nSize := Text_AES(sTextEncrypt, &pPassword, StrLen(pPassword), pKey, SID, True) ; Encryption
IniWrite, %sTextEncrypt%, macro.ini, User, Password
pPassword = 1234567
InputBox, pPassphrase, Macro Password, Please Specify PassPhrase (It will be encrypted):,,300,125
pPassphrase = %pPassphrase%
nSize := Text_AES(sTextEncrypt, &pPassphrase, StrLen(pPassphrase), pKey, SID, True) ; Encryption
IniWrite, %sTextEncrypt%, macro.ini, User, Passphrase
pPassphrase = 1234567
return
+^F12::
SID := 128 ; 256bit AES
pKey := "n0disassemble"
KeyWait, Control, L
KeyWait, LShift, L
IniRead, pPassword, macro.ini, User, Password, 0
nSize := Text_AES(pWordDecrypt, &pPassword, nSize, pKey, SID, False) ; Decryption
MsgBox % pWordDecrypt
IniRead, pPassphrase, macro.ini, User, Passphrase, 0
nSize := Text_AES(pPhraseDecrypt, &pPassphrase, nSize, pKey, SID, False) ; Decryption
MsgBox % pPhraseDecrypt
Again this is more proof of concept, once I get it to work properly, I'll clean up the code, move the key definitions, etc.
Text_AES is defined as noted here:
Code:
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
}
When I check the encrypted string in the INI file, they look identical but when I decrypt, the first will come out fine...the second will come up as a completely different string.
Any help would be appreciated.