import { JSEncrypt } from 'jsencrypt';

// 加密公钥
const key =
	`MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDMOcPB06u5yKyQsPjfVWiWgbEIrd14kiXNNihciaVKb6HnkQvq7zpQuZ80WEX94spnUMI3iOAl/GmIvHrpGwcbB4hJbznm+PajiwnUSPuCCXA68YJF640cJKb/8KeM7WVz69OFkIEPHhVxOy4FFF5QWe/kt6zOZ19HmE+ak+5x/QIDAQAB`

// 加密
export function rsaEncrypt(msg) {
	const jsencrypt = new JSEncrypt()
	jsencrypt.setPublicKey(key)
	const encryptMsg = jsencrypt.encrypt(msg)
	return encryptMsg
}

// 解密私钥
const privateKey = `---`

// 解密
export function rsaDecrypt(msg) {
	const decrypt = new JSEncrypt()
	decrypt.setPrivateKey(privateKey)
	const decryptMsg = decrypt.decrypt(msg)
	return decryptMsg
}
