Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sha.js

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sha.js - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

bin.js

5

hash.js

@@ -34,2 +34,5 @@ var u = require('./util')

if(enc === 'utf-8')
enc = 'utf8'
if(enc === 'base64' || enc === 'utf8')

@@ -83,3 +86,3 @@ data = toBuffer(data, enc), enc = null

var hash = this._update(this._block.buffer)
var hash = this._update(this._block.buffer) || this._hash()
return u.toString(new Uint8Array(hash.buffer || hash), enc)

@@ -86,0 +89,0 @@ }

3

package.json
{
"name": "sha.js",
"description": "streaming sha1 hash in pure javascript",
"version": "1.1.0",
"version": "1.2.0",
"homepage": "https://github.com/dominictarr/sha.js",

@@ -16,2 +16,3 @@ "repository": {

},
"bin": "./bin.js",
"scripts": {

@@ -18,0 +19,0 @@ "test": "set -e; for t in test/*.js; do node $t; done;"

@@ -9,7 +9,2 @@ /*

*/
var hexpp = require('./hexpp').defaults({bigendian: false})
var u = require('./util')
var reverseByteOrder = u.reverseByteOrder
var zeroFill = u.zeroFill
module.exports = Sha1

@@ -22,3 +17,2 @@

var q = false
var A = 0

@@ -30,3 +24,3 @@ var B = 4

var BE = false
var BE = false
var LE = true

@@ -42,8 +36,9 @@

var H = this._dvH = new DataView(this._h.buffer)
this._h32 = new Uint32Array(this._h.buffer)
H.setUint32(A, 0x01234567, LE)
H.setUint32(B, 0x89abcdef, LE)
H.setUint32(C, 0xfedcba98, LE)
H.setUint32(D, 0x76543210, LE)
H.setUint32(E, 0xf0e1d2c3, LE)
this._a = 0x67452301
this._b = 0xefcdab89
this._c = 0x98badcfe
this._d = 0x10325476
this._e = 0xc3d2e1f0

@@ -61,20 +56,18 @@ this._len = 0

var H = this._dvH
var h32 = this._h32
var h = this._h
var a, b, c, d, e, _a, _b, _c, _d, _e
var a = _a = H.getUint32(A, BE)
var b = _b = H.getUint32(B, BE)
var c = _c = H.getUint32(C, BE)
var d = _d = H.getUint32(D, BE)
var e = _e = H.getUint32(E, BE)
a = _a = this._a
b = _b = this._b
c = _c = this._c
d = _d = this._d
e = _e = this._e
var w = this._w
var x = this._block
// console.log('--- Update ---')
// console.log(hexpp(x))
for(var j = 0; j < 80; j++) {
w[j] = j < 16
var W = w[j]
= j < 16
? X.getUint32(j*4, BE)

@@ -84,11 +77,5 @@ : rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1)

var t =
safe_add(
safe_add(
rol(a, 5),
sha1_ft(j, b, c, d)
),
safe_add(
safe_add(e, w[j]),
sha1_kt(j)
)
add(
add(rol(a, 5), sha1_ft(j, b, c, d)),
add(add(e, W), sha1_kt(j))
);

@@ -103,9 +90,17 @@

H.setUint32(A, safe_add(a, _a), BE)
H.setUint32(B, safe_add(b, _b), BE)
H.setUint32(C, safe_add(c, _c), BE)
H.setUint32(D, safe_add(d, _d), BE)
H.setUint32(E, safe_add(e, _e), BE)
this._a = add(a, _a)
this._b = add(b, _b)
this._c = add(c, _c)
this._d = add(d, _d)
this._e = add(e, _e)
}
return h
Sha1.prototype._hash = function () {
var H = this._dvH //new DataView(new ArrayBuffer(20))
H.setUint32(A, this._a, BE)
H.setUint32(B, this._b, BE)
H.setUint32(C, this._c, BE)
H.setUint32(D, this._d, BE)
H.setUint32(E, this._e, BE)
return H
}

@@ -136,7 +131,10 @@

* //dominictarr: this is 10 years old, so maybe this can be dropped?)
*
*/
function safe_add(x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
function add(x, y) {
return (x + y ) | 0
//lets see how this goes on testling.
// var lsw = (x & 0xFFFF) + (y & 0xFFFF);
// var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
// return (msw << 16) | (lsw & 0xFFFF);
}

@@ -143,0 +141,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc