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.
22 lines
549 B
22 lines
549 B
import CryptoJS from 'crypto-js'
|
|
|
|
const SECRET_KEY = CryptoJS.enc.Utf8.parse('KeyWareSecretKey');
|
|
|
|
|
|
// 加密
|
|
export function encrypt(data) {
|
|
const encrypted = CryptoJS.AES.encrypt(data, SECRET_KEY, {
|
|
mode: CryptoJS.mode.ECB,
|
|
padding: CryptoJS.pad.Pkcs7
|
|
});
|
|
return encrypted.toString();
|
|
}
|
|
|
|
// 解密
|
|
export function decrypt(data) {
|
|
const decrypted = CryptoJS.AES.decrypt(data, SECRET_KEY, {
|
|
mode: CryptoJS.mode.ECB,
|
|
padding: CryptoJS.pad.Pkcs7
|
|
})
|
|
return decrypted.toString(CryptoJS.enc.Utf8)
|
|
} |