13 lines
383 B
TypeScript
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;
|
|
};
|