import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = "-----BEGIN PUBLIC KEY-----\n" +
    "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnkvy0VcU0zuAkUeVO5q3VwTYt\n" +
    "SHfl7k+Bd7MokpDU+DnhHAe1an152N5YSq3LGtz84I+qCQnCkth6lBmFEd4RuCk7\n" +
    "1LuJeJgTCy2ToUlGeAfBxjfZMis61uJTCsxN8yrZJbgrfAhuMiEBuCigtUOmmEZh\n" +
    "UnuM1bZ9XLm1srsbiQIDAQAB\n" +
    "-----END PUBLIC KEY-----";

const privateKey = ''

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

