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

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

const publicKey = `MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAM1GfQdZPr/vZbEPP75WyIIPGn8Uoox2
MQD96nRCbCBwEaM3dp11sY/Ga2bwKiqPOrmNa8xVYsqqD91HY5RrTv0CAwEAAQ==`

const privateKey = `MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAzUZ9B1k+v+9lsQ8/
vlbIgg8afxSijHYxAP3qdEJsIHARozd2nXWxj8ZrZvAqKo86uY1rzFViyqoP3Udj
lGtO/QIDAQABAkBeAPWos9nkk4ECQHV0eNGBneEIaS63HDj8t0ryyqgxgc51NemU
Nnf3LgZmKi8NOAMGDV1khIoKgkiauetZtOKBAiEA8+btcqtVw0xAKdakh8LVx9p/
GMEfkIcTqrIZ0ETIFMUCIQDXdRQDp5tfzM4ZREWVt745MQIUhT1ogEicIHofTq4k
2QIgR+XAAzh8jJiSpYKvd5G4oTRImQx8+IbJBl1//IP6Ex0CIQCNXYwcOcSAPuib
O2hMq5pr+/PZcvKvtjvt9IEsOXuZQQIhAIscGt8KDKP3kh/7CmIHgatUCpznQMWU
x435DUicqF75`

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

