Created
December 20, 2011 03:40
-
-
Save shinout/1500125 to your computer and use it in GitHub Desktop.
md5
This file contains hidden or 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'); | |
var md5sum = crypto.createHash('md5'); | |
md5sum.update('shinout', 'utf8'); | |
console.log(md5sum.digest('hex')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The 2nd argument of md5sum.update ("utf8") is necessary for multi-byte strings.
Otherwise, we can get wrong result and collision would easily happen.
For example,
"場所": "place" in English
and
"水着" : "swimsuits" in English
return the same hash result if we omit the second argument.