node 密码加密方法
建立连接
const crypto = require('crypto') const { CRYPTO_SECRET_KEY } = require('../conf/secretKeys') /** * md5 加密 * @param {string} content 明文 */ function _md5(content) { const md5 = crypto.createHash('md5') return md5.update(content).digest('hex') } /** * 加密方法 * @param {string} content 明文 */ function doCrypto(content) { const str = `password=${content}&key=${CRYPTO_SECRET_KEY}` return _md5(str) } module.exports = doCrypto
使用
const doCrypto = require("../utils/cryp"); await createUser({userName,password:doCrypto(password), gender})
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
码云笔记 » node 密码加密方法
码云笔记 » node 密码加密方法