代码如下:
// 3DES 解密
function desDecrypt(message:string, key:string) :string {
try {
const keyHex: string = CryptoJS.enc.Base64.parse(key);
// console.log("下面解密会导致崩溃===>>>>>");
const decrypted: string = CryptoJS.TripleDES.decrypt(
message
, keyHex, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7,
}).toString(CryptoJS.enc.Utf8);
return decrypted;
} catch (e) {
console.log(JSON.stringify(e))
return JSON.stringify(e)
}
}
数据量大于2M的时候,推荐使用分段加解密,分段加解密参考链接:
https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/crypto-encrypt-decrypt-by-segment-V5