[Pkg-javascript-commits] [node-md5.js] 02/22: Bump hash-base (^2.0.0)
Bastien Roucariès
rouca at moszumanska.debian.org
Wed Sep 6 09:56:02 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-md5.js.
commit 50511ccfd22bb3280a27ac95474ccabb0dc8239e
Author: Kirill Fomichev <fanatid at ya.ru>
Date: Thu Apr 7 09:57:05 2016 +0300
Bump hash-base (^2.0.0)
---
.gitignore | 2 --
index.js | 78 +++++++++++++++++++-----------------------------------------
package.json | 4 +---
3 files changed, 26 insertions(+), 58 deletions(-)
diff --git a/.gitignore b/.gitignore
index 8afa17e..6112603 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,3 @@
-.nyc_output
-coverage
node_modules
npm-debug.log
diff --git a/index.js b/index.js
index cf2b5e7..4ae9739 100644
--- a/index.js
+++ b/index.js
@@ -3,69 +3,18 @@ var inherits = require('inherits')
var HashBase = require('hash-base')
function MD5 () {
- HashBase.call(this)
+ HashBase.call(this, 64)
// state
this._a = 0x67452301
this._b = 0xefcdab89
this._c = 0x98badcfe
this._d = 0x10325476
-
- // block data
- this._block = new Buffer(64) // 64 * 8 = 512 bit
- this._blockLength = 0
- this._lengthL = 0
- this._lengthH = 0
}
inherits(MD5, HashBase)
-MD5.prototype._update = function (data) {
- // consume data
- var offset = 0
- while (this._blockLength + data.length - offset >= 64) {
- for (var i = this._blockLength; i < 64;) this._block[i++] = data[offset++]
- this._handleBlock()
- this._blockLength = 0
- }
-
- while (offset < data.length) {
- this._block[this._blockLength++] = data[offset++]
- }
-
- // update length
- this._lengthL += data.length * 8
- if (this._lengthL > 0xffffffff) {
- this._lengthL -= 0x0100000000
- this._lengthH += 1
- if (this._lengthH > 0xffffffff) this._lengthH = 0
- }
-}
-
-MD5.prototype._digest = function () {
- // create padding and handle blocks
- this._block[this._blockLength++] = 0x80
- if (this._blockLength > 56) {
- this._block.fill(0, this._blockLength, 64)
- this._handleBlock()
- this._blockLength = 0
- }
-
- this._block.fill(0, this._blockLength, 56)
- this._block.writeUInt32LE(this._lengthL, 56)
- this._block.writeUInt32LE(this._lengthH, 60)
- this._handleBlock()
-
- // produce result
- var buffer = new Buffer(16)
- buffer.writeUInt32LE(this._a, 0)
- buffer.writeUInt32LE(this._b, 4)
- buffer.writeUInt32LE(this._c, 8)
- buffer.writeUInt32LE(this._d, 12)
- return buffer
-}
-
-MD5.prototype._handleBlock = function () {
+MD5.prototype._update = function () {
var m = new Array(16)
for (var i = 0; i < 16; ++i) m[i] = this._block.readUInt32LE(i * 4)
@@ -148,6 +97,29 @@ MD5.prototype._handleBlock = function () {
this._d = (this._d + d) >>> 0
}
+MD5.prototype._digest = function () {
+ // create padding and handle blocks
+ this._block[this._blockOffset++] = 0x80
+ if (this._blockOffset > 56) {
+ this._block.fill(0, this._blockOffset, 64)
+ this._update()
+ this._blockOffset = 0
+ }
+
+ this._block.fill(0, this._blockOffset, 56)
+ this._block.writeUInt32LE(this._length[0], 56)
+ this._block.writeUInt32LE(this._length[1], 60)
+ this._update()
+
+ // produce result
+ var buffer = new Buffer(16)
+ buffer.writeUInt32LE(this._a, 0)
+ buffer.writeUInt32LE(this._b, 4)
+ buffer.writeUInt32LE(this._c, 8)
+ buffer.writeUInt32LE(this._d, 12)
+ return buffer
+}
+
function rotl (x, n) {
return ((x << n) | (x >>> (32 - n))) >>> 0
}
diff --git a/package.json b/package.json
index c7f9e2b..a64beb2 100644
--- a/package.json
+++ b/package.json
@@ -21,18 +21,16 @@
"url": "https://github.com:crypto-browserify/md5.js.git"
},
"scripts": {
- "coverage": "nyc node test/*.js",
"lint": "standard",
"test": "npm run lint && npm run unit",
"unit": "node test/*.js"
},
"dependencies": {
- "hash-base": "^1.0.2",
+ "hash-base": "^2.0.0",
"inherits": "^2.0.1"
},
"devDependencies": {
"hash-test-vectors": "^1.3.2",
- "nyc": "^6.1.1",
"standard": "^6.0.8",
"tape": "^4.2.0"
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-md5.js.git
More information about the Pkg-javascript-commits
mailing list