SMMP/public_html/js/lib/sha256-min.js

7 lines
2.8 KiB
JavaScript
Raw Permalink Normal View History

var sha256={hash:function(a){a=a.utf8Encode();var d=[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],b=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];a+=String.fromCharCode(128);for(var g=Math.ceil((a.length/4+2)/16),h=Array(g),f=0;f<g;f++){h[f]=Array(16);for(var e=0;16>e;e++)h[f][e]=a.charCodeAt(64*f+4*e)<<24|a.charCodeAt(64*
f+4*e+1)<<16|a.charCodeAt(64*f+4*e+2)<<8|a.charCodeAt(64*f+4*e+3)}h[g-1][14]=8*(a.length-1)/Math.pow(2,32);h[g-1][14]=Math.floor(h[g-1][14]);h[g-1][15]=8*(a.length-1)&4294967295;a=Array(64);for(var l,m,q,k,n,p,r,f=0;f<g;f++){for(var c=0;16>c;c++)a[c]=h[f][c];for(c=16;64>c;c++)a[c]=sha256.\u03c31(a[c-2])+a[c-7]+sha256.\u03c30(a[c-15])+a[c-16]&4294967295;e=b[0];l=b[1];m=b[2];q=b[3];k=b[4];n=b[5];p=b[6];r=b[7];for(c=0;64>c;c++){var t=r+sha256.\u03a31(k)+sha256.Ch(k,n,p)+d[c]+a[c],u=sha256.\u03a30(e)+
sha256.Maj(e,l,m);r=p;p=n;n=k;k=q+t&4294967295;q=m;m=l;l=e;e=t+u&4294967295}b[0]=b[0]+e&4294967295;b[1]=b[1]+l&4294967295;b[2]=b[2]+m&4294967295;b[3]=b[3]+q&4294967295;b[4]=b[4]+k&4294967295;b[5]=b[5]+n&4294967295;b[6]=b[6]+p&4294967295;b[7]=b[7]+r&4294967295}return sha256.toHexStr(b[0])+sha256.toHexStr(b[1])+sha256.toHexStr(b[2])+sha256.toHexStr(b[3])+sha256.toHexStr(b[4])+sha256.toHexStr(b[5])+sha256.toHexStr(b[6])+sha256.toHexStr(b[7])},ROTR:function(a,d){return d>>>a|d<<32-a},"\u03a30":function(a){return sha256.ROTR(2,
a)^sha256.ROTR(13,a)^sha256.ROTR(22,a)},"\u03a31":function(a){return sha256.ROTR(6,a)^sha256.ROTR(11,a)^sha256.ROTR(25,a)},"\u03c30":function(a){return sha256.ROTR(7,a)^sha256.ROTR(18,a)^a>>>3},"\u03c31":function(a){return sha256.ROTR(17,a)^sha256.ROTR(19,a)^a>>>10},Ch:function(a,d,b){return a&d^~a&b},Maj:function(a,d,b){return a&d^a&b^d&b},toHexStr:function(a){for(var d="",b,g=7;0<=g;g--)b=a>>>4*g&15,d+=b.toString(16);return d}};
"undefined"==typeof String.prototype.utf8Encode&&(String.prototype.utf8Encode=function(){return unescape(encodeURIComponent(this))});"undefined"==typeof String.prototype.utf8Decode&&(String.prototype.utf8Decode=function(){try{return decodeURIComponent(escape(this))}catch(a){return this}});"undefined"!=typeof module&&module.exports&&(module.exports=sha256);"function"==typeof define&&define.amd&&define([],function(){return sha256});