import { JSEncrypt } from 'jsencrypt' // 加密公钥 const key = `MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANvJdcirkqRV7m50jxzfmUQ3kfHZg/y16CtIUQJKo29BJxlKFoz9sc15faGuH/4maDULewXGBBZpRVF0t+m6iYMCAwEAAQ==` // 加密 export function rsaEncrypt (msg) { const jsencrypt = new JSEncrypt() jsencrypt.setPublicKey(key) const encryptMsg = jsencrypt.encrypt(msg) return encryptMsg } // 解密私钥 const privateKey = `MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEA28l1yKuSpFXubnSPHN+ZRDeR8dmD/LXoK0hRAkqjb0EnGUoWjP2xzXl9oa4f/iZoNQt7BcYEFmlFUXS36bqJgwIDAQABAkEApqbqbX9TENKrmQs+nNkaoPQ18JlLECpqYa9S5Zbst+TaYwcKDbu1EuHc9G6E+5gDOLulOxbxIYU/PctIQ6pqcQIhAO7KSnNlqpAKnFb3lTtdE6Ct0AW/eJQW2f8g1UlCK5pbAiEA66COmDu7SIzISasS18puQLIoBWx8SQi7lvjyR80a5fkCIFuG7kKNFXNgncw32duHMZ7FAJczbORWXfiMfTQ3SL9BAiBpUlUquthV74e/VhaQGk354Sh+dCWBx8OCEjjJ22ZAkQIgWOClJ4WVNkYhk8Qitt98pnXPjBRwUDGq2D2NWBujfgg=` // 解密 export function rsaDecrypt (msg) { const decrypt = new JSEncrypt() decrypt.setPrivateKey(privateKey) const decryptMsg = decrypt.decrypt(msg) return decryptMsg }