Socket
Socket
Sign inDemoInstall

fast-sha256

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.1.1

13

package.json
{
"name": "fast-sha256",
"version": "1.1.0",
"version": "1.1.1",
"description": "SHA-256, HMAC and PBKDF2 implementation with typed arrays for modern browsers and Node.js",
"main": "sha256.js",
"files": [
"sha256.js",
"sha256.min.js",
"sha256.d.ts"
],
"typings": "sha256",

@@ -32,7 +37,7 @@ "directories": {

"faucet": "0.x.x",
"tape": "2.x.x",
"tslint": "^3.6.0",
"typescript": "^2.6.1",
"tape": "4.11.0",
"tslint": "^5.20.0",
"typescript": "^3.6.4",
"uglify-js": "^3.1.9"
}
}

@@ -17,10 +17,4 @@ fast-sha256-js

You can install fast-sha256-js via a package manager:
You can install fast-sha256-js via [NPM](https://www.npmjs.org/):
[Bower](http://bower.io):
$ bower install fast-sha256
[NPM](https://www.npmjs.org/):
$ npm install fast-sha256

@@ -59,3 +53,3 @@

Constructor for hash instance. Should be used with `new`.
Available methods: `update()`, `digest()`, `reset()`, etc.
Available methods: `update()`, `digest()`, `reset()`, etc.

@@ -65,3 +59,3 @@ ### new sha256.HMAC(key)

Constructor for HMAC instance. Should be used with `new`.
Available methods: `update()`, `digest()`, `reset()`, etc.
Available methods: `update()`, `digest()`, `reset()`, etc.

@@ -68,0 +62,0 @@ See comments in `src/sha256.ts` for details.

@@ -1,1 +0,1 @@

!function(t,e){var i={};!function(t){"use strict";function e(t,e,i,r,n){for(var h,f,a,o,u,d,p,c,b,g,l,y,v;n>=64;){for(h=e[0],f=e[1],a=e[2],o=e[3],u=e[4],d=e[5],p=e[6],c=e[7],g=0;g<16;g++)l=r+4*g,t[g]=(255&i[l])<<24|(255&i[l+1])<<16|(255&i[l+2])<<8|255&i[l+3];for(g=16;g<64;g++)b=t[g-2],y=(b>>>17|b<<15)^(b>>>19|b<<13)^b>>>10,b=t[g-15],v=(b>>>7|b<<25)^(b>>>18|b<<14)^b>>>3,t[g]=(y+t[g-7]|0)+(v+t[g-16]|0);for(g=0;g<64;g++)y=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&d^~u&p)|0)+(c+(s[g]+t[g]|0)|0)|0,v=((h>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10))+(h&f^h&a^f&a)|0,c=p,p=d,d=u,u=o+y|0,o=a,a=f,f=h,h=y+v|0;e[0]+=h,e[1]+=f,e[2]+=a,e[3]+=o,e[4]+=u,e[5]+=d,e[6]+=p,e[7]+=c,r+=64,n-=64}return r}function i(t){var e=(new r).update(t),i=e.digest();return e.clean(),i}t.__esModule=!0,t.digestLength=32,t.blockSize=64;var s=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);var r=function(){function i(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return i.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},i.prototype.clean=function(){for(t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(var t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},i.prototype.update=function(t,i){if(void 0===i&&(i=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var s=0;if(this.bytesHashed+=i,this.bufferLength>0){for(;this.bufferLength<64&&i>0;)this.buffer[this.bufferLength++]=t[s++],i--;64===this.bufferLength&&(e(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(i>=64&&(s=e(this.temp,this.state,t,s,i),i%=64);i>0;)this.buffer[this.bufferLength++]=t[s++],i--;return this},i.prototype.finish=function(t){if(!this.finished){var i=this.bytesHashed,s=this.bufferLength,r=i/536870912|0,n=i<<3,h=i%64<56?64:128;this.buffer[s]=128;for(f=s+1;f<h-8;f++)this.buffer[f]=0;this.buffer[h-8]=r>>>24&255,this.buffer[h-7]=r>>>16&255,this.buffer[h-6]=r>>>8&255,this.buffer[h-5]=r>>>0&255,this.buffer[h-4]=n>>>24&255,this.buffer[h-3]=n>>>16&255,this.buffer[h-2]=n>>>8&255,this.buffer[h-1]=n>>>0&255,e(this.temp,this.state,this.buffer,0,h),this.finished=!0}for(var f=0;f<8;f++)t[4*f+0]=this.state[f]>>>24&255,t[4*f+1]=this.state[f]>>>16&255,t[4*f+2]=this.state[f]>>>8&255,t[4*f+3]=this.state[f]>>>0&255;return this},i.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},i.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},i.prototype._restoreState=function(t,e){for(var i=0;i<this.state.length;i++)this.state[i]=t[i];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},i}();t.Hash=r;var n=function(){function t(t){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new r).update(t).finish(e).clean();else for(i=0;i<t.length;i++)e[i]=t[i];for(i=0;i<e.length;i++)e[i]^=54;this.inner.update(e);for(i=0;i<e.length;i++)e[i]^=106;this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var i=0;i<e.length;i++)e[i]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();t.HMAC=n;t.hash=i,t.default=i;t.hmac=function(t,e){var i=new n(t).update(e),s=i.digest();return i.clean(),s};t.pbkdf2=function(t,e,i,s){for(var r=new n(t),h=r.digestLength,f=new Uint8Array(4),a=new Uint8Array(h),o=new Uint8Array(h),u=new Uint8Array(s),d=0;d*h<s;d++){var p=d+1;f[0]=p>>>24&255,f[1]=p>>>16&255,f[2]=p>>>8&255,f[3]=p>>>0&255,r.reset(),r.update(e),r.update(f),r.finish(o);for(b=0;b<h;b++)a[b]=o[b];for(b=2;b<=i;b++){r.reset(),r.update(o).finish(o);for(var c=0;c<h;c++)a[c]^=o[c]}for(var b=0;b<h&&d*h+b<s;b++)u[d*h+b]=a[b]}for(d=0;d<h;d++)a[d]=o[d]=0;for(d=0;d<4;d++)f[d]=0;return r.clean(),u}}(i);var s=i.default;for(var r in i)s[r]=i[r];"object"==typeof module&&"object"==typeof module.exports?module.exports=s:"function"==typeof define&&define.amd?define(function(){return s}):t.sha256=s}(this);
!function(t){var e={};!function(e){"use strict";e.__esModule=true,e.digestLength=32,e.blockSize=64;var y=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function f(t,e,i,s,r){var n,h,f,a,o,u,d,p,v,c,b,g,l;while(r>=64){n=e[0];h=e[1];f=e[2];a=e[3];o=e[4];u=e[5];d=e[6];p=e[7];for(c=0;c<16;c++){b=s+c*4;t[c]=(i[b]&255)<<24|(i[b+1]&255)<<16|(i[b+2]&255)<<8|i[b+3]&255}for(c=16;c<64;c++){v=t[c-2];g=(v>>>17|v<<32-17)^(v>>>19|v<<32-19)^v>>>10;v=t[c-15];l=(v>>>7|v<<32-7)^(v>>>18|v<<32-18)^v>>>3;t[c]=(g+t[c-7]|0)+(l+t[c-16]|0)}for(c=0;c<64;c++){g=(((o>>>6|o<<32-6)^(o>>>11|o<<32-11)^(o>>>25|o<<32-25))+(o&u^~o&d)|0)+(p+(y[c]+t[c]|0)|0)|0;l=((n>>>2|n<<32-2)^(n>>>13|n<<32-13)^(n>>>22|n<<32-22))+(n&h^n&f^h&f)|0;p=d;d=u;u=o;o=a+g|0;a=f;f=h;h=n;n=g+l|0}e[0]+=n;e[1]+=h;e[2]+=f;e[3]+=a;e[4]+=o;e[5]+=u;e[6]+=d;e[7]+=p;s+=64;r-=64}return s}var s=function(){function t(){this.digestLength=e.digestLength;this.blockSize=e.blockSize;this.state=new Int32Array(8);this.temp=new Int32Array(64);this.buffer=new Uint8Array(128);this.bufferLength=0;this.bytesHashed=0;this.finished=false;this.reset()}t.prototype.reset=function(){this.state[0]=1779033703;this.state[1]=3144134277;this.state[2]=1013904242;this.state[3]=2773480762;this.state[4]=1359893119;this.state[5]=2600822924;this.state[6]=528734635;this.state[7]=1541459225;this.bufferLength=0;this.bytesHashed=0;this.finished=false;return this};t.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++){this.buffer[t]=0}for(var t=0;t<this.temp.length;t++){this.temp[t]=0}this.reset()};t.prototype.update=function(t,e){if(e===void 0){e=t.length}if(this.finished){throw new Error("SHA256: can't update because hash was finished.")}var i=0;this.bytesHashed+=e;if(this.bufferLength>0){while(this.bufferLength<64&&e>0){this.buffer[this.bufferLength++]=t[i++];e--}if(this.bufferLength===64){f(this.temp,this.state,this.buffer,0,64);this.bufferLength=0}}if(e>=64){i=f(this.temp,this.state,t,i,e);e%=64}while(e>0){this.buffer[this.bufferLength++]=t[i++];e--}return this};t.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed;var i=this.bufferLength;var s=e/536870912|0;var r=e<<3;var n=e%64<56?64:128;this.buffer[i]=128;for(var h=i+1;h<n-8;h++){this.buffer[h]=0}this.buffer[n-8]=s>>>24&255;this.buffer[n-7]=s>>>16&255;this.buffer[n-6]=s>>>8&255;this.buffer[n-5]=s>>>0&255;this.buffer[n-4]=r>>>24&255;this.buffer[n-3]=r>>>16&255;this.buffer[n-2]=r>>>8&255;this.buffer[n-1]=r>>>0&255;f(this.temp,this.state,this.buffer,0,n);this.finished=true}for(var h=0;h<8;h++){t[h*4+0]=this.state[h]>>>24&255;t[h*4+1]=this.state[h]>>>16&255;t[h*4+2]=this.state[h]>>>8&255;t[h*4+3]=this.state[h]>>>0&255}return this};t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);this.finish(t);return t};t.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++){t[e]=this.state[e]}};t.prototype._restoreState=function(t,e){for(var i=0;i<this.state.length;i++){this.state[i]=t[i]}this.bytesHashed=e;this.finished=false;this.bufferLength=0};return t}();e.Hash=s;var c=function(){function t(t){this.inner=new s;this.outer=new s;this.blockSize=this.inner.blockSize;this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize){(new s).update(t).finish(e).clean()}else{for(var i=0;i<t.length;i++){e[i]=t[i]}}for(var i=0;i<e.length;i++){e[i]^=54}this.inner.update(e);for(var i=0;i<e.length;i++){e[i]^=54^92}this.outer.update(e);this.istate=new Uint32Array(8);this.ostate=new Uint32Array(8);this.inner._saveState(this.istate);this.outer._saveState(this.ostate);for(var i=0;i<e.length;i++){e[i]=0}}t.prototype.reset=function(){this.inner._restoreState(this.istate,this.inner.blockSize);this.outer._restoreState(this.ostate,this.outer.blockSize);return this};t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++){this.ostate[t]=this.istate[t]=0}this.inner.clean();this.outer.clean()};t.prototype.update=function(t){this.inner.update(t);return this};t.prototype.finish=function(t){if(this.outer.finished){this.outer.finish(t)}else{this.inner.finish(t);this.outer.update(t,this.digestLength).finish(t)}return this};t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);this.finish(t);return t};return t}();function t(t){var e=(new s).update(t);var i=e.digest();e.clean();return i}function i(t,e){var i=new c(t).update(e);var s=i.digest();i.clean();return s}function r(t,e,i,s){var r=new c(t);var n=r.digestLength;var h=new Uint8Array(4);var f=new Uint8Array(n);var a=new Uint8Array(n);var o=new Uint8Array(s);for(var u=0;u*n<s;u++){var d=u+1;h[0]=d>>>24&255;h[1]=d>>>16&255;h[2]=d>>>8&255;h[3]=d>>>0&255;r.reset();r.update(e);r.update(h);r.finish(a);for(var p=0;p<n;p++){f[p]=a[p]}for(var p=2;p<=i;p++){r.reset();r.update(a).finish(a);for(var v=0;v<n;v++){f[v]^=a[v]}}for(var p=0;p<n&&u*n+p<s;p++){o[u*n+p]=f[p]}}for(var u=0;u<n;u++){f[u]=a[u]=0}for(var u=0;u<4;u++){h[u]=0}r.clean();return o}e.HMAC=c,e.hash=t,e["default"]=t,e.hmac=i,e.pbkdf2=r}(e);var i=e.default;for(var s in e)i[s]=e[s];"object"==typeof module&&"object"==typeof module.exports?module.exports=i:"function"==typeof define&&define.amd?define(function(){return i}):t.sha256=i}(this);
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc