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