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)