|
@@ -7,7 +7,7 @@ const publicKey = import.meta.env.VITE_APP_RSA_PUBLIC_KEY;
|
|
|
const privateKey = import.meta.env.VITE_APP_RSA_PRIVATE_KEY;
|
|
const privateKey = import.meta.env.VITE_APP_RSA_PRIVATE_KEY;
|
|
|
|
|
|
|
|
// 加密
|
|
// 加密
|
|
|
-export const encrypt = (txt: string | undefined) => {
|
|
|
|
|
|
|
+export const encrypt = (txt) => {
|
|
|
if(!!!txt) {
|
|
if(!!!txt) {
|
|
|
throw new Error('加密数据不能为空')
|
|
throw new Error('加密数据不能为空')
|
|
|
}
|
|
}
|
|
@@ -17,7 +17,7 @@ export const encrypt = (txt: string | undefined) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 解密
|
|
// 解密
|
|
|
-export const decrypt = (txt: string) => {
|
|
|
|
|
|
|
+export const decrypt = (txt) => {
|
|
|
const encryptor = new JSEncrypt();
|
|
const encryptor = new JSEncrypt();
|
|
|
encryptor.setPrivateKey(privateKey); // 设置私钥
|
|
encryptor.setPrivateKey(privateKey); // 设置私钥
|
|
|
return encryptor.decrypt(txt); // 对数据进行解密
|
|
return encryptor.decrypt(txt); // 对数据进行解密
|