微信小程序使用CryptoJS加密PassWord(MD5)
背景及环境:
微信小程序登录页面,需要加密登录密码发送给后端,使用 MD5 来加密密码
开发工具:微信开发者工具
-
npm安装CryptoJS
查看有哪些crypto的包
npm search crypto找到自己需要的包安装
npm install crypto-js
-
构建 npm
使用微信开发者工具构建 npm

-
解决警告
出现警告报错,打开 miniprogram_npm/crypto-js/index.js文件,将最后面的
["crypto"]中的"crypto"删掉,注意每次重新构建 npm 都需要删掉。//miniprogram-npm-outsideDeps=[]

-
创建 crypto.js工具类

const CryptoJS = require('crypto-js')
export function getmd5(password){
return CryptoJS.MD5(password).toString();
}
-
使用
例如我的 login.js 文件里面
//引入 var crypto = require("../../utils/crypto") //需要的地方直接调用即可! const encryptedPwd= crypto.getmd5(this.data.password)



![[天翼杯 2021]esay_eval - RCE(disabled_function绕过||AS_Redis绕过)+反序列化(大小写wakeup绕过)](https://img-blog.csdnimg.cn/90a3a05ad5cb4fd0905846c8c2d07b8a.png)







![2023年中国隆鼻行业发展历程及趋势分析:隆鼻手术市场将实现进一步增长[图]](https://img-blog.csdnimg.cn/img_convert/cf14dba05537c50b6ba1485af1e28ce8.png)





![web:[护网杯 2018]easy_tornado](https://img-blog.csdnimg.cn/904763e802da4e8ebc98bd713a803ad2.png)

