add 新增响应解密私钥 ;

add 新增 crypto#decryptBase64 Base64解码方法 ;
update 更新响应拦截器增加响应解密逻辑 ;
This commit is contained in:
Michelle.Chung
2023-11-20 19:27:03 +08:00
parent d84fee9319
commit b3c1b95437
6 changed files with 45 additions and 4 deletions

View File

@ -30,6 +30,13 @@ export const encryptBase64 = (str: CryptoJS.lib.WordArray) => {
return CryptoJS.enc.Base64.stringify(str);
};
/**
* 解密base64
*/
export const decryptBase64 = (str: string) => {
return CryptoJS.enc.Base64.parse(str);
};
/**
* 使用密钥对数据进行加密
* @param message
@ -43,3 +50,17 @@ export const encryptWithAes = (message: string, aesKey: CryptoJS.lib.WordArray)
});
return encrypted.toString();
};
/**
* 使用密钥对数据进行解密
* @param message
* @param aesKey
* @returns {string}
*/
export const decryptWithAes = (message: string, aesKey: CryptoJS.lib.WordArray) => {
const decrypted = CryptoJS.AES.decrypt(message, aesKey, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
return decrypted.toString(CryptoJS.enc.Utf8);
};