Comparing version 2.2.1 to 2.3.0
@@ -17,3 +17,3 @@ (function(){ | ||
message = Array.prototype.slice.call(message, 0); | ||
else if (!Array.isArray(message)) | ||
else if (!Array.isArray(message) && message.constructor !== Uint8Array) | ||
message = message.toString(); | ||
@@ -20,0 +20,0 @@ // else, assume byte array already |
{ | ||
"name": "md5", | ||
"description": "js function for hashing messages with MD5", | ||
"version": "2.2.1", | ||
"version": "2.3.0", | ||
"author": "Paul Vorbach <paul@vorba.ch> (http://paul.vorba.ch)", | ||
@@ -24,11 +24,13 @@ "contributors": [ | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "mocha", | ||
"webpack": "webpack -p" | ||
}, | ||
"dependencies": { | ||
"charenc": "~0.0.1", | ||
"crypt": "~0.0.1", | ||
"is-buffer": "~1.1.1" | ||
"charenc": "0.0.2", | ||
"crypt": "0.0.2", | ||
"is-buffer": "~1.1.6" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~2.3.4" | ||
"mocha": "~2.3.4", | ||
"webpack": "~2.4.1" | ||
}, | ||
@@ -35,0 +37,0 @@ "optionalDependencies": {}, |
# MD5 | ||
[![build status](https://secure.travis-ci.org/pvorb/node-md5.png)](http://travis-ci.org/pvorb/node-md5) | ||
[![build status](https://secure.travis-ci.org/pvorb/node-md5.png)](http://travis-ci.org/pvorb/node-md5) [![info badge](https://img.shields.io/npm/dt/md5.svg)](http://npm-stat.com/charts.html?package=md5) | ||
a JavaScript function for hashing messages with MD5. | ||
node-md5 is being sponsored by the following tool; please help to support us by taking a look and signing up to a free trial | ||
<a href="https://tracking.gitads.io/?repo=node-md5"><img src="https://images.gitads.io/node-md5" alt="GitAds"/></a> | ||
## Installation | ||
@@ -24,3 +27,3 @@ | ||
* `message` -- `String` or `Buffer` | ||
* `message` -- `String`, `Buffer`, `Array` or `Uint8Array` | ||
* returns `String` | ||
@@ -27,0 +30,0 @@ |
32
test.js
@@ -6,3 +6,3 @@ var md5 = require('./md5.js'); | ||
it('should throw an error for `undefined`', function() { | ||
it('should throw an error for an undefined value', function() { | ||
assert.throws(function() { | ||
@@ -13,2 +13,6 @@ md5(undefined); | ||
it('should allow the hashing of the string `undefined`', function() { | ||
assert.equal('5e543256c480ac577d30f76f9120eb74', md5('undefined')); | ||
}); | ||
it('should throw an error for `null`', function() { | ||
@@ -47,2 +51,28 @@ assert.throws(function() { | ||
}); | ||
it('should support Uint8Array', function() { | ||
// Polyfills | ||
if (!Array.from) { | ||
Array.from = function(src, fn) { | ||
var result = new Array(src.length); | ||
for (var i = 0; i < src.length; ++i) | ||
result[i] = fn(src[i]); | ||
return result; | ||
}; | ||
} | ||
if (!Uint8Array.from) { | ||
Uint8Array.from = function(src) { | ||
var result = new Uint8Array(src.length); | ||
for (var i = 0; i < src.length; ++i) | ||
result[i] = src[i]; | ||
return result; | ||
}; | ||
} | ||
var message = 'foobarbaz'; | ||
var u8arr = Uint8Array.from( | ||
Array.from(message, function(c) { return c.charCodeAt(0); })); | ||
var u8aHash = md5(u8arr); | ||
assert.equal(u8aHash, md5(message)); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21352
9
244
112
2
Updatedcharenc@0.0.2
Updatedcrypt@0.0.2
Updatedis-buffer@~1.1.6