md5-typescript
Version:
1 lines • 7.97 kB
JavaScript
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(t.bundle=t.bundle||{})}(this,function(t){"use strict";var i=function(){function t(){}return t.AddUnsigned=function(t,i){var s,h,d,n,a;return d=2147483648&t,n=2147483648&i,s=1073741824&t,h=1073741824&i,a=(1073741823&t)+(1073741823&i),s&h?2147483648^a^d^n:s|h?1073741824&a?3221225472^a^d^n:1073741824^a^d^n:a^d^n},t.FF=function(t,i,s,h,d,n,a){return t=this.AddUnsigned(t,this.AddUnsigned(this.AddUnsigned(this.F(i,s,h),d),a)),this.AddUnsigned(this.RotateLeft(t,n),i)},t.GG=function(t,i,s,h,d,n,a){return t=this.AddUnsigned(t,this.AddUnsigned(this.AddUnsigned(this.G(i,s,h),d),a)),this.AddUnsigned(this.RotateLeft(t,n),i)},t.HH=function(t,i,s,h,d,n,a){return t=this.AddUnsigned(t,this.AddUnsigned(this.AddUnsigned(this.H(i,s,h),d),a)),this.AddUnsigned(this.RotateLeft(t,n),i)},t.II=function(t,i,s,h,d,n,a){return t=this.AddUnsigned(t,this.AddUnsigned(this.AddUnsigned(this.I(i,s,h),d),a)),this.AddUnsigned(this.RotateLeft(t,n),i)},t.ConvertToWordArray=function(t){for(var i,s=t.length,h=s+8,d=(h-h%64)/64,n=16*(d+1),a=Array(n-1),c=0,e=0;e<s;)i=(e-e%4)/4,c=e%4*8,a[i]=a[i]|t.charCodeAt(e)<<c,e++;return i=(e-e%4)/4,c=e%4*8,a[i]=a[i]|128<<c,a[n-2]=s<<3,a[n-1]=s>>>29,a},t.WordToHex=function(t){var i,s,h="",d="";for(s=0;s<=3;s++)i=t>>>8*s&255,d="0"+i.toString(16),h+=d.substr(d.length-2,2);return h},t.Utf8Encode=function(t){var i,s="";t=t.replace(/\r\n/g,"\n");for(var h=0;h<t.length;h++)i=t.charCodeAt(h),i<128?s+=String.fromCharCode(i):i>127&&i<2048?(s+=String.fromCharCode(i>>6|192),s+=String.fromCharCode(63&i|128)):(s+=String.fromCharCode(i>>12|224),s+=String.fromCharCode(i>>6&63|128),s+=String.fromCharCode(63&i|128));return s},t.init=function(t){var i;for("string"!=typeof t&&(t=JSON.stringify(t)),this._string=this.Utf8Encode(t),this.x=this.ConvertToWordArray(this._string),this.a=1732584193,this.b=4023233417,this.c=2562383102,this.d=271733878,this.k=0;this.k<this.x.length;this.k+=16)this.AA=this.a,this.BB=this.b,this.CC=this.c,this.DD=this.d,this.a=this.FF(this.a,this.b,this.c,this.d,this.x[this.k],this.S11,3614090360),this.d=this.FF(this.d,this.a,this.b,this.c,this.x[this.k+1],this.S12,3905402710),this.c=this.FF(this.c,this.d,this.a,this.b,this.x[this.k+2],this.S13,606105819),this.b=this.FF(this.b,this.c,this.d,this.a,this.x[this.k+3],this.S14,3250441966),this.a=this.FF(this.a,this.b,this.c,this.d,this.x[this.k+4],this.S11,4118548399),this.d=this.FF(this.d,this.a,this.b,this.c,this.x[this.k+5],this.S12,1200080426),this.c=this.FF(this.c,this.d,this.a,this.b,this.x[this.k+6],this.S13,2821735955),this.b=this.FF(this.b,this.c,this.d,this.a,this.x[this.k+7],this.S14,4249261313),this.a=this.FF(this.a,this.b,this.c,this.d,this.x[this.k+8],this.S11,1770035416),this.d=this.FF(this.d,this.a,this.b,this.c,this.x[this.k+9],this.S12,2336552879),this.c=this.FF(this.c,this.d,this.a,this.b,this.x[this.k+10],this.S13,4294925233),this.b=this.FF(this.b,this.c,this.d,this.a,this.x[this.k+11],this.S14,2304563134),this.a=this.FF(this.a,this.b,this.c,this.d,this.x[this.k+12],this.S11,1804603682),this.d=this.FF(this.d,this.a,this.b,this.c,this.x[this.k+13],this.S12,4254626195),this.c=this.FF(this.c,this.d,this.a,this.b,this.x[this.k+14],this.S13,2792965006),this.b=this.FF(this.b,this.c,this.d,this.a,this.x[this.k+15],this.S14,1236535329),this.a=this.GG(this.a,this.b,this.c,this.d,this.x[this.k+1],this.S21,4129170786),this.d=this.GG(this.d,this.a,this.b,this.c,this.x[this.k+6],this.S22,3225465664),this.c=this.GG(this.c,this.d,this.a,this.b,this.x[this.k+11],this.S23,643717713),this.b=this.GG(this.b,this.c,this.d,this.a,this.x[this.k],this.S24,3921069994),this.a=this.GG(this.a,this.b,this.c,this.d,this.x[this.k+5],this.S21,3593408605),this.d=this.GG(this.d,this.a,this.b,this.c,this.x[this.k+10],this.S22,38016083),this.c=this.GG(this.c,this.d,this.a,this.b,this.x[this.k+15],this.S23,3634488961),this.b=this.GG(this.b,this.c,this.d,this.a,this.x[this.k+4],this.S24,3889429448),this.a=this.GG(this.a,this.b,this.c,this.d,this.x[this.k+9],this.S21,568446438),this.d=this.GG(this.d,this.a,this.b,this.c,this.x[this.k+14],this.S22,3275163606),this.c=this.GG(this.c,this.d,this.a,this.b,this.x[this.k+3],this.S23,4107603335),this.b=this.GG(this.b,this.c,this.d,this.a,this.x[this.k+8],this.S24,1163531501),this.a=this.GG(this.a,this.b,this.c,this.d,this.x[this.k+13],this.S21,2850285829),this.d=this.GG(this.d,this.a,this.b,this.c,this.x[this.k+2],this.S22,4243563512),this.c=this.GG(this.c,this.d,this.a,this.b,this.x[this.k+7],this.S23,1735328473),this.b=this.GG(this.b,this.c,this.d,this.a,this.x[this.k+12],this.S24,2368359562),this.a=this.HH(this.a,this.b,this.c,this.d,this.x[this.k+5],this.S31,4294588738),this.d=this.HH(this.d,this.a,this.b,this.c,this.x[this.k+8],this.S32,2272392833),this.c=this.HH(this.c,this.d,this.a,this.b,this.x[this.k+11],this.S33,1839030562),this.b=this.HH(this.b,this.c,this.d,this.a,this.x[this.k+14],this.S34,4259657740),this.a=this.HH(this.a,this.b,this.c,this.d,this.x[this.k+1],this.S31,2763975236),this.d=this.HH(this.d,this.a,this.b,this.c,this.x[this.k+4],this.S32,1272893353),this.c=this.HH(this.c,this.d,this.a,this.b,this.x[this.k+7],this.S33,4139469664),this.b=this.HH(this.b,this.c,this.d,this.a,this.x[this.k+10],this.S34,3200236656),this.a=this.HH(this.a,this.b,this.c,this.d,this.x[this.k+13],this.S31,681279174),this.d=this.HH(this.d,this.a,this.b,this.c,this.x[this.k],this.S32,3936430074),this.c=this.HH(this.c,this.d,this.a,this.b,this.x[this.k+3],this.S33,3572445317),this.b=this.HH(this.b,this.c,this.d,this.a,this.x[this.k+6],this.S34,76029189),this.a=this.HH(this.a,this.b,this.c,this.d,this.x[this.k+9],this.S31,3654602809),this.d=this.HH(this.d,this.a,this.b,this.c,this.x[this.k+12],this.S32,3873151461),this.c=this.HH(this.c,this.d,this.a,this.b,this.x[this.k+15],this.S33,530742520),this.b=this.HH(this.b,this.c,this.d,this.a,this.x[this.k+2],this.S34,3299628645),this.a=this.II(this.a,this.b,this.c,this.d,this.x[this.k],this.S41,4096336452),this.d=this.II(this.d,this.a,this.b,this.c,this.x[this.k+7],this.S42,1126891415),this.c=this.II(this.c,this.d,this.a,this.b,this.x[this.k+14],this.S43,2878612391),this.b=this.II(this.b,this.c,this.d,this.a,this.x[this.k+5],this.S44,4237533241),this.a=this.II(this.a,this.b,this.c,this.d,this.x[this.k+12],this.S41,1700485571),this.d=this.II(this.d,this.a,this.b,this.c,this.x[this.k+3],this.S42,2399980690),this.c=this.II(this.c,this.d,this.a,this.b,this.x[this.k+10],this.S43,4293915773),this.b=this.II(this.b,this.c,this.d,this.a,this.x[this.k+1],this.S44,2240044497),this.a=this.II(this.a,this.b,this.c,this.d,this.x[this.k+8],this.S41,1873313359),this.d=this.II(this.d,this.a,this.b,this.c,this.x[this.k+15],this.S42,4264355552),this.c=this.II(this.c,this.d,this.a,this.b,this.x[this.k+6],this.S43,2734768916),this.b=this.II(this.b,this.c,this.d,this.a,this.x[this.k+13],this.S44,1309151649),this.a=this.II(this.a,this.b,this.c,this.d,this.x[this.k+4],this.S41,4149444226),this.d=this.II(this.d,this.a,this.b,this.c,this.x[this.k+11],this.S42,3174756917),this.c=this.II(this.c,this.d,this.a,this.b,this.x[this.k+2],this.S43,718787259),this.b=this.II(this.b,this.c,this.d,this.a,this.x[this.k+9],this.S44,3951481745),this.a=this.AddUnsigned(this.a,this.AA),this.b=this.AddUnsigned(this.b,this.BB),this.c=this.AddUnsigned(this.c,this.CC),this.d=this.AddUnsigned(this.d,this.DD);return i=this.WordToHex(this.a)+this.WordToHex(this.b)+this.WordToHex(this.c)+this.WordToHex(this.d),i.toLowerCase()},t.x=Array(),t.S11=7,t.S12=12,t.S13=17,t.S14=22,t.S21=5,t.S22=9,t.S23=14,t.S24=20,t.S31=4,t.S32=11,t.S33=16,t.S34=23,t.S41=6,t.S42=10,t.S43=15,t.S44=21,t.RotateLeft=function(t,i){return t<<i|t>>>32-i},t.F=function(t,i,s){return t&i|~t&s},t.G=function(t,i,s){return t&s|i&~s},t.H=function(t,i,s){return t^i^s},t.I=function(t,i,s){return i^(t|~s)},t}();t.Md5=i,Object.defineProperty(t,"__esModule",{value:!0})});