[Pkg-javascript-commits] [node-sha.js] 102/237: tidy

Bastien Roucariès rouca at moszumanska.debian.org
Fri May 5 09:03:39 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 6f0392697e73f03c8900ccebd4a7d706c77bdea9
Author: Dominic Tarr <dominic.tarr at gmail.com>
Date:   Wed Jan 15 13:22:12 2014 +0700

    tidy
---
 hash.js   |  3 ---
 sha1.js   | 10 ++--------
 sha256.js | 19 +------------------
 util.js   | 13 -------------
 4 files changed, 3 insertions(+), 42 deletions(-)

diff --git a/hash.js b/hash.js
index 377cfb6..26315e7 100644
--- a/hash.js
+++ b/hash.js
@@ -22,7 +22,6 @@ module.exports = function (Buffer) {
 
   Hash.prototype.update = function (data, enc) {
     var bl = this._blockSize
-    //for now, assume ascii.
 
     //I'd rather do this with a streaming encoder, like the opposite of
     //http://nodejs.org/api/string_decoder.html
@@ -61,7 +60,6 @@ module.exports = function (Buffer) {
   }
 
   Hash.prototype.digest = function (enc) {
-    //how much message is leftover
     var bl = this._blockSize
     var fl = this._finalSize
     var len = this._len*8
@@ -92,5 +90,4 @@ module.exports = function (Buffer) {
   }
 
   return Hash
-
 }
diff --git a/sha1.js b/sha1.js
index f6cdd5a..10b4fdb 100644
--- a/sha1.js
+++ b/sha1.js
@@ -29,9 +29,7 @@ module.exports = function (Buffer, Hash) {
     this._w = new Int32Array(80)
     Hash.call(this, 16*4, 14*4)
   
-    this._h = new Buffer(20) //new Uint8Array(20)
-    var H = this._dvH = this._h // = new DataView(this._h.buffer)
-  //  this._h32 = new Uint32Array(this._h.buffer)
+    this._h = new Buffer(20)
 
     this._a = 0x67452301
     this._b = 0xefcdab89
@@ -57,10 +55,6 @@ module.exports = function (Buffer, Hash) {
   Sha1.prototype._update = function (array) {
 
     var X = this._block
-  //  var H = this._dvH
-
-  //  console.log(hexpp(X))
-
     var h = this._h
     var a, b, c, d, e, _a, _b, _c, _d, _e
 
@@ -101,7 +95,7 @@ module.exports = function (Buffer, Hash) {
   }
 
   Sha1.prototype._hash = function () {
-    var H = this._dvH //new DataView(new ArrayBuffer(20))
+    var H = this._h
 
     //console.log(this._a|0, this._b|0, this._c|0, this._d|0, this._e|0)
     H.writeInt32BE(this._a|0, A)
diff --git a/sha256.js b/sha256.js
index e679c7d..21d0622 100644
--- a/sha256.js
+++ b/sha256.js
@@ -40,11 +40,6 @@ module.exports = function (Buffer, Hash) {
   function Sha256() {
     this._data = new Buffer(32)
 
-  //new Uint32Array([
-  //    0x67e6096a, 0x85ae67bb, 0x72f36e3c, 0x3af54fa5,
-  //    0x7f520e51, 0x8c68059b, 0xabd9831f, 0x19cde05b
-  //  ])
-
     this._a = 0x6a09e667|0
     this._b = 0xbb67ae85|0
     this._c = 0x3c6ef372|0
@@ -54,9 +49,7 @@ module.exports = function (Buffer, Hash) {
     this._g = 0x1f83d9ab|0
     this._h = 0x5be0cd19|0
 
-    //var DV = this._dvH = new DataView(this._data.buffer)
-  
-    this._w = new Array(64) //new Uint32Array(64);
+    this._w = new Array(64)
 
     Hash.call(this, 16*4, 14*4)
   };
@@ -116,7 +109,6 @@ module.exports = function (Buffer, Hash) {
 
     for (var j = 0; j < 64; j++) {
       var w = W[j] = j < 16
-        //? M.getUint32(j * 4, BE)
         ? M.readInt32BE(j * 4)
         : Gamma1256(W[j - 2]) + W[j - 7] + Gamma0256(W[j - 15]) + W[j - 16]
 
@@ -141,15 +133,6 @@ module.exports = function (Buffer, Hash) {
 
     var H = this._data
 
-  //  H.setUint32( 0, this._a, BE);
-  //  H.setUint32( 4, this._b, BE);
-  //  H.setUint32( 8, this._c, BE);
-  //  H.setUint32(12, this._d, BE);
-  //  H.setUint32(16, this._e, BE);
-  //  H.setUint32(20, this._f, BE);
-  //  H.setUint32(24, this._g, BE);
-  //  H.setUint32(28, this._h, BE);
-  //
     H.writeInt32BE(this._a,  0)
     H.writeInt32BE(this._b,  4)
     H.writeInt32BE(this._c,  8)
diff --git a/util.js b/util.js
index 1162704..bd46ec8 100644
--- a/util.js
+++ b/util.js
@@ -4,19 +4,6 @@ exports.zeroFill = zeroFill
 
 exports.toString = toString
 var bopsToString = require('bops/typedarray/to')
-//change me: args should be:
-//buffer, string, enc, string_start, buffer_start
-//write will write as much of string into buffer as possible, and return the new length.
-//no. that is not enough... because of utf8.
-//HMM
-
-//I think this is just too coupled to be separate.
-//for utf8 you also need the state of the character...
-
-//the simplest way would be to just convert the utf8 to a buffer first.
-//not optimal, though...
-
-//OKAY, I should have benchmarks before I worry about that.
 
 function write (buffer, string, enc, start, from, to, LE) {
   var l = (to - from)

-- 
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