sha512-es
Version:
Cryptographic hash library producing a 512-bit (64-byte) hash value
2 lines • 8.49 kB
JavaScript
!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["sha512-es"]=t():n["sha512-es"]=t()}(this,function(){return function(n){function t(r){if(e[r])return e[r].exports;var I=e[r]={i:r,l:!1,exports:{}};return n[r].call(I.exports,I,I.exports,t),I.l=!0,I.exports}var e={};return t.m=n,t.c=e,t.i=function(n){return n},t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:r})},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},t.p="",t(t.s=2)}([function(n,t,e){"use strict";function r(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var I=function(){function n(n,t){for(var e=0;e<t.length;e++){var r=t[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}}(),l=e(1),o=function(){function n(){r(this,n)}return I(n,null,[{key:"hash",value:function(t){return n.stringToHex(n.arrayToString(n.run(n.stringToArray(t),8*t.length)))}},{key:"run",value:function(n,t){var e=[new l.Int64(1116352408,-685199838),new l.Int64(1899447441,602891725),new l.Int64(-1245643825,-330482897),new l.Int64(-373957723,-2121671748),new l.Int64(961987163,-213338824),new l.Int64(1508970993,-1241133031),new l.Int64(-1841331548,-1357295717),new l.Int64(-1424204075,-630357736),new l.Int64(-670586216,-1560083902),new l.Int64(310598401,1164996542),new l.Int64(607225278,1323610764),new l.Int64(1426881987,-704662302),new l.Int64(1925078388,-226784913),new l.Int64(-2132889090,991336113),new l.Int64(-1680079193,633803317),new l.Int64(-1046744716,-815192428),new l.Int64(-459576895,-1628353838),new l.Int64(-272742522,944711139),new l.Int64(264347078,-1953704523),new l.Int64(604807628,2007800933),new l.Int64(770255983,1495990901),new l.Int64(1249150122,1856431235),new l.Int64(1555081692,-1119749164),new l.Int64(1996064986,-2096016459),new l.Int64(-1740746414,-295247957),new l.Int64(-1473132947,766784016),new l.Int64(-1341970488,-1728372417),new l.Int64(-1084653625,-1091629340),new l.Int64(-958395405,1034457026),new l.Int64(-710438585,-1828018395),new l.Int64(113926993,-536640913),new l.Int64(338241895,168717936),new l.Int64(666307205,1188179964),new l.Int64(773529912,1546045734),new l.Int64(1294757372,1522805485),new l.Int64(1396182291,-1651133473),new l.Int64(1695183700,-1951439906),new l.Int64(1986661051,1014477480),new l.Int64(-2117940946,1206759142),new l.Int64(-1838011259,344077627),new l.Int64(-1564481375,1290863460),new l.Int64(-1474664885,-1136513023),new l.Int64(-1035236496,-789014639),new l.Int64(-949202525,106217008),new l.Int64(-778901479,-688958952),new l.Int64(-694614492,1432725776),new l.Int64(-200395387,1467031594),new l.Int64(275423344,851169720),new l.Int64(430227734,-1194143544),new l.Int64(506948616,1363258195),new l.Int64(659060556,-544281703),new l.Int64(883997877,-509917016),new l.Int64(958139571,-976659869),new l.Int64(1322822218,-482243893),new l.Int64(1537002063,2003034995),new l.Int64(1747873779,-692930397),new l.Int64(1955562222,1575990012),new l.Int64(2024104815,1125592928),new l.Int64(-2067236844,-1578062990),new l.Int64(-1933114872,442776044),new l.Int64(-1866530822,593698344),new l.Int64(-1538233109,-561857047),new l.Int64(-1090935817,-1295615723),new l.Int64(-965641998,-479046869),new l.Int64(-903397682,-366583396),new l.Int64(-779700025,566280711),new l.Int64(-354779690,-840897762),new l.Int64(-176337025,-294727304),new l.Int64(116418474,1914138554),new l.Int64(174292421,-1563912026),new l.Int64(289380356,-1090974290),new l.Int64(460393269,320620315),new l.Int64(685471733,587496836),new l.Int64(852142971,1086792851),new l.Int64(1017036298,365543100),new l.Int64(1126000580,-1676669620),new l.Int64(1288033470,-885112138),new l.Int64(1501505948,-60457430),new l.Int64(1607167915,987167468),new l.Int64(1816402316,1246189591)],r=new l.Int64(0,0),I=new l.Int64(0,0),o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],w=new l.Int64(1779033703,-205731576),h=new l.Int64(-1150833019,-2067093701),u=new l.Int64(1013904242,-23791573),a=new l.Int64(-1521486534,1595750129),c=new l.Int64(1359893119,-1377402159),i=new l.Int64(-1694144372,725511199),f=new l.Int64(528734635,-79577749),d=new l.Int64(1541459225,327033209),y=new l.Int64(0,0),p=new l.Int64(0,0),s=new l.Int64(0,0),v=new l.Int64(0,0),b=new l.Int64(0,0),g=new l.Int64(0,0),k=new l.Int64(0,0),x=new l.Int64(0,0),m=new l.Int64(0,0),j=new l.Int64(0,0),T=new l.Int64(0,0),A=new l.Int64(0,0),O=new l.Int64(0,0),C=new l.Int64(0,0),P=new l.Int64(0,0),_=0,M=0,S=0;for(M=0;M<80;M+=1)o[M]=new l.Int64(0,0);for(n[t>>5]|=128<<24-(31&t),n[31+(t+128>>10<<5)]=t,S=n.length,M=0;M<S;M+=32){for(l.Int64.copy(y,w),l.Int64.copy(p,h),l.Int64.copy(s,u),l.Int64.copy(v,a),l.Int64.copy(b,c),l.Int64.copy(g,i),l.Int64.copy(k,f),l.Int64.copy(x,d),_=0;_<16;_+=1)o[_].h=n[M+2*_],o[_].l=n[M+2*_+1];for(_=16;_<80;_+=1)l.Int64.rotr(O,o[_-2],19),l.Int64.rotl(C,o[_-2],29),l.Int64.shr(P,o[_-2],6),j.l=O.l^C.l^P.l,j.h=O.h^C.h^P.h,l.Int64.rotr(O,o[_-15],1),l.Int64.rotr(C,o[_-15],8),l.Int64.shr(P,o[_-15],7),m.l=O.l^C.l^P.l,m.h=O.h^C.h^P.h,l.Int64.add4(o[_],j,o[_-7],m,o[_-16]);for(_=0;_<80;_+=1)T.l=b.l&g.l^~b.l&k.l,T.h=b.h&g.h^~b.h&k.h,l.Int64.rotr(O,b,14),l.Int64.rotr(C,b,18),l.Int64.rotl(P,b,9),j.l=O.l^C.l^P.l,j.h=O.h^C.h^P.h,l.Int64.rotr(O,y,28),l.Int64.rotl(C,y,2),l.Int64.rotl(P,y,7),m.l=O.l^C.l^P.l,m.h=O.h^C.h^P.h,A.l=y.l&p.l^y.l&s.l^p.l&s.l,A.h=y.h&p.h^y.h&s.h^p.h&s.h,l.Int64.add5(r,x,j,T,e[_],o[_]),l.Int64.add(I,m,A),l.Int64.copy(x,k),l.Int64.copy(k,g),l.Int64.copy(g,b),l.Int64.add(b,v,r),l.Int64.copy(v,s),l.Int64.copy(s,p),l.Int64.copy(p,y),l.Int64.add(y,r,I);l.Int64.add(w,w,y),l.Int64.add(h,h,p),l.Int64.add(u,u,s),l.Int64.add(a,a,v),l.Int64.add(c,c,b),l.Int64.add(i,i,g),l.Int64.add(f,f,k),l.Int64.add(d,d,x)}return[w.h,w.l,h.h,h.l,u.h,u.l,a.h,a.l,c.h,c.l,i.h,i.l,f.h,f.l,d.h,d.l]}},{key:"arrayToString",value:function(n){var t=32*n.length,e=0,r="";for(e=0;e<t;e+=8)r+=String.fromCharCode(n[e>>5]>>>24-e%32&255);return r}},{key:"stringToArray",value:function(n){var t=8*n.length,e=Array(n.length>>2),r=e.length,I=0;for(I=0;I<r;I+=1)e[I]=0;for(I=0;I<t;I+=8)e[I>>5]|=(255&n.charCodeAt(I/8))<<24-I%32;return e}},{key:"stringToHex",value:function(n){for(var t="0123456789abcdef",e=n.length,r="",I=null,l=0;l<e;l+=1)I=n.charCodeAt(l),r+=t.charAt(I>>>4&15)+t.charAt(15&I);return r}}]),n}();t.default=o},function(n,t,e){"use strict";function r(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var I=function(){function n(n,t){for(var e=0;e<t.length;e++){var r=t[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}}();t.Int64=function(){function n(t,e){r(this,n),this.h=t,this.l=e}return I(n,null,[{key:"copy",value:function(n,t){n.h=t.h,n.l=t.l}},{key:"shr",value:function(n,t,e){n.l=t.l>>>e|t.h<<32-e,n.h=t.h>>>e}},{key:"rotr",value:function(n,t,e){n.l=t.l>>>e|t.h<<32-e,n.h=t.h>>>e|t.l<<32-e}},{key:"rotl",value:function(n,t,e){n.l=t.h>>>e|t.l<<32-e,n.h=t.l>>>e|t.h<<32-e}},{key:"add",value:function(n,t,e){var r=(65535&t.l)+(65535&e.l),I=(t.l>>>16)+(e.l>>>16)+(r>>>16),l=(65535&t.h)+(65535&e.h)+(I>>>16),o=(t.h>>>16)+(e.h>>>16)+(l>>>16);n.l=65535&r|I<<16,n.h=65535&l|o<<16}},{key:"add4",value:function(n,t,e,r,I){var l=(65535&t.l)+(65535&e.l)+(65535&r.l)+(65535&I.l),o=(t.l>>>16)+(e.l>>>16)+(r.l>>>16)+(I.l>>>16)+(l>>>16),w=(65535&t.h)+(65535&e.h)+(65535&r.h)+(65535&I.h)+(o>>>16),h=(t.h>>>16)+(e.h>>>16)+(r.h>>>16)+(I.h>>>16)+(w>>>16);n.l=65535&l|o<<16,n.h=65535&w|h<<16}},{key:"add5",value:function(n,t,e,r,I,l){var o=(65535&t.l)+(65535&e.l)+(65535&r.l)+(65535&I.l)+(65535&l.l),w=(t.l>>>16)+(e.l>>>16)+(r.l>>>16)+(I.l>>>16)+(l.l>>>16)+(o>>>16),h=(65535&t.h)+(65535&e.h)+(65535&r.h)+(65535&I.h)+(65535&l.h)+(w>>>16),u=(t.h>>>16)+(e.h>>>16)+(r.h>>>16)+(I.h>>>16)+(l.h>>>16)+(h>>>16);n.l=65535&o|w<<16,n.h=65535&h|u<<16}}]),n}()},function(n,t,e){n.exports=e(0)}])});
//# sourceMappingURL=sha512-es.min.js.map