dasig-solid/frontend/@dasig/scripts/functions/encryptRsa.ts
2025-11-26 10:56:07 +08:00

13 lines
383 B
TypeScript

import { JSEncrypt } from "jsencrypt";
import { $rsaPublicKey } from "../../../configs/config.security.ts";
const enc = new JSEncrypt();
const PUBLIC_KEY = $rsaPublicKey.get();
export default (message: string) => {
enc.setPublicKey(PUBLIC_KEY);
const encrypted = enc.encrypt(message).toString();
const fixedEncrypted = encrypted.replace(/\//g, "~");
return fixedEncrypted;
};