ndoe-安全
Posted 火腿肠烧烤大赛冠军
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ndoe-安全相关的知识,希望对你有一定的参考价值。
安全涉及
sql注入
使用mysql.escape
const sql = `select username, realname from users where username='${escape(username)}' and password='${escape(password)}'`
xss攻击
使用工具预防即可
const title = xss(blogData.title)
密码加密
自行定义加密规则:
保持一致即可
const crypto = require('crypto')
// 密匙
const SECRET_KEY = '@#SUNsih)Ua(a>?'
// md5加密
function md5(content) {
const md5 = crypto.createHash('md5')
return md5.update(content).digest('hex')
}
function genPassword(password) {
let str = `password=${password};<>${SECRET_KEY}`
return md5(str)
}
console.log(genPassword('123'))
module.exports = {
genPassword
}
以上是关于ndoe-安全的主要内容,如果未能解决你的问题,请参考以下文章