前端使用JSEncrypt进行加密和解密

下载链接:https://www.bootcdn.cn/jsencrypt/

使用方法:

1、引入jsencrypt

2、使用方法

// 加密公钥
const key = `xxxxxx`;
function setEncrypt (msg) {
  //msg:需要加密的字符
  const jsencrypt = new JSEncrypt()
  jsencrypt.setPublicKey(key)
  return jsencrypt.encrypt(msg)//得到经过加密后的字符
}
复制代码
// 解密私钥
const privateKey = `---`
 
// 解密
export function decrypt (msg) {
  let decrypt = new JSEncrypt()
  decrypt.setPrivateKey(privateKey)
  var decryptMsg = decrypt.decrypt(msg)
  return decryptMsg
}
复制代码

参考链接:https://www.cnblogs.com/hlweng-0207/p/12971180.html

最后小声哔哔一点:不知道为什么csdn上的人随便一个小问题都要积分都要钱,就比如这个Js的下载

  

posted @   锦年与panda  Views(1065)  Comments(0Edit  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· 单线程的Redis速度为什么快?
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
点击右上角即可分享
微信分享提示