Skip to content

Instantly share code, notes, and snippets.

@bclinkinbeard
Forked from ThomasBurleson/gist:6445197
Last active December 22, 2015 08:29
Show Gist options
  • Select an option

  • Save bclinkinbeard/6445373 to your computer and use it in GitHub Desktop.

Select an option

Save bclinkinbeard/6445373 to your computer and use it in GitHub Desktop.
CommonJS format
var supplant = require('utils/supplant');
function rhex(n) {
var s = '', j = 0;
for (; j < 4; j++) {
s += hex_chr[(n >> (j * 8 + 4)) & 0x0F] + hex_chr[(n >> (j * 8)) & 0x0F];
}
return s;
}
function hex(x) {
for (var i = 0; i < x.length; i++) {
x[i] = rhex(x[i]);
}
return x.join('');
}
module.exports = function () {
// Build an instance of the md5 object with encrypt() features only...
return {
encrypt: function (s) {
var results = hex(s);
console.log(supplant('md5::encrypt({0}) = {1}', [ s, results]));
return results;
}
};
};