[Pkg-javascript-commits] [node-sha.js] 22/237: simplify bit manipulations

Bastien Roucariès rouca at moszumanska.debian.org
Fri May 5 09:02:52 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-sha.js.

commit 7e2fc4c06350b35c83d7336c4c36b0acef274373
Author: Dominic Tarr <dominic.tarr at gmail.com>
Date:   Fri Dec 27 08:46:58 2013 +0700

    simplify bit manipulations
---
 hash.js | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/hash.js b/hash.js
index 57d99e9..c45e4ec 100644
--- a/hash.js
+++ b/hash.js
@@ -54,21 +54,21 @@ Hash.prototype.digest = function (enc) {
   var x = this._block.buffer
   var X = this._dv
 
-  var bits = len % bl*8
+  var bits = len % (bl*8)
 
   //add end marker, so that appending 0's creats a different hash.
-  x[bits >> 4] = 0x80
-
-  console.log('--- final ---')
+  x[this._len % bl] = 0x80
+  console.log('--- final ---', bits, fl, this._len % bl, fl + 4, fl*8, bits >= fl*8)
   console.log(hexpp(x))
-
-  if(bits >= fl) {
+  
+  if(bits >= fl*8) {
     this._update(this._block.buffer)
-    zeroFill(this._x, 0)
+    u.zeroFill(this._x, 0)
   }
 
   //TODO: handle case where the bit length is > Math.pow(2, 29)
   X.setUint32(fl + 4, len, false) //big endian
+
   var hash = this._update(this._block.buffer)
   if(!enc) return hash
   return u.toHex(hash)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-sha.js.git



More information about the Pkg-javascript-commits mailing list