feat: 整合登录

This commit is contained in:
xlsea
2024-08-16 16:33:11 +08:00
parent e6aa25e9f8
commit 243de247f7
49 changed files with 889 additions and 3882 deletions

21
src/utils/jsencrypt.ts Normal file
View File

@ -0,0 +1,21 @@
import JSEncrypt from 'jsencrypt';
// 密钥对生成 http://web.chacuo.net/netrsakeypair
const publicKey = import.meta.env.VITE_APP_RSA_PUBLIC_KEY;
// 前端不建议存放私钥 不建议解密数据 因为都是透明的意义不大
const privateKey = import.meta.env.VITE_APP_RSA_PRIVATE_KEY;
// 加密
export const encrypt = (txt: string) => {
const encryptor = new JSEncrypt();
encryptor.setPublicKey(publicKey!); // 设置公钥
return encryptor.encrypt(txt); // 对数据进行加密
};
// 解密
export const decrypt = (txt: string) => {
const encryptor = new JSEncrypt();
encryptor.setPrivateKey(privateKey!); // 设置私钥
return encryptor.decrypt(txt); // 对数据进行解密
};