Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var crypto = require('crypto');
// change to 'md5' if you want an MD5 hash
var hash = crypto.createHash('sha1');
// change to 'binary' if you want a binary hash.
hash.setEncoding('hex');
// the text that you want to hash
hash.write('hello world');
// very important! You cannot read from the stream until you haven't called end()
hash.end();
// and now you get the resulting hash
var sha1sum = hash.read();
cosnole.log(sha1sum);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.