import JSEncrypt from "jsencrypt";

// 公钥
const PUBLICK_KEY =
  "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALM5Ng98GCAQLcUwdPmxZQ2+QUaWbrWfkg4BLY0u0twGHKC7upBPvpr7f1uvfv6EiMsOCEtELN1I5nY9nmuvIk8CAwEAAQ==";

// 创建实例
const encrypt = new JSEncrypt();
encrypt.setPublicKey(PUBLICK_KEY);

// 加密
const encryption = (data = "") => {
  if (!data) return data;
  return encrypt.encrypt(data);
};

// 解密
const decryption = (data = "") => {
  if (!data) return data;
  return encrypt.decrypt(data);
};

export { encryption, decryption };
