Skip to content

Instantly share code, notes, and snippets.

View yahayaohinoyi's full-sized avatar
🎯
Focusing

yahayaohinoyi

🎯
Focusing
View GitHub Profile
@dmh2000
dmh2000 / bcrypt-promise.js
Last active May 18, 2021 09:58
Using bcrypt with promises to hash a password and then verify it
const bcrypt = require("bcrypt");
// use this library in case your version of node doesn't support Promise
// const Promise = require("promise");
let password = "hello";
let stored_hash = "";
// first generate a random salt
function genSalt(password) {
return new Promise((resolve, reject) => {