From 91a8f037498f860847d5b61354cae3ed73e7e86d Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Mon, 10 Nov 2025 13:40:46 +0800 Subject: [PATCH] Added encryption --- src/utils/functions/encryptRsa.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/utils/functions/encryptRsa.ts 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 +}