最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

react native - TripleDES encrypt and decrypt in javascript - CryptoJS - Stack Overflow

programmeradmin1浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 5

solved:

You should CryptoJS.enc.Utf8 inside toString function.

console.log('decrypt',CryptoJS.TripleDES.decrypt(param, key).toString(CryptoJS.enc.Utf8))
发布评论

评论列表(0)

  1. 暂无评论