Skip to content

Instantly share code, notes, and snippets.

@groovecoder
Created February 7, 2018 17:02
Show Gist options
  • Select an option

  • Save groovecoder/7fbb091b1c303a83107ea3674d17b44d to your computer and use it in GitHub Desktop.

Select an option

Save groovecoder/7fbb091b1c303a83107ea3674d17b44d to your computer and use it in GitHub Desktop.
const crypto = require('crypto');
const stdin = process.openStdin();
const shasum = crypto.createHash('sha1');
console.log('Enter an email address to get the SHA1 hash as it would appear in a HIBP hashset file.');
stdin.addListener('data', data => {
let trimmedString = data.toString().trim();
console.log('You entered: [' + trimmedString + '], sha1 hash of lowercase: ');
shasum.update(trimmedString.toLowerCase());
console.log(shasum.digest('hex'));
console.log('Enter an email address to get the SHA1 hash as it would appear in a HIBP hashset file.');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment