import JSEncrypt from '@/node_modules/jsencrypt/bin/jsencrypt.js' import { getPubKey } from '@/utils/auth.js' //获取公钥 const publickey = getPubKey() export function encrypt(txt) { const encryptor = new JSEncrypt() // 设置公钥 encryptor.setPublicKey(publickey) // 对数据进行加密 return encryptor.encrypt(txt.toString()) }