Open yriadie opened 4 years ago
对密码明文先进行 base64 加密,如密码 22
加之后 MjI=
然后对加密后的密文进行 3DES 加密,密码:123456789012345678901234
,偏移量: 12345678
,得到最后密文 1DKCnPsI/FQ=
import CryptoJS from 'crypto-js';
function encode3DES(psw: string): string {
const edsKey = '123456789012345678901234'; // 密码
const edsIv = '12345678'; // 偏移量
const str = CryptoJS.enc.Utf8.parse(psw);
const baseStr = CryptoJS.enc.Base64.stringify(str);
const KeyHex = CryptoJS.enc.Utf8.parse(edsKey);
const baseStrUtf = CryptoJS.enc.Utf8.parse(baseStr);
const encrypted = CryptoJS.TripleDES.encrypt(baseStrUtf,
KeyHex,
{
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
iv: CryptoJS.enc.Utf8.parse(edsIv)
});
return encrypted.toString();
}
Hi All,
I have an issue for decrypting the hex string using 3des.
and it returns a blank on the console. looking forward to your help ...