var uint8Array=Uint8Array,uint32Array=Uint32Array,pow=Math.pow,DEFAULT_STATE=new uint32Array(8),ROUND_CONSTANTS=[],M=new uint32Array(64);function getFractionalBits(n){return(n-(0|n))*pow(2,32)|0}for(var n=2,nPrime=0;nPrime<64;){for(var isPrime=!0,factor=2;factor<=n/2;factor++)n%factor==0&&(isPrime=!1);isPrime&&(nPrime<8&&(DEFAULT_STATE[nPrime]=getFractionalBits(pow(n,.5))),ROUND_CONSTANTS[nPrime]=getFractionalBits(pow(n,1/3)),nPrime++),n++}var LittleEndian=!!new uint8Array(new uint32Array([1]).buffer)[0];function convertEndian(word){return LittleEndian?word>>>24|(word>>>16&255)<<8|(65280&word)<<8|word<<24:word}function rightRotate(word,bits){return word>>>bits|word<<32-bits}function sha256(data){var STATE=DEFAULT_STATE.slice(),legth=data.length,bitLength=8*legth,newBitLength=512-(64+bitLength)%512-1+bitLength+65,bytes=new uint8Array(newBitLength/8),words=new uint32Array(bytes.buffer);bytes.set(data,0),bytes[legth]=128,words[words.length-1]=convertEndian(bitLength);for(var block=0;block<newBitLength/32;block+=16){for(var workingState=STATE.slice(),round=0;round<64;round++){gamma0x=round<16?convertEndian(words[block+round]):(gamma0x=M[round-15],gamma1x=M[round-2],M[round-7]+M[round-16]+(rightRotate(gamma0x,7)^rightRotate(gamma0x,18)^gamma0x>>>3)+(rightRotate(gamma1x,17)^rightRotate(gamma1x,19)^gamma1x>>>10)),M[round]=gamma0x|=0;for(var gamma0x,gamma1x=(rightRotate(workingState[4],6)^rightRotate(workingState[4],11)^rightRotate(workingState[4],25))+(workingState[4]&workingState[5]^~workingState[4]&workingState[6])+workingState[7]+gamma0x+ROUND_CONSTANTS[round],t2=(rightRotate(workingState[0],2)^rightRotate(workingState[0],13)^rightRotate(workingState[0],22))+(workingState[0]&workingState[1]^workingState[2]&(workingState[0]^workingState[1])),i=7;0<i;i--)workingState[i]=workingState[i-1];workingState[0]=gamma1x+t2|0,workingState[4]=workingState[4]+gamma1x|0}for(round=0;round<8;round++)STATE[round]=STATE[round]+workingState[round]|0}return new uint8Array(new uint32Array(STATE.map(function(val){return convertEndian(val)})).buffer)}function hmac(key,data){(key=64<key.length?sha256(key):key).length<64&&((tmp=new Uint8Array(64)).set(key,0),key=tmp);for(var innerKey=new Uint8Array(64),outerKey=new Uint8Array(64),i=0;i<64;i++)innerKey[i]=54^key[i],outerKey[i]=92^key[i];var tmp=new Uint8Array(data.length+64),data=(tmp.set(innerKey,0),tmp.set(data,64),new Uint8Array(96));return data.set(outerKey,0),data.set(sha256(tmp),64),sha256(data)}var encoder=new TextEncoder("utf-8");function sign(inputKey,inputData){return hmac("string"==typeof inputKey?encoder.encode(inputKey):inputKey,"string"==typeof inputData?encoder.encode(inputData):inputData)}function hash(str){return hex(sha256(encoder.encode(str)))}function hex(bin){return bin.reduce((acc,val)=>acc+("00"+val.toString(16)).substr(-2),"")}