我使用CryptoJS来做一些AES加密。代码是
const cipher = CryptoJS.AES.encrypt(plaintext, key)如果我使用cipher.toString(CryptoJS.enc.Base64),web就会崩溃,并显示"TypeError: wordArray.clamp不是一个函数“。好像只有不带任何参数的toString()才适合我,所以我想知道后台解密的toString()方法的默认编码器。
发布于 2021-01-29 21:59:47
我也遇到过类似的问题:
下面的代码返回一个WordArray,而不是一个字符串,因此代码崩溃,因为需要一个字符串:
const hashcode = CryptoJS.MD5(CryptoJS.enc.Latin1.parse(a.result));要用toString()方法解决这个问题,只需在最后添加它即可。
const hashcode = CryptoJS.MD5(CryptoJS.enc.Latin1.parse(a.result)).toString();https://stackoverflow.com/questions/57744295
复制相似问题