I'm using CryptoJS library to TripleDES
function but the decrypt data doesn't work. my decrypted data dons't return the origin string.
var t = "a";
var d = "john";
var key = CryptoJS.MD5(t).toString()
var param = CryptoJS.TripleDES.encrypt(d, key).toString();
console.log('decrypt',CryptoJS.TripleDES.decrypt(param, key).toString())
console.log('encrypt',param) // it should return `john`. but it returns a different value.
the result of this encryption:
decrypt 6a6f686e
encrypt U2FsdGVkX19Ww0uMTSo+qAV5PVzsEhSR
I'm using CryptoJS library to TripleDES
function but the decrypt data doesn't work. my decrypted data dons't return the origin string.
var t = "a";
var d = "john";
var key = CryptoJS.MD5(t).toString()
var param = CryptoJS.TripleDES.encrypt(d, key).toString();
console.log('decrypt',CryptoJS.TripleDES.decrypt(param, key).toString())
console.log('encrypt',param) // it should return `john`. but it returns a different value.
the result of this encryption:
decrypt 6a6f686e
encrypt U2FsdGVkX19Ww0uMTSo+qAV5PVzsEhSR
https://github./brix/crypto-js
Share Improve this question asked Nov 19, 2018 at 6:31 S.M_EmamianS.M_Emamian 17.4k40 gold badges154 silver badges273 bronze badges 1- You must the answer ... – Hamboy75 Commented Apr 19, 2020 at 17:35
1 Answer
Reset to default 5solved:
You should CryptoJS.enc.Utf8
inside toString
function.
console.log('decrypt',CryptoJS.TripleDES.decrypt(param, key).toString(CryptoJS.enc.Utf8))