Skip to content

Instantly share code, notes, and snippets.

@mwawrusch
Created December 2, 2013 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwawrusch/7760403 to your computer and use it in GitHub Desktop.
Save mwawrusch/7760403 to your computer and use it in GitHub Desktop.
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