dev.Log
node.js 비밀번호 암호화 본문
bcrypt 알고리즘
npm install -s bcrypt
const bcrypt = require('bcrypt');
const saltRounds = 10;
const myPlaintextPassword= '1111111';
const another = '22222';
bcrypt.hash(myPlaintextPassword, saltRounds, function(err, hash){
console.log(hash);
//hash를 DB에 저장하면 된다.
bcrypt.compare(myPlaintextPassword, hash, function(err, result){
console.log('my password', result); //true
})
bcrypt.compare(another, hash, function (err, result){
console.log('another password', result); //false
})
});
'<FRONTEND>' 카테고리의 다른 글
검색어 추천 기능 ajax로 구현해보기 (0) | 2020.07.06 |
---|---|
동일출처정책 CORS??? (0) | 2020.07.06 |
Ajax (0) | 2020.07.06 |
XMLHttpRequest 요청 (0) | 2020.07.06 |
React - Redux 규칙 (0) | 2020.06.26 |
Comments