Skip to content

Instantly share code, notes, and snippets.

@joao-neves95
Created January 30, 2018 15:02
Show Gist options
  • Save joao-neves95/7787791ff1f97d52881d12ee6b4a1235 to your computer and use it in GitHub Desktop.
Save joao-neves95/7787791ff1f97d52881d12ee6b4a1235 to your computer and use it in GitHub Desktop.
FCC_BCrypt-Hashing
'use strict';
const express = require('express');
const bcrypt = require('bcrypt');
const bodyParser = require('body-parser');
const fccTesting = require('./freeCodeCamp/fcctesting.js');
const app = express();
fccTesting(app); //For FCC testing purposes
const saltRounds = 13;
const myPlaintextPassword = 'sUperpassw0rd!';
const someOtherPlaintextPassword = 'pass123';
//START_ASYNC -do not remove notes, place code between correct pair of notes.
bcrypt.hash(myPlaintextPassword, saltRounds, (err, hash) => {
console.log(hash)
bcrypt.compare('sUperpassw0rd!', hash, (err, res) => {
console.log(res)
})
})
//END_ASYNC
//START_SYNC
const HASH = bcrypt.hashSync(myPlaintextPassword, saltRounds)
const COMPARE = bcrypt.compareSync(myPlaintextPassword, HASH)
console.log(HASH)
console.log(COMPARE)
//END_SYNC
app.listen(process.env.PORT || 3000, () => {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment