1.首先npm一下JSEncrypt
2.找到node_modules下的jsencrypt文件夹
3.在jsencrypt文件下找到jsencrypt.min.js,将它复制到你存放工具类js的文件夹下,例如我放到了utils文件夹下
4.使用
var JSEncrypt = require('./jsencrypt/jsencrypt.min.js'); 写一个加密函数并导出 export const encryptRAS = (word) => { var encryptor = new JSEncrypt() // 创建加密对象实例 encryptor.setPublicKey(rsaPublickey)//设置公钥 var rsaPassWord = encryptor.encrypt(word) // 对内容进行加密 return rsaPassWord; }切记不要使用jsencrypt.js,会报eval is not a fuction的错误,就算使用微信小程序开发工具的构建npm也一样
标签:加密,微信,RSA,js,JSEncrypt,encryptor,var,jsencrypt From: https://www.cnblogs.com/idontcare/p/18199611