17 lines
300 B
TypeScript
17 lines
300 B
TypeScript
|
import {JSEncrypt} from "jsencrypt";
|
||
|
|
||
|
const rsa = new JSEncrypt()
|
||
|
rsa.setPublicKey(__APP_ENV.VITE_APP_RSA_PUBLIC_KEY)
|
||
|
|
||
|
const encryptStr = (text: string): string => {
|
||
|
const r = rsa.encrypt(text);
|
||
|
if (!r) {
|
||
|
throw "加密失败";
|
||
|
}
|
||
|
return r;
|
||
|
}
|
||
|
|
||
|
export default {
|
||
|
encryptStr
|
||
|
}
|