dasig/frontend/src/@dasig/scripts/functions/encryptRsa.ts
2025-11-20 13:03:40 +08:00

13 lines
384 B
TypeScript

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