서버/Node.js
bcrypt ?
이건욱
2020. 4. 15. 18:03
bcrypt는 주로 비밀번호 저장을 암호화 할때 사용이 됩니다.
bcrypt는 강력한 해시 메커니즘중에 하나입니다.
node에서는 보통 bcrypt or bcrypt-node 이렇게 두개를 많이 사용합니다.
설치 패키지 :)
npm install --save bcrypt
기본 사용법 :)
- 암호화
import * as bcrypt from 'bcrypt';
const salt: string = await bcrypt.genSalt(10);
const hash: string = await bcrypt.hash(password, salt);
- 비교
const match: boolean = await bcrypt.compare(candidatePassword, this.password);