View Single Post
Old 13th June 2018, 17:09   #9
Anders's Avatar
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,294
I played around a bit with a different plug-in and it seems to work:

Crypto::Encrypt AES-128 "m:MyKey" "m:MyIV" "m:This is a test"
Pop $3
DetailPrint CT=$3

Crypto::Decrypt AES-128 "m:MyKey" "m:MyIV" "b64:$3"
Pop $4
DetailPrint PT(b64)=$4
Crypto::Decode BASE64 $4
Pop $0
DetailPrint PT=$0

Crypto::DeriveKey AES-128 "m:MyKey"
Pop $1
DetailPrint DK(b64)=$1

Crypto::Decrypt AES-128 "b64:$1" "m:MyIV" "b64:$3"
Pop $0
Crypto::Decode BASE64 $0
Pop $0
DetailPrint PT=$0
Input types are m (narrow string), w (wide string, Unicode only) and b64. The wide string type is a bit useless if you need to read the decrypted data back into a NSIS register because Decrypt returns it as raw UTF-16 encoded as Base64.

The input key is transformed with CryptDeriveKey:SHA1 unless you use the b64 type.

AES is AES CBC with padding.
Attached Files
File Type: zip Crypto 1.5 (7.4 KB, 273 views)

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote