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
}
