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

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

const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDJYGfQjJ/HPUmDq3uKdx9whqlaZq2VXmLOKc26fhSxfqxRL/XEmlEcAeTnGbkA9ndcG0qBXeu2IRFW+sh09aSXCyaT0kavSvQf6O14lE4WLaEudhUjyJdnNE8IfDmT1YJei5eZXgg3+aQ+hheGJQrxTYldvffHPVU+MNp5+JL+pQIDAQAB'

const privateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMlgZ9CMn8c9SYOre4p3H3CGqVpmrZ" +
    "VeYs4pzbp+FLF+rFEv9cSaURwB5OcZuQD2d1wbSoFd67YhEVb6yHT1pJcLJpPSRq9K9B/o7XiUThYtoS52FSPIl2c0Twh8OZPVgl6Ll5leC" +
    "Df5pD6GF4YlCvFNiV2998c9VT4w2nn4kv6lAgMBAAECgYEAlNCQh3aUUNmCrTIZfs7fRfnNxwef+YUhwTb1WH757d0tnGWz2pErpWXk8b95" +
    "jzOUK1Xjrkxo91Pii4OShZROBx1aS/tF4BG0RVIyX2Il54flG//vLvZCjxkAT5HY+iwGtkUFBVG7t8abANF6Dp09LbYbzKgCBY6t0CglM0O" +
    "kedUCQQDjnKjIRDrBVWpKZQmhHEt7FZU6AgxWkhA6aWF9mz6xx2XwIyic6RWkWiImFIBVTB2qrxcFePhBGYvyfgo9e1i3AkEA4n4WKduTai" +
    "FWyycQiUpiI4GagiHt+FkSQx1jiRWSNmaR75gDN3IVJKkgnffZD0xsxCwMxypTptJ3TRM24y0vgwJAAd1xwJpWhOkHQu7LAmfx8mM94sjLg" +
    "xYVTfU5GEdiXyCMJEiVd5utUrhuWTOHzase/xwKK0BPgHEOJYGE4fYVxwJBALykmd8pJGH7/KdeFRbUXmMGWmNS0TrNLTm7K6EM12f6DEjL" +
    "irpOia+sMh+AREjKtbi6m7Xy2hOTLoyCmW+jvfMCQBvAzPYrsGq48ZpAOTZn5D80BokAl65xov4tj970k1pj0HunSdhz6ndRA/6yVklFnt/" +
    "D/HJ/kCZn5zEvBdtLQTE="

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

