[Pkg-javascript-commits] [node-sha.js] 136/237: sha: jshint cleanup
Bastien Roucariès
rouca at moszumanska.debian.org
Fri May 5 09:03:47 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 a04fae03acdfb3bbfc7fbf15d928244364b5083a
Author: Daniel Cousens <github at dcousens.com>
Date: Thu Sep 4 18:37:10 2014 +1000
sha: jshint cleanup
---
sha1.js | 37 +++++++++----------------------------
sha256.js | 20 ++++----------------
2 files changed, 13 insertions(+), 44 deletions(-)
diff --git a/sha1.js b/sha1.js
index c7042b6..ada604d 100644
--- a/sha1.js
+++ b/sha1.js
@@ -6,11 +6,10 @@
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for details.
*/
-module.exports = function (Buffer, Hash) {
- var inherits = require('util').inherits
+var inherits = require('util').inherits
- inherits(Sha1, Hash)
+module.exports = function (Buffer, Hash) {
var A = 0|0
var B = 4|0
@@ -18,9 +17,6 @@ module.exports = function (Buffer, Hash) {
var D = 12|0
var E = 16|0
- var BE = false
- var LE = true
-
var W = new Int32Array(80)
var POOL = []
@@ -37,6 +33,8 @@ module.exports = function (Buffer, Hash) {
this.init()
}
+ inherits(Sha1, Hash)
+
Sha1.prototype.init = function () {
this._a = 0x67452301
this._b = 0xefcdab89
@@ -49,18 +47,6 @@ module.exports = function (Buffer, Hash) {
}
Sha1.prototype._POOL = POOL
-
- // assume that array is a Uint32Array with length=16,
- // and that if it is the last block, it already has the length and the 1 bit appended.
-
-
- var isDV = (typeof DataView !== 'undefined') && (new Buffer(1) instanceof DataView)
- function readInt32BE (X, i) {
- return isDV
- ? X.getInt32(i, false)
- : X.readInt32BE(i)
- }
-
Sha1.prototype._update = function (X) {
var a, b, c, d, e, _a, _b, _c, _d, _e
@@ -74,18 +60,13 @@ module.exports = function (Buffer, Hash) {
var w = this._w
for(var j = 0; j < 80; j++) {
- var W = w[j]
- = j < 16
- //? X.getInt32(j*4, false)
- //? readInt32BE(X, j*4) //*/ X.readInt32BE(j*4) //*/
- ? X.readInt32BE(j*4)
+ var W = w[j] = j < 16 ? X.readInt32BE(j*4)
: rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1)
- var t =
- add(
- add(rol(a, 5), sha1_ft(j, b, c, d)),
- add(add(e, W), sha1_kt(j))
- );
+ var t = add(
+ add(rol(a, 5), sha1_ft(j, b, c, d)),
+ add(add(e, W), sha1_kt(j))
+ )
e = d
d = c
diff --git a/sha256.js b/sha256.js
index 05fdbd5..b3c2b16 100644
--- a/sha256.js
+++ b/sha256.js
@@ -8,9 +8,6 @@
*/
var inherits = require('util').inherits
-var BE = false
-var LE = true
-var u = require('./util')
module.exports = function (Buffer, Hash) {
@@ -33,21 +30,18 @@ module.exports = function (Buffer, Hash) {
0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
]
- inherits(Sha256, Hash)
var W = new Array(64)
var POOL = []
- function Sha256() {
- if(POOL.length) {
- //return POOL.shift().init()
- }
- //this._data = new Buffer(32)
+ function Sha256() {
this.init()
this._w = W //new Array(64)
Hash.call(this, 16*4, 14*4)
- };
+ }
+
+ inherits(Sha256, Hash)
Sha256.prototype.init = function () {
@@ -65,12 +59,6 @@ module.exports = function (Buffer, Hash) {
return this
}
- var safe_add = function(x, y) {
- var lsw = (x & 0xFFFF) + (y & 0xFFFF);
- var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
- return (msw << 16) | (lsw & 0xFFFF);
- }
-
function S (X, n) {
return (X >>> n) | (X << (32 - n));
}
--
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