Added encryption
This commit is contained in:
parent
0fba045794
commit
91a8f03749
1 changed files with 12 additions and 0 deletions
12
src/utils/functions/encryptRsa.ts
Normal file
12
src/utils/functions/encryptRsa.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
const PUBLIC_KEY = import.meta.env.VITE_PUBLIC_KEY
|
||||||
|
import { JSEncrypt } from 'jsencrypt'
|
||||||
|
|
||||||
|
const enc = new JSEncrypt()
|
||||||
|
|
||||||
|
export default async (message: string) => {
|
||||||
|
enc.setPublicKey(PUBLIC_KEY)
|
||||||
|
const encrypted = enc.encrypt(message).toString()
|
||||||
|
const fixedEncrypted = encrypted.replace(/\//g, '~')
|
||||||
|
|
||||||
|
return fixedEncrypted
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue