Bcrypt hash and compare not working

Tell us what’s happening:

bcrypt hash and compare is failing

Your code so far

bcrypt.hash(myPlaintextPassword, saltRounds, function(error, hash){
  //if (error) return console.log(error);
  bcrypt.compare(myPlaintextPassword, hash, function(err, result){
    //if (err) return console.log(err);

link to glitch project

I originally thought the error lines were throwing it off, so I commented them out, but the test is failing either way.

To note: the hash and the result are both printing to the console fine.

Your browser information:

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

Challenge: undefined

Link to the challenge:

bcrypt isn’t failing. Looks like the test is checking to see that you also used the same paramater names as provided in the example. Check those :wink:


@broregard thank you!!! ^^

After @broregard’s warning of what could be wrong, I went on to check other small details, and discovered my test was failing because I was omitting parens. Instead of (err, res) => { console.log(res) }, my callback was (err, res) => console.log(res). And that was enough to throw off the testing.

I love freeCodeCamp but this is just rubbish. In these backend lessons, I spend more time trying to figure out how to make valid answers pass the test than actually learning things. Frustration is not a good teaching tool…

I used their parameter names and still cannot pass this one.



I was facing the same issue. It turned out that I had to use the variables myPlaintextPassword and saltRounds instead of writing 'passw0rd!' and 13 by myself. They are already defined in the Glitch template, above the //START_ASYNC comment.