diff --git a/src/utils/functions/encryptRsa.ts b/src/utils/functions/encryptRsa.ts new file mode 100644 index 0000000..5b3eeea --- /dev/null +++ b/src/utils/functions/encryptRsa.ts @@ -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 +}