jsencrypt加密

664 阅读1分钟

使用jsencrypt实现密码等参数的加密

  • 安装jsencrypt
  • 使用encrypt(pwd)
export function encrypt(txt) {
  const encryptor = new JSEncrypt();
  encryptor.setPublicKey(publicKey); // 设置公钥
  return encryptor.encrypt(txt); // 对需要加密的数据进行加密
}
  • publicKey 公钥 后台生成公钥私钥,将公钥返回给前端加密