You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
14 KiB

11 months ago
!function(){"use strict";const{Array:t,Object:e,Math:n,Error:s,Uint8Array:a,Uint16Array:r,Uint32Array:i,Int32Array:c,DataView:o,TextEncoder:l,crypto:h,postMessage:p}=globalThis,d=[];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)1&e?e=e>>>1^3988292384:e>>>=1;d[t]=e}class u{constructor(t){this.crc=t||-1}append(t){let e=0|this.crc;for(let n=0,s=0|t.length;s>n;n++)e=e>>>8^d[255&(e^t[n])];this.crc=e}get(){return~this.crc}}const f={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],s=f.getPartial(n);return 32===s?t.concat(e):f._shiftRight(e,s,0|n,t.slice(0,t.length-1))},bitLength(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+f.getPartial(n)},clamp(t,e){if(32*t.length<e)return t;const s=(t=t.slice(0,n.ceil(e/32))).length;return e&=31,s>0&&e&&(t[s-1]=f.partial(e,t[s-1]&2147483648>>e-1,1)),t},partial:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,getPartial:t=>n.round(t/1099511627776)||32,_shiftRight(t,e,n,s){for(void 0===s&&(s=[]);e>=32;e-=32)s.push(n),n=0;if(0===e)return s.concat(t);for(let a=0;a<t.length;a++)s.push(n|t[a]>>>e),n=t[a]<<32-e;const a=t.length?t[t.length-1]:0,r=f.getPartial(a);return s.push(f.partial(e+r&31,e+r>32?n:s.pop(),1)),s}},g={bytes:{fromBits(t){const e=f.bitLength(t)/8,n=new a(e);let s;for(let a=0;e>a;a++)0==(3&a)&&(s=t[a/4]),n[a]=s>>>24,s<<=8;return n},toBits(t){const e=[];let n,s=0;for(n=0;n<t.length;n++)s=s<<8|t[n],3==(3&n)&&(e.push(s),s=0);return 3&n&&e.push(f.partial(8*(3&n),s)),e}}},w={sha1:function(t){t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()}};w.sha1.prototype={blockSize:512,reset:function(){const t=this;return t._h=this._init.slice(0),t._buffer=[],t._length=0,t},update:function(t){const e=this;"string"==typeof t&&(t=g.utf8String.toBits(t));const n=e._buffer=f.concat(e._buffer,t),a=e._length,r=e._length=a+f.bitLength(t);if(r>9007199254740991)throw new s("Cannot hash more than 2^53 - 1 bits");const c=new i(n);let o=0;for(let t=e.blockSize+a-(e.blockSize+a&e.blockSize-1);r>=t;t+=e.blockSize)e._block(c.subarray(16*o,16*(o+1))),o+=1;return n.splice(0,16*o),e},finalize:function(){const t=this;let e=t._buffer;const s=t._h;e=f.concat(e,[f.partial(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(n.floor(t._length/4294967296)),e.push(0|t._length);e.length;)t._block(e.splice(0,16));return t.reset(),s},_init:[1732584193,4023233417,2562383102,271733878,3285377520],_key:[1518500249,1859775393,2400959708,3395469782],_f:(t,e,n,s)=>t>19?t>39?t>59?t>79?void 0:e^n^s:e&n|e&s|n&s:e^n^s:e&n|~e&s,_S:(t,e)=>e<<t|e>>>32-t,_block:function(e){const s=this,a=s._h,r=t(80);for(let t=0;16>t;t++)r[t]=e[t];let i=a[0],c=a[1],o=a[2],l=a[3],h=a[4];for(let t=0;79>=t;t++){16>t||(r[t]=s._S(1,r[t-3]^r[t-8]^r[t-14]^r[t-16]));const e=s._S(5,i)+s._f(t,c,o,l)+h+r[t]+s._key[n.floor(t/20)]|0;h=l,l=o,o=s._S(30,c),c=i,i=e}a[0]=a[0]+i|0,a[1]=a[1]+c|0,a[2]=a[2]+o|0,a[3]=a[3]+l|0,a[4]=a[4]+h|0}};const y={getRandomValues(t){const e=new i(t.buffer),s=t=>{let e=987654321;const s=4294967295;return()=>(e=36969*(65535&e)+(e>>16)&s,(((e<<16)+(t=18e3*(65535&t)+(t>>16)&s)&s)/4294967296+.5)*(n.random()>.5?1:-1))};for(let a,r=0;r<t.length;r+=4){let t=s(4294967296*(a||n.random()));a=987654071*t(),e[r/4]=4294967296*t()|0}return t}},_={importKey:t=>new _.hmacSha1(g.bytes.toBits(t)),pbkdf2(t,e,n,a){if(n=n||1e4,0>a||0>n)throw new s("invalid params to pbkdf2");const r=1+(a>>5)<<2;let i,c,l,h,p;const d=new ArrayBuffer(r);let u=new o(d),w=0;const y=f;for(e=g.bytes.toBits(e),p=1;(r||1)>w;p++){for(i=c=t.encrypt(y.concat(e,[p])),l=1;n>l;l++)for(c=t.encrypt(c),h=0;h<c.length;h++)i[h]^=c[h];for(l=0;(r||1)>w&&l<i.length;l++)u.setInt32(w,i[l]),w+=4}return d.slice(0,a/8)},hmacSha1:class{constructor(t){const e=this,n=e._hash=w.sha1,s=[[],[]],a=n.prototype.blockSize/32;e._baseHash=[new n,new n],t.length>a&&(t=n.hash(t));for(let e=0;a>e;e++)s[0][e]=909522486^t[e],s[1][e]=1549556828^t[e];e._baseHash[0].update(s[0]),e._baseHash[1].update(s[1]),e._resultHash=new n(e._baseHash[0])}reset(){const t=this;t._resultHash=new t._hash(t._baseHash[0]),t._updated=!1}