There is no problem to decrypt the encrypted string using crypto-js.
My code is here :
'use strict';
const cryptoJs = require('crypto-js');
const key = 'myTestKey';
const encMyPassword = cryptoJs.AES.encrypt('myPassword', key).toString();
console.log(`encrypted : ${encMyPassword}`);
const decMyPassword = cryptoJs.AES.decrypt(encMyPassword, key).toString(cryptoJs.enc.Utf8);
console.log(`decrypted : ${decMyPassword}`);
Output:
encrypted : U2FsdGVkX19XxsV6RGCXGcy7ySNarTOa4o0+uAWGJZY=
decrypted : myPassword
I tried to decrypt the encrypted string in postgresql, but it fails.
select decrypt('U2FsdGVkX19XxsV6RGCXGcy7ySNarTOa4o0+uAWGJZY='::bytea, 'myTestKey'::bytea, 'aes');
Output:
SQL Error [39000]: ERROR: decrypt error: Data not a multiple of block size
How do I fix my query?