Reputation: 429
Under my development machine WAMP, AES_ENCRYPT and AES_DECRYPT is not working as required, also i tested with ENCODE and DECODE and same happen... I'm not understading why...
SELECT
AES_ENCRYPT('text', SHA1('My secret passphrase')) as enc,
AES_DECRYPT(AES_ENCRYPT('text', SHA1('My secret passphrase')), SHA1('My secret passphrase')) as denc
Result:
enc : 3278167d9d630327c74d83067964c9b6
denc: 74657874
text after encryption doesn't look good and decryption is wrong too.
Any suggestions?
Upvotes: 1
Views: 345
Reputation: 24949
it is working even on your side but it is blob data you are seeing.
denc: 74 65 78 74
74=t 65=e 78=x 74=t, add them together you get 'text'
ascii table here: http://www.asciitable.com/
try it with cast
to make it more obvious:
SELECT cast(AES_ENCRYPT('text', SHA1('My secret passphrase')) as char(100)) as enc,
cast(AES_DECRYPT(AES_ENCRYPT('text', SHA1('My secret passphrase')), SHA1('My secret passphrase')) as char(100)) as denc
Upvotes: 2