Skip to content

Instantly share code, notes, and snippets.

@isaacs
Forked from scottgonzalez/gist:485299
Created July 22, 2010 02:40
Show Gist options
  • Save isaacs/485492 to your computer and use it in GitHub Desktop.
Save isaacs/485492 to your computer and use it in GitHub Desktop.
var crypto = require('crypto');
["sha1", "md5", "sha256", "sha512", "ripemd160"].forEach(function(algo) {
exports[algo] = function(data, salt) {
return crypto["createH"+(typeof salt != 'undefined' ? "mac":"ash"](algo,salt)
.update(data).digest("hex");
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment