You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.0 KiB
30 lines
1.0 KiB
1 week ago
|
/*
|
||
|
* @Descripttion:
|
||
|
* @version: 1.0.0
|
||
|
* @Author: YeeChan
|
||
|
* @Date: 2020-07-09 18:54:38
|
||
|
*/
|
||
|
import * as CryptoJS from "./aes.js"
|
||
|
|
||
|
export default class AesTools {
|
||
|
private static readonly KEY_custom = 'b#63fFJ6AvkK3YT*';
|
||
|
private static readonly IV_custom = 'J$f4DU%sNL73M&Go';
|
||
|
|
||
|
//加密
|
||
|
public static encrypt_custom(str: string) {
|
||
|
var key = CryptoJS.enc.Utf8.parse(AesTools.KEY_custom);// 秘钥
|
||
|
var iv = CryptoJS.enc.Utf8.parse(AesTools.IV_custom);//向量iv
|
||
|
var encrypted = CryptoJS.AES.encrypt(str, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 });
|
||
|
return encrypted.toString();
|
||
|
}
|
||
|
|
||
|
//解密
|
||
|
public static decrypt_custom(str: string) {
|
||
|
var key = CryptoJS.enc.Utf8.parse(AesTools.KEY_custom);// 秘钥
|
||
|
var iv = CryptoJS.enc.Utf8.parse(AesTools.IV_custom);//向量iv
|
||
|
var decrypted = CryptoJS.AES.decrypt(str, key, { iv: iv, padding: CryptoJS.pad.Pkcs7 });
|
||
|
return decrypted.toString(CryptoJS.enc.Utf8);
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|