md5.js
3.16 KB
"use strict";!function(){var d=require("crypt"),T=require("charenc").utf8,p=require("is-buffer"),q=require("charenc").bin,n=function r(t,e){t.constructor==String?t=e&&"binary"===e.encoding?q.stringToBytes(t):T.stringToBytes(t):p(t)?t=Array.prototype.slice.call(t,0):Array.isArray(t)||(t=t.toString());for(var n=d.bytesToWords(t),i=8*t.length,o=1732584193,s=-271733879,u=-1732584194,a=271733878,c=0;c<n.length;c++)n[c]=16711935&(n[c]<<8|n[c]>>>24)|4278255360&(n[c]<<24|n[c]>>>8);n[i>>>5]|=128<<i%32,n[14+(i+64>>>9<<4)]=i;var f=r._ff,g=r._gg,y=r._hh,v=r._ii;for(c=0;c<n.length;c+=16){var _=o,h=s,l=u,b=a;s=v(s=v(s=v(s=v(s=y(s=y(s=y(s=y(s=g(s=g(s=g(s=g(s=f(s=f(s=f(s=f(s,u=f(u,a=f(a,o=f(o,s,u,a,n[c+0],7,-680876936),s,u,n[c+1],12,-389564586),o,s,n[c+2],17,606105819),a,o,n[c+3],22,-1044525330),u=f(u,a=f(a,o=f(o,s,u,a,n[c+4],7,-176418897),s,u,n[c+5],12,1200080426),o,s,n[c+6],17,-1473231341),a,o,n[c+7],22,-45705983),u=f(u,a=f(a,o=f(o,s,u,a,n[c+8],7,1770035416),s,u,n[c+9],12,-1958414417),o,s,n[c+10],17,-42063),a,o,n[c+11],22,-1990404162),u=f(u,a=f(a,o=f(o,s,u,a,n[c+12],7,1804603682),s,u,n[c+13],12,-40341101),o,s,n[c+14],17,-1502002290),a,o,n[c+15],22,1236535329),u=g(u,a=g(a,o=g(o,s,u,a,n[c+1],5,-165796510),s,u,n[c+6],9,-1069501632),o,s,n[c+11],14,643717713),a,o,n[c+0],20,-373897302),u=g(u,a=g(a,o=g(o,s,u,a,n[c+5],5,-701558691),s,u,n[c+10],9,38016083),o,s,n[c+15],14,-660478335),a,o,n[c+4],20,-405537848),u=g(u,a=g(a,o=g(o,s,u,a,n[c+9],5,568446438),s,u,n[c+14],9,-1019803690),o,s,n[c+3],14,-187363961),a,o,n[c+8],20,1163531501),u=g(u,a=g(a,o=g(o,s,u,a,n[c+13],5,-1444681467),s,u,n[c+2],9,-51403784),o,s,n[c+7],14,1735328473),a,o,n[c+12],20,-1926607734),u=y(u,a=y(a,o=y(o,s,u,a,n[c+5],4,-378558),s,u,n[c+8],11,-2022574463),o,s,n[c+11],16,1839030562),a,o,n[c+14],23,-35309556),u=y(u,a=y(a,o=y(o,s,u,a,n[c+1],4,-1530992060),s,u,n[c+4],11,1272893353),o,s,n[c+7],16,-155497632),a,o,n[c+10],23,-1094730640),u=y(u,a=y(a,o=y(o,s,u,a,n[c+13],4,681279174),s,u,n[c+0],11,-358537222),o,s,n[c+3],16,-722521979),a,o,n[c+6],23,76029189),u=y(u,a=y(a,o=y(o,s,u,a,n[c+9],4,-640364487),s,u,n[c+12],11,-421815835),o,s,n[c+15],16,530742520),a,o,n[c+2],23,-995338651),u=v(u,a=v(a,o=v(o,s,u,a,n[c+0],6,-198630844),s,u,n[c+7],10,1126891415),o,s,n[c+14],15,-1416354905),a,o,n[c+5],21,-57434055),u=v(u,a=v(a,o=v(o,s,u,a,n[c+12],6,1700485571),s,u,n[c+3],10,-1894986606),o,s,n[c+10],15,-1051523),a,o,n[c+1],21,-2054922799),u=v(u,a=v(a,o=v(o,s,u,a,n[c+8],6,1873313359),s,u,n[c+15],10,-30611744),o,s,n[c+6],15,-1560198380),a,o,n[c+13],21,1309151649),u=v(u,a=v(a,o=v(o,s,u,a,n[c+4],6,-145523070),s,u,n[c+11],10,-1120210379),o,s,n[c+2],15,718787259),a,o,n[c+9],21,-343485551),o=o+_>>>0,s=s+h>>>0,u=u+l>>>0,a=a+b>>>0}return d.endian([o,s,u,a])};n._ff=function(r,t,e,n,i,o,s){var u=r+(t&e|~t&n)+(i>>>0)+s;return(u<<o|u>>>32-o)+t},n._gg=function(r,t,e,n,i,o,s){var u=r+(t&n|e&~n)+(i>>>0)+s;return(u<<o|u>>>32-o)+t},n._hh=function(r,t,e,n,i,o,s){var u=r+(t^e^n)+(i>>>0)+s;return(u<<o|u>>>32-o)+t},n._ii=function(r,t,e,n,i,o,s){var u=r+(e^(t|~n))+(i>>>0)+s;return(u<<o|u>>>32-o)+t},n._blocksize=16,n._digestsize=16,module.exports=function(r,t){if(void 0!==r){var e=d.wordsToBytes(n(r,t));return t&&t.asBytes?e:t&&t.asString?q.bytesToString(e):d.bytesToHex(e)}}}();