Skip to content

Commit

Permalink
Merge pull request #10 from keyle/master
Browse files Browse the repository at this point in the history
Fix for crash when passing undefined
  • Loading branch information
pvorb committed Apr 2, 2014
2 parents a9dd92c + 7427044 commit 96f7c25
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions md5.js
Expand Up @@ -5,6 +5,10 @@

// The core
md5 = function (message, options) {

if(typeof message === "undefined") {
return;
}
// Convert to byte array
if (message.constructor == String)
if (options && options.encoding === 'binary')
Expand Down Expand Up @@ -148,6 +152,11 @@
md5._digestsize = 16;

module.exports = function (message, options) {

if(typeof message === "undefined") {
return;
}

var digestbytes = crypt.wordsToBytes(md5(message, options));
return options && options.asBytes ? digestbytes :
options && options.asString ? bin.bytesToString(digestbytes) :
Expand Down

0 comments on commit 96f7c25

Please sign in to comment.