filesbox/web/dist/js/rusha.min.js
2024-07-26 14:10:54 +08:00

2 lines
5.4 KiB
JavaScript

/*! rusha 2015-06-22 */(function(){var F={getDataType:function(p){if(typeof p=="string")return"string";if(p instanceof Array)return"array";if(typeof global!="undefined"&&global.Buffer&&global.Buffer.isBuffer(p))return"buffer";if(p instanceof ArrayBuffer)return"arraybuffer";if(p.buffer instanceof ArrayBuffer)return"view";if(p instanceof Blob)return"blob";throw new Error("Unsupported data type.")}};function k(p){"use strict";var o={fill:0},b=function(r){for(r+=9;r%64>0;r+=1);return r},B=function(r,t){for(var e=t>>2;e<r.length;e++)r[e]=0},a=function(r,t,e){r[t>>2]|=128<<24-(t%4<<3),r[((t>>2)+2&~15)+14]=e>>29,r[((t>>2)+2&~15)+15]=e<<3},j=function(r,t,e,v,f){var i=this,u,C=f%4,m=v%4,h=v-m;if(h>0)switch(C){case 0:r[f+3|0]=i.charCodeAt(e);case 1:r[f+2|0]=i.charCodeAt(e+1);case 2:r[f+1|0]=i.charCodeAt(e+2);case 3:r[f|0]=i.charCodeAt(e+3)}for(u=C;u<h;u=u+4|0)t[f+u>>2]=i.charCodeAt(e+u)<<24|i.charCodeAt(e+u+1)<<16|i.charCodeAt(e+u+2)<<8|i.charCodeAt(e+u+3);switch(m){case 3:r[f+h+1|0]=i.charCodeAt(e+h+2);case 2:r[f+h+2|0]=i.charCodeAt(e+h+1);case 1:r[f+h+3|0]=i.charCodeAt(e+h)}},y=function(r,t,e,v,f){var i=this,u,C=f%4,m=v%4,h=v-m;if(h>0)switch(C){case 0:r[f+3|0]=i[e];case 1:r[f+2|0]=i[e+1];case 2:r[f+1|0]=i[e+2];case 3:r[f|0]=i[e+3]}for(u=4-C;u<h;u=u+=4|0)t[f+u>>2]=i[e+u]<<24|i[e+u+1]<<16|i[e+u+2]<<8|i[e+u+3];switch(m){case 3:r[f+h+1|0]=i[e+h+2];case 2:r[f+h+2|0]=i[e+h+1];case 1:r[f+h+3|0]=i[e+h]}},A=function(r,t,e,v,f){var i=this,u,C=f%4,m=v%4,h=v-m,g=new Uint8Array(U.readAsArrayBuffer(i.slice(e,e+v)));if(h>0)switch(C){case 0:r[f+3|0]=g[0];case 1:r[f+2|0]=g[1];case 2:r[f+1|0]=g[2];case 3:r[f|0]=g[3]}for(u=4-C;u<h;u=u+=4|0)t[f+u>>2]=g[u]<<24|g[u+1]<<16|g[u+2]<<8|g[u+3];switch(m){case 3:r[f+h+1|0]=g[h+2];case 2:r[f+h+2|0]=g[h+1];case 1:r[f+h+3|0]=g[h]}},I=function(r){switch(F.getDataType(r)){case"string":return j.bind(r);case"array":return y.bind(r);case"buffer":return y.bind(r);case"arraybuffer":return y.bind(new Uint8Array(r));case"view":return y.bind(new Uint8Array(r.buffer,r.byteOffset,r.byteLength));case"blob":return A.bind(r)}},n=function(r,t){switch(F.getDataType(r)){case"string":return r.slice(t);case"array":return r.slice(t);case"buffer":return r.slice(t);case"arraybuffer":return r.slice(t);case"view":return r.buffer.slice(t)}},c=function(r){var t,e,v="0123456789abcdef",f=[],i=new Uint8Array(r);for(t=0;t<i.length;t++)e=i[t],f[t]=v.charAt(e>>4&15)+v.charAt(e>>0&15);return f.join("")},L=function(r){var t;if(r<=65536)return 65536;if(r<16777216)for(t=1;t<r;t=t<<1);else for(t=16777216;t<r;t+=16777216);return t},s=function(r){if(r%64>0)throw new Error("Chunk size must be a multiple of 128 bit");o.maxChunkLen=r,o.padMaxChunkLen=b(r),o.heap=new ArrayBuffer(L(o.padMaxChunkLen+320+20)),o.h32=new Int32Array(o.heap),o.h8=new Int8Array(o.heap),o.core=new k._core({Int32Array,DataView},{},o.heap),o.buffer=null};s(p||64*1024);var x=function(r,t){var e=new Int32Array(r,t+320,5);e[0]=1732584193,e[1]=-271733879,e[2]=-1732584194,e[3]=271733878,e[4]=-1009589776},l=function(r,t){var e=b(r),v=new Int32Array(o.heap,0,e>>2);return B(v,r),a(v,r,t),e},D=function(r,t,e){I(r)(o.h8,o.h32,t,e,0)},d=function(r,t,e,v,f){var i=e;f&&(i=l(e,v)),D(r,t,e),o.core.hash(i,o.padMaxChunkLen)},M=function(r,t){var e=new Int32Array(r,t+320,5),v=new Int32Array(5),f=new DataView(v.buffer);return f.setInt32(0,e[0],!1),f.setInt32(4,e[1],!1),f.setInt32(8,e[2],!1),f.setInt32(12,e[3],!1),f.setInt32(16,e[4],!1),v},w=this.rawDigest=function(r){var t=r.byteLength||r.length||r.size||0;x(o.heap,o.padMaxChunkLen);var e=0,v=o.maxChunkLen,f;for(e=0;t>e+v;e+=v)d(r,e,v,t,!1);return d(r,e,t-e,t,!0),M(o.heap,o.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(r){return c(w(r).buffer)}}if(k._core=function(o,b,B){var a=new o.Int32Array(B);function j(y,A){y=y|0,A=A|0;var I=0,n=0,c=0,L=0,s=0,x=0,l=0,D=0,d=0,M=0,w=0,r=0,t=0,e=0;for(c=a[A+320>>2]|0,s=a[A+324>>2]|0,l=a[A+328>>2]|0,d=a[A+332>>2]|0,w=a[A+336>>2]|0,I=0;(I|0)<(y|0);I=I+64|0){for(L=c,x=s,D=l,M=d,r=w,n=0;(n|0)<64;n=n+4|0)e=a[I+n>>2]|0,t=((c<<5|c>>>27)+(s&l|~s&d)|0)+((e+w|0)+1518500249|0)|0,w=d,d=l,l=s<<30|s>>>2,s=c,c=t,a[y+n>>2]=e;for(n=y+64|0;(n|0)<(y+80|0);n=n+4|0)e=(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])<<1|(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])>>>31,t=((c<<5|c>>>27)+(s&l|~s&d)|0)+((e+w|0)+1518500249|0)|0,w=d,d=l,l=s<<30|s>>>2,s=c,c=t,a[n>>2]=e;for(n=y+80|0;(n|0)<(y+160|0);n=n+4|0)e=(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])<<1|(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])>>>31,t=((c<<5|c>>>27)+(s^l^d)|0)+((e+w|0)+1859775393|0)|0,w=d,d=l,l=s<<30|s>>>2,s=c,c=t,a[n>>2]=e;for(n=y+160|0;(n|0)<(y+240|0);n=n+4|0)e=(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])<<1|(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])>>>31,t=((c<<5|c>>>27)+(s&l|s&d|l&d)|0)+((e+w|0)-1894007588|0)|0,w=d,d=l,l=s<<30|s>>>2,s=c,c=t,a[n>>2]=e;for(n=y+240|0;(n|0)<(y+320|0);n=n+4|0)e=(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])<<1|(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])>>>31,t=((c<<5|c>>>27)+(s^l^d)|0)+((e+w|0)-899497514|0)|0,w=d,d=l,l=s<<30|s>>>2,s=c,c=t,a[n>>2]=e;c=c+L|0,s=s+x|0,l=l+D|0,d=d+M|0,w=w+r|0}a[A+320>>2]=c,a[A+324>>2]=s,a[A+328>>2]=l,a[A+332>>2]=d,a[A+336>>2]=w}return{hash:j}},typeof module!="undefined"?module.exports=k:typeof window!="undefined"&&(window.Rusha=k),typeof FileReaderSync!="undefined"){var U=new FileReaderSync,R=new k(4*1024*1024);self.onmessage=function(o){var b,B=o.data.data;try{b=R.digest(B),self.postMessage({id:o.data.id,hash:b})}catch(a){self.postMessage({id:o.data.id,error:a.name})}}}})();