const JSEncrypt = require('../libs/jsencrypt/lib/index').default; export function encryptedData(key, data) { // 新建JSEncrypt对象 let encryptor = new JSEncrypt(); // 设置公钥 encryptor.setPublicKey(key); // 加密数据 return encryptor.encrypt(data); }