This commit is contained in:
2025-03-25 16:35:39 +08:00
parent 2b456dc17e
commit 9463635e03
66 changed files with 864 additions and 64 deletions

30
src/utils/AESCrypto.js Normal file
View File

@@ -0,0 +1,30 @@
import AES from 'crypto-js/aes.js';
import utf8 from 'crypto-js/enc-utf8.js';
class AESCrypto {
/**
* 密钥
* @type {string}
*/
static #AES_KEY = import.meta.env.VITE_AES_KEY;
/**
* AES加密
* @param context {string} 加密内容
*/
static encrypt = (context) => {
return AES.encrypt(context, this.#AES_KEY).toString();
}
/**
* AES解密
* @param context {string}
* @return {string}
*/
static decrypt = (context) => {
const bytes = AES.decrypt(context, this.#AES_KEY);
return bytes.toString(utf8);
}
}
export default AESCrypto;