install dependencies
npm init -y
npm installexpress ejs
EJS
- embedded javascript templates
- 将HTML和JS相结合
- 在HTML格式的文件中插入
<%(...)%>标签并填入JS语法
Render the templates
app.get("/",(res,req)=>{
const countries = [];res.render("index.ejs",{
countries:countries,
total:countries.length
});
})
Week 9
- cross site scripting(xss) attacks: 将恶意脚本注入到网页中,例如在输入框中注入GET方法获取从服务器的返回
- sql injection attacks: 注入unauthorized sql queries并从database中获取数据
hash fundamental
- 哈希值将data转为固定长度的string(hash)
- 单向转换: 无法从哈希值还原出原文件
- salting: 在hash前加入一些随机
bcrypt hashing
- npm install bcrypt
- step 1: generate a random salt
- step 2:combine password and salt
- step 3: use the blowfish cipher
- step 4: output bcrypt hash