Skip to content

Instantly share code, notes, and snippets.

@nowelium
Created February 24, 2012 04:06
Show Gist options
  • Save nowelium/1897406 to your computer and use it in GitHub Desktop.
Save nowelium/1897406 to your computer and use it in GitHub Desktop.
var crypto = require('crypto');
var b = crypto.createHash('md5').update('hoge').digest('binary');
var c = crypto.createHash('md5').update('hoge').digest('hex');
var d = []; for(var i = 0; i < b.length; ++i){ if(b.charCodeAt(i) < 10){ d.push('0' + b.charCodeAt(i).toString(16)) } else { d.push(b.charCodeAt(i).toString(16)) } }
c
==> 'ea703e7aa1efda0064eaa507d9e8ab7e'
d.join('')
==> 'ea703e7aa1efda0064eaa507d9e8ab7e'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment