crypto-md5.js 5.5 KB

1234567
  1. /*
  2. * Crypto-JS v1.1.0
  3. * http://code.google.com/p/crypto-js/
  4. * Copyright (c) 2009, Jeff Mott. All rights reserved.
  5. * http://code.google.com/p/crypto-js/wiki/License
  6. */
  7. (function(){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";window.Crypto={};var a=Crypto.util={rotl:function(d,c){return(d<<c)|(d>>>(32-c))},rotr:function(d,c){return(d<<(32-c))|(d>>>c)},endian:function(d){if(d.constructor==Number){return a.rotl(d,8)&16711935|a.rotl(d,24)&4278255360}for(var c=0;c<d.length;c++){d[c]=a.endian(d[c])}return d},randomBytes:function(d){for(var c=[];d>0;d--){c.push(Math.floor(Math.random()*256))}return c},stringToBytes:function(e){var c=[];for(var d=0;d<e.length;d++){c.push(e.charCodeAt(d))}return c},bytesToString:function(c){var e=[];for(var d=0;d<c.length;d++){e.push(String.fromCharCode(c[d]))}return e.join("")},stringToWords:function(f){var e=[];for(var g=0,d=0;g<f.length;g++,d+=8){e[d>>>5]|=f.charCodeAt(g)<<(24-d%32)}return e},bytesToWords:function(d){var f=[];for(var e=0,c=0;e<d.length;e++,c+=8){f[c>>>5]|=d[e]<<(24-c%32)}return f},wordsToBytes:function(e){var d=[];for(var c=0;c<e.length*32;c+=8){d.push((e[c>>>5]>>>(24-c%32))&255)}return d},bytesToHex:function(c){var e=[];for(var d=0;d<c.length;d++){e.push((c[d]>>>4).toString(16));e.push((c[d]&15).toString(16))}return e.join("")},hexToBytes:function(e){var d=[];for(var f=0;f<e.length;f+=2){d.push(parseInt(e.substr(f,2),16))}return d},bytesToBase64:function(d){if(typeof btoa=="function"){return btoa(a.bytesToString(d))}var c=[],f;for(var e=0;e<d.length;e++){switch(e%3){case 0:c.push(b.charAt(d[e]>>>2));f=(d[e]&3)<<4;break;case 1:c.push(b.charAt(f|(d[e]>>>4)));f=(d[e]&15)<<2;break;case 2:c.push(b.charAt(f|(d[e]>>>6)));c.push(b.charAt(d[e]&63));f=-1}}if(f!=undefined&&f!=-1){c.push(b.charAt(f))}while(c.length%4!=0){c.push("=")}return c.join("")},base64ToBytes:function(d){if(typeof atob=="function"){return a.stringToBytes(atob(d))}d=d.replace(/[^A-Z0-9+\/]/ig,"");var c=[];for(var e=0;e<d.length;e++){switch(e%4){case 1:c.push((b.indexOf(d.charAt(e-1))<<2)|(b.indexOf(d.charAt(e))>>>4));break;case 2:c.push(((b.indexOf(d.charAt(e-1))&15)<<4)|(b.indexOf(d.charAt(e))>>>2));break;case 3:c.push(((b.indexOf(d.charAt(e-1))&3)<<6)|(b.indexOf(d.charAt(e))));break}}return c}};Crypto.mode={}})();(function(){var a=Crypto.util;var b=Crypto.MD5=function(e,c){var d=a.wordsToBytes(b._md5(e));return c&&c.asBytes?d:c&&c.asString?a.bytesToString(d):a.bytesToHex(d)};b._md5=function(s){var g=a.stringToWords(s),h=s.length*8,q=1732584193,p=-271733879,o=-1732584194,n=271733878;for(var j=0;j<g.length;j++){g[j]=((g[j]<<8)|(g[j]>>>24))&16711935|((g[j]<<24)|(g[j]>>>8))&4278255360}g[h>>>5]|=128<<(h%32);g[(((h+64)>>>9)<<4)+14]=h;for(var j=0;j<g.length;j+=16){var e=q,k=p,f=o,r=n;q=b._ff(q,p,o,n,g[j+0],7,-680876936);n=b._ff(n,q,p,o,g[j+1],12,-389564586);o=b._ff(o,n,q,p,g[j+2],17,606105819);p=b._ff(p,o,n,q,g[j+3],22,-1044525330);q=b._ff(q,p,o,n,g[j+4],7,-176418897);n=b._ff(n,q,p,o,g[j+5],12,1200080426);o=b._ff(o,n,q,p,g[j+6],17,-1473231341);p=b._ff(p,o,n,q,g[j+7],22,-45705983);q=b._ff(q,p,o,n,g[j+8],7,1770035416);n=b._ff(n,q,p,o,g[j+9],12,-1958414417);o=b._ff(o,n,q,p,g[j+10],17,-42063);p=b._ff(p,o,n,q,g[j+11],22,-1990404162);q=b._ff(q,p,o,n,g[j+12],7,1804603682);n=b._ff(n,q,p,o,g[j+13],12,-40341101);o=b._ff(o,n,q,p,g[j+14],17,-1502002290);p=b._ff(p,o,n,q,g[j+15],22,1236535329);q=b._gg(q,p,o,n,g[j+1],5,-165796510);n=b._gg(n,q,p,o,g[j+6],9,-1069501632);o=b._gg(o,n,q,p,g[j+11],14,643717713);p=b._gg(p,o,n,q,g[j+0],20,-373897302);q=b._gg(q,p,o,n,g[j+5],5,-701558691);n=b._gg(n,q,p,o,g[j+10],9,38016083);o=b._gg(o,n,q,p,g[j+15],14,-660478335);p=b._gg(p,o,n,q,g[j+4],20,-405537848);q=b._gg(q,p,o,n,g[j+9],5,568446438);n=b._gg(n,q,p,o,g[j+14],9,-1019803690);o=b._gg(o,n,q,p,g[j+3],14,-187363961);p=b._gg(p,o,n,q,g[j+8],20,1163531501);q=b._gg(q,p,o,n,g[j+13],5,-1444681467);n=b._gg(n,q,p,o,g[j+2],9,-51403784);o=b._gg(o,n,q,p,g[j+7],14,1735328473);p=b._gg(p,o,n,q,g[j+12],20,-1926607734);q=b._hh(q,p,o,n,g[j+5],4,-378558);n=b._hh(n,q,p,o,g[j+8],11,-2022574463);o=b._hh(o,n,q,p,g[j+11],16,1839030562);p=b._hh(p,o,n,q,g[j+14],23,-35309556);q=b._hh(q,p,o,n,g[j+1],4,-1530992060);n=b._hh(n,q,p,o,g[j+4],11,1272893353);o=b._hh(o,n,q,p,g[j+7],16,-155497632);p=b._hh(p,o,n,q,g[j+10],23,-1094730640);q=b._hh(q,p,o,n,g[j+13],4,681279174);n=b._hh(n,q,p,o,g[j+0],11,-358537222);o=b._hh(o,n,q,p,g[j+3],16,-722521979);p=b._hh(p,o,n,q,g[j+6],23,76029189);q=b._hh(q,p,o,n,g[j+9],4,-640364487);n=b._hh(n,q,p,o,g[j+12],11,-421815835);o=b._hh(o,n,q,p,g[j+15],16,530742520);p=b._hh(p,o,n,q,g[j+2],23,-995338651);q=b._ii(q,p,o,n,g[j+0],6,-198630844);n=b._ii(n,q,p,o,g[j+7],10,1126891415);o=b._ii(o,n,q,p,g[j+14],15,-1416354905);p=b._ii(p,o,n,q,g[j+5],21,-57434055);q=b._ii(q,p,o,n,g[j+12],6,1700485571);n=b._ii(n,q,p,o,g[j+3],10,-1894986606);o=b._ii(o,n,q,p,g[j+10],15,-1051523);p=b._ii(p,o,n,q,g[j+1],21,-2054922799);q=b._ii(q,p,o,n,g[j+8],6,1873313359);n=b._ii(n,q,p,o,g[j+15],10,-30611744);o=b._ii(o,n,q,p,g[j+6],15,-1560198380);p=b._ii(p,o,n,q,g[j+13],21,1309151649);q=b._ii(q,p,o,n,g[j+4],6,-145523070);n=b._ii(n,q,p,o,g[j+11],10,-1120210379);o=b._ii(o,n,q,p,g[j+2],15,718787259);p=b._ii(p,o,n,q,g[j+9],21,-343485551);q+=e;p+=k;o+=f;n+=r}return a.endian([q,p,o,n])};b._ff=function(g,f,l,j,e,i,h){var k=g+(f&l|~f&j)+(e>>>0)+h;return((k<<i)|(k>>>(32-i)))+f};b._gg=function(g,f,l,j,e,i,h){var k=g+(f&j|l&~j)+(e>>>0)+h;return((k<<i)|(k>>>(32-i)))+f};b._hh=function(g,f,l,j,e,i,h){var k=g+(f^l^j)+(e>>>0)+h;return((k<<i)|(k>>>(32-i)))+f};b._ii=function(g,f,l,j,e,i,h){var k=g+(l^(f|~j))+(e>>>0)+h;return((k<<i)|(k>>>(32-i)))+f};b._blocksize=16})();