Closed sampjr closed 6 years ago
You are mixing things up. Either use sync or async methods, you can't mix them.
You are using the async method of salt generation (genSalt) but the sync method of hashing (hashSync). So when your hashSync is executing the salt hasn't been generated and therefore salt is null.
Here is for sync method (as you can read in th readme... ;-)): var salt = bcrypt.genSaltSync(10); var hash = bcrypt.hashSync("B4c0/\/", salt);
Oh I see, thank you!
I have a .env.password variable, that I pass under
JSON.stringify(password.env.password)
to fit the hashSync arguments, but I end up with this error:throw Error("Illegal arguments: "+(typeof s)+', '+(typeof salt));
My code looks like this:
var hashed_pw = JSON.stringify(password.env.password);
console.log(hashed_pw); //this just add the "" to the beginning and end of my pw
var salt = bcrypt.genSalt(10);
var hash = bcrypt.hashSync(hashed_pw, salt);
I don't know what to do.