import { JSEncrypt } from "jsencrypt";

const rsa = new JSEncrypt();
// rsa.setPublicKey(__APP_ENV.VITE_APP_JS_ENCRYPT_PUBLIC_KEY)
rsa.setPublicKey(import.meta.env.VITE_APP_CRYPTO_JS_SECRET_KEY);

export const encryptStr = (text: string): string => {
  const r = rsa.encrypt(text);
  if (!r) {
    throw "加密失败";
  }
  return r;
};

export default {
  encryptStr,
};
