How to decrypt cCryptoGS (CryptoJS) string using OpenSSL?
Sample function in Google Apps Script using the cCryptoGS library:
function encrypt() {
let message = "Hello world!";
let pw = "password";
let encrypted = cCryptoGS.CryptoJS.AES.encrypt(message, pw).toString();
Logger.log(encrypted);
// Sample result, changes each time due to the salt
// U2FsdGVkX19A/TPmx/tmR9MRiKU9AQPhUYKD/lyoY/c=
};
Trying to decrypt using OpenSSL:
echo "U2FsdGVkX19A/TPmx/tmR9MRiKU9AQPhUYKD/lyoY/c=" | openssl enc -d -a -A -aes-256-cbc -iter 1 -md md5 -pass pass:'password' && echo
That command returned an error:
bad decrypt
803B3E80A67F0000:error:1C800064:Provider routines:ossl_cipher_unpadblock:bad decrypt:../providers/implementations/ciphers/ciphercommon_block.c:124:
OpenSSL version is OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
.
How could the cyphertext generated by cCryptoGS be decrypted using OpenSSL?
Comments
Post a Comment