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

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

const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMAIICS6NkbU5tB1zMK/midmr2KKSKSU\n' +
  '3tcP2AAvwHPLIlgkw1y3tPnB89RFX9T+gBiWLup2HblOBYfPvolOBrsCAwEAAQ=='

const privateKey = 'MIIBVgIBADANBgkqhkiG9w0BAQEFAASCAUAwggE8AgEAAkEAwAggJLo2RtTm0HXM\n' +
  'wr+aJ2avYopIpJTe1w/YAC/Ac8siWCTDXLe0+cHz1EVf1P6AGJYu6nYduU4Fh8++\n' +
  'iU4GuwIDAQABAkBMKmzlZF5m1cb+49plXC2+dwIVaZfKf6mrT4Ny/32r7zP8uQDr\n' +
  '9Qws6ek/JyHdE8nK8I9FJ8AHaQf3tg4sNJ+BAiEA6bxjonxzPcMWuALr/Z7kjEdt\n' +
  'MSft65YShttRTUpbh+ECIQDSUsmaAJIR6btsQvT1haQEzulFFcLIRnq1SS6hwbTy\n' +
  'GwIhAMWgF84m03mBHhBvyAEk+7DwI47QaAYtWXTUsyVanZGBAiEAmwjljLzA761g\n' +
  'N6R/lwAk8FppP0CULTcuurUwR5JXRGMCIQDN6v0A2RVF5NrMkYLB0KprArX9Howj\n' +
  'vZt2g0IfIEAH2w=='

// 加密
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) // 对数据进行解密
}

