24 lines
638 B
JavaScript
24 lines
638 B
JavaScript
import CryptoJS from "crypto-js";
|
|
|
|
const key = CryptoJS.enc.Utf8.parse('6f4ff1fc2b53b9ee')
|
|
const iv = CryptoJS.enc.Utf8.parse('jskey_1618823712')
|
|
|
|
export function encrypt(data) {
|
|
const encrypted = CryptoJS.AES.encrypt(data, key, {
|
|
iv,
|
|
mode: CryptoJS.mode.CBC,
|
|
padding: CryptoJS.pad.Pkcs7
|
|
});
|
|
return encrypted.ciphertext.toString(CryptoJS.enc.Base64);
|
|
}
|
|
|
|
export function decrypt(encryptedData) {
|
|
const encrypted = CryptoJS.AES.decrypt(encryptedData, key, {
|
|
iv,
|
|
mode: CryptoJS.mode.CBC,
|
|
padding: CryptoJS.pad.Pkcs7
|
|
});
|
|
return encrypted.toString(CryptoJS.enc.Utf8);
|
|
}
|
|
|