Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not returning True (isHashed) #14

Open
benkraw opened this issue Aug 22, 2016 · 1 comment
Open

Not returning True (isHashed) #14

benkraw opened this issue Aug 22, 2016 · 1 comment

Comments

@benkraw
Copy link

benkraw commented Aug 22, 2016

var passwordHash = require('password-hash');
var hashedPassword = 'sha1$3I7HRwy7$cbfdac6008f9cab4083784cbd1874f76618d2a97';

console.log(passwordHash.isHashed('password123')); // false
console.log(passwordHash.isHashed(hashedPassword)); // true

passwordHash.isHashed() will always return False?

@MContagious
Copy link

MContagious commented Dec 5, 2016

yes, the code is splitting the password with $ and checking for four segments where as the hashed password is having only 3

so, try

var passwordHash = require('password-hash');
passwordHash.isHashed = function(password) {
  if (!password) return false;
  return password.split('$').length === 3;
}
var hashedPassword = 'sha1$3I7HRwy7$cbfdac6008f9cab4083784cbd1874f76618d2a97';

console.log(passwordHash.isHashed('password123')); // false
console.log(passwordHash.isHashed(hashedPassword)); // true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants