Created
December 2, 2013 22:40
-
-
Save mwawrusch/7760403 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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