HmacMD5.js 10.8 KB
!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.t=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.i=t.clone(),u=this.u=t.clone(),f=o.words,c=u.words,a=0;a<r;a++)f[a]^=1549556828,c[a]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.t.reset(),this.t.update(this.u)},n.prototype.update=function(n){return this.t.update(n),this},n.prototype.finalize=function(n){var t=this.t.finalize(n);return this.t.reset(),this.t.finalize(this.i.clone().concat(t))},n}()},670:function(n,t,r){r.d(t,{MD5:function(){return v}});var i,e=r(3354),o=r(1868),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[];function c(n,t,r,i,e,o,u){var f=n+(t&r|~t&i)+e+u;return(f<<o|f>>>32-o)+t}function a(n,t,r,i,e,o,u){var f=n+(t&i|r&~i)+e+u;return(f<<o|f>>>32-o)+t}function s(n,t,r,i,e,o,u){var f=n+(t^r^i)+e+u;return(f<<o|f>>>32-o)+t}function h(n,t,r,i,e,o,u){var f=n+(r^(t|~i))+e+u;return(f<<o|f>>>32-o)+t}!function(){for(var n=0;n<64;n++)f[n]=4294967296*Math.abs(Math.sin(n+1))|0}();var v=function(n){function t(t){var r=n.call(this,t)||this;return r.h=new e.e([1732584193,4023233417,2562383102,271733878]),t&&void 0!==t.hash&&(r.h=t.hash.clone()),r}return u(t,n),t.prototype.v=function(){this.h=new e.e([1732584193,4023233417,2562383102,271733878])},t.prototype.l=function(n,t){for(var r=0;r<16;r++){var i=t+r,e=n[i];n[i]=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8)}var o=this.h.words,u=n[t],v=n[t+1],w=n[t+2],d=n[t+3],l=n[t+4],y=n[t+5],b=n[t+6],p=n[t+7],m=n[t+8],g=n[t+9],j=n[t+10],A=n[t+11],M=n[t+12],O=n[t+13],I=n[t+14],E=n[t+15],U=o[0],_=o[1],S=o[2],N=o[3];U=c(U,_,S,N,u,7,f[0]),N=c(N,U,_,S,v,12,f[1]),S=c(S,N,U,_,w,17,f[2]),_=c(_,S,N,U,d,22,f[3]),U=c(U,_,S,N,l,7,f[4]),N=c(N,U,_,S,y,12,f[5]),S=c(S,N,U,_,b,17,f[6]),_=c(_,S,N,U,p,22,f[7]),U=c(U,_,S,N,m,7,f[8]),N=c(N,U,_,S,g,12,f[9]),S=c(S,N,U,_,j,17,f[10]),_=c(_,S,N,U,A,22,f[11]),U=c(U,_,S,N,M,7,f[12]),N=c(N,U,_,S,O,12,f[13]),S=c(S,N,U,_,I,17,f[14]),U=a(U,_=c(_,S,N,U,E,22,f[15]),S,N,v,5,f[16]),N=a(N,U,_,S,b,9,f[17]),S=a(S,N,U,_,A,14,f[18]),_=a(_,S,N,U,u,20,f[19]),U=a(U,_,S,N,y,5,f[20]),N=a(N,U,_,S,j,9,f[21]),S=a(S,N,U,_,E,14,f[22]),_=a(_,S,N,U,l,20,f[23]),U=a(U,_,S,N,g,5,f[24]),N=a(N,U,_,S,I,9,f[25]),S=a(S,N,U,_,d,14,f[26]),_=a(_,S,N,U,m,20,f[27]),U=a(U,_,S,N,O,5,f[28]),N=a(N,U,_,S,w,9,f[29]),S=a(S,N,U,_,p,14,f[30]),U=s(U,_=a(_,S,N,U,M,20,f[31]),S,N,y,4,f[32]),N=s(N,U,_,S,m,11,f[33]),S=s(S,N,U,_,A,16,f[34]),_=s(_,S,N,U,I,23,f[35]),U=s(U,_,S,N,v,4,f[36]),N=s(N,U,_,S,l,11,f[37]),S=s(S,N,U,_,p,16,f[38]),_=s(_,S,N,U,j,23,f[39]),U=s(U,_,S,N,O,4,f[40]),N=s(N,U,_,S,u,11,f[41]),S=s(S,N,U,_,d,16,f[42]),_=s(_,S,N,U,b,23,f[43]),U=s(U,_,S,N,g,4,f[44]),N=s(N,U,_,S,M,11,f[45]),S=s(S,N,U,_,E,16,f[46]),U=h(U,_=s(_,S,N,U,w,23,f[47]),S,N,u,6,f[48]),N=h(N,U,_,S,p,10,f[49]),S=h(S,N,U,_,I,15,f[50]),_=h(_,S,N,U,y,21,f[51]),U=h(U,_,S,N,M,6,f[52]),N=h(N,U,_,S,d,10,f[53]),S=h(S,N,U,_,j,15,f[54]),_=h(_,S,N,U,v,21,f[55]),U=h(U,_,S,N,m,6,f[56]),N=h(N,U,_,S,E,10,f[57]),S=h(S,N,U,_,b,15,f[58]),_=h(_,S,N,U,O,21,f[59]),U=h(U,_,S,N,l,6,f[60]),N=h(N,U,_,S,A,10,f[61]),S=h(S,N,U,_,w,15,f[62]),_=h(_,S,N,U,g,21,f[63]),o[0]=o[0]+U|0,o[1]=o[1]+_|0,o[2]=o[2]+S|0,o[3]=o[3]+N|0},t.prototype.j=function(){var n=this.A,t=n.words,r=8*this.O,i=8*n.nSigBytes;t[i>>>5]|=128<<24-i%32;var e=Math.floor(r/4294967296),o=r;t[15+(i+64>>>9<<4)]=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8),t[14+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n.nSigBytes=4*(t.length+1),this.I();for(var u=this.h,f=u.words,c=0;c<4;c++){var a=f[c];f[c]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return u},t.prototype.clone=function(){return new t({hash:this.h,blockSize:this.U,data:this.A,nBytes:this.O})},t.hash=function(n){return(new t).finalize(n)},t}(o.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this._=Array.isArray(t)?t:[],void(this.S="number"==typeof r?r:4*this._.length);if(t instanceof n)return this._=t.words.slice(),void(this.S=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this._=o,this.S=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.S},set:function(n){this.S=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this._},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this._,t=this.S,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.S%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this._[this.S+i>>>2]|=e<<24-(this.S+i)%4*8}else for(i=0;i<r;i+=4)this._[this.S+i>>>2]=t[i>>>2];return this.S+=r,this},n.prototype.clamp=function(){var n=this.S;this._[n>>>2]&=4294967295<<32-n%4*8,this._.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this._.slice(),this.S)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.N=0,this.U=0,this.F=n,this.A=n&&void 0!==n.data?n.data.clone():new i.e,this.O=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.U},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.A=void 0!==n?n.clone():new i.e,this.O="number"==typeof t?t:0},n.prototype.H=function(n){var t="string"==typeof n?e.d.parse(n):n;this.A.concat(t),this.O+=t.nSigBytes},n.prototype.I=function(n){var t,r=this.A.words,e=this.A.nSigBytes,o=this.U,u=e/(4*this.U),f=(u=n?Math.ceil(u):Math.max((0|u)-this.N,0))*o,c=Math.min(4*f,e);if(f){for(var a=0;a<f;a+=o)this.l(r,a);t=r.splice(0,f),this.A.nSigBytes-=c}return new i.e(t,c)},n.prototype.l=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.U=16,r.F=t,t&&"number"==typeof t.blockSize&&(r.U=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.U},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.v()},t.prototype.update=function(n){return this.H(n),this.I(),this},t.prototype.finalize=function(n){return n&&this.H(n),this.j()},t.prototype.v=function(){throw new Error("Not implemented")},t.prototype.j=function(){throw new Error("Not implemented")},t}(e.C)},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"k",{value:!0})};var i={};return function(){r.r(i),r.d(i,{HmacMD5:function(){return e}});var n=r(6367),t=r(670);function e(r,i){return new n.Hmac(new t.MD5,i).finalize(r)}}(),i}()}));