/* * @Author: 尹鹏孝 * @Date: 2021-09-03 15:02:26 * @LastEditTime: 2021-09-03 15:43:03 * @LastEditors: Please set LastEditors * @Description: 密码加密 * @FilePath: \koa2-test-api\src\utils\cropto.js */ const CryptoJS = require('crypto-js'); const config = require("../config/config.js") console.log(config); function enCrypto(key) { const result = CryptoJS.MD5(key + config.cryptoSecretKey).toString(); return result; } function deCrypto(cipherText) { var bytes = CryptoJS.MD5.decrypt(cipherText, config.cryptoSecretKey); var originalText = bytes.toString(CryptoJS.enc.Utf8); console.log('MD5解密:', originalText); return originalText; } module.exports = { enCrypto, deCrypto }