Lucas Knäuper
Lucas Knäuper

Reputation: 35

What is the meaning of bacon and not_bacon in the README of bcrypt.js?

It's Part of the Code-Examples in the README-File. "B4c0/\/" stands for 'password_example' I found out from another question here.

What means 'bacon' and 'not_bacon'?

    To check a password: 

```javascript
// Load hash from your password DB.
bcrypt.compareSync("B4c0/\/", hash); // true
bcrypt.compareSync("not_bacon", hash); // false
```

Auto-gen a salt and hash:

```javascript
var hash = bcrypt.hashSync('bacon', 8);
```

All I would like to know is, what these words stand for.

I am just guessing and have no clue.


"B4c0/\/"    === the actual password from the database

"bacon"      === password input  

"not_bacon"  === wrong password input

Is my guess correct?

Upvotes: -3

Views: 100

Answers (1)

CertainPerformance
CertainPerformance

Reputation: 370819

B4c0/\/ is just an example of a password, such as one submitted by the user. not_bacon is an example of another user-submitted password. If compareSync returns true, then the password matches the hash. If compareSync returns false, then the password doesn't match the hash.

The particular strings chosen don't really matter. They only illustrate that a hash will only be validated against the password used to create the hash, and not against any old string.

Here, the hash was originally created by passing in B4c0/\/ to bcrypt.

Later, when validating the user's input against the hash again, if they pass in B4c0/\/ again, it will pass.

If they pass in something else that is not the hashed password, like not_bacon, it will fail.

Upvotes: 1

Related Questions