Bcrypt Hash and Compare Passwords Synchronously

I’m not passing Bcrypt sync test:
Hi team!
I’m not passing Bcrypt sync test

// running tests
Sync hash should be generated and correctly compared.
// tests completed

Here is my code

‘use strict’;
const express = require(‘express’);
const bodyParser = require(‘body-parser’);
const fccTesting = require(‘./freeCodeCamp/fcctesting.js’);
const app = express();
const saltRounds = 12;
const myPlaintextPassword = ‘sUperpassw0rd!’;
const someOtherPlaintextPassword = ‘pass123’;

const bcrypt = require(‘bcrypt’);

const salt = bcrypt.genSaltSync(saltRounds);
console.log("salt value: ", salt);

//Hash and Compare Passwords Asynchronously
// bcrypt.hash(myPlaintextPassword, saltRounds, (err, hash) => {
// console.log(hash);
// bcrypt.compare(myPlaintextPassword, hash, (err, res) => {
// console.log(res);
// });
// });

//START_ASYNC -do not remove notes, place code between correct pair of notes.



let hash = bcrypt.hashSync(“myPlaintextPassword”, salt);

let result = bcrypt.compareSync(“myPlaintextPassword”, hash);

Thank you very much. I appreciate you.

Your project link(s)

solution: boilerplate-bcrypt - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Hash and Compare Passwords Synchronously

Link to the challenge:

If I’m understanding correctly

let hash = bcrypt.hashSync(“myPlaintextPassword”, salt);

then you’re passing a string litteral instead of the constant

const myPlaintextPassword = ‘sUperpassw0rd!’;

Could that be it?

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.