diff --git a/CHANGELOG.md b/CHANGELOG.md index 6909fb9..89502da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## v0.10.0 / 2026-11-16 +### Fixed +- Unpaired UTF-16 surrogates produce wrong digests and consume the next code unit in the JS path. Unpaired surrogates are now encoded as U+FFFD, matching `TextEncoder` and Node.js `crypto`. #57 + ## v0.9.2 / 2026-07-20 ### Fixed - CI test. diff --git a/bower.json b/bower.json index 3205ac6..fba3e40 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "js-md5", - "version": "0.9.2", + "version": "0.10.0", "main": ["src/md5.js"], "ignore": [ "tests" diff --git a/build/md5-lite.js b/build/md5-lite.js index af48abf..40b02e8 100644 --- a/build/md5-lite.js +++ b/build/md5-lite.js @@ -2,7 +2,7 @@ * [js-md5]{@link https://github.com/emn178/js-md5} * * @namespace md5 - * @version 0.9.2 + * @version 0.10.0 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2014-2026 * @license MIT @@ -227,7 +227,7 @@ var result = formatMessage(message); message = result[0]; var isString = result[1]; - var code, index = 0, i, length = message.length, blocks = this.blocks; + var code, code2, index = 0, i, length = message.length, blocks = this.blocks; var buffer8 = this.buffer8; while (index < length) { @@ -253,12 +253,18 @@ buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) { + ++index; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); + } else { + // unpaired surrogate: U+FFFD + buffer8[i++] = 0xef; + buffer8[i++] = 0xbf; + buffer8[i++] = 0xbd; } } } diff --git a/build/md5-lite.min.js b/build/md5-lite.min.js index 99b468c..3ccfc65 100644 --- a/build/md5-lite.min.js +++ b/build/md5-lite.min.js @@ -2,9 +2,9 @@ * [js-md5]{@link https://github.com/emn178/js-md5} * * @namespace md5 - * @version 0.9.2 + * @version 0.10.0 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2014-2026 * @license MIT */ -!function(){var t="input is invalid type",r="object"==typeof window,e=r?window:{};e.JS_MD5_NO_WINDOW&&(r=!1);var i="undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope,s=!e.JS_MD5_NO_NODE_JS&&!r&&"object"==typeof process&&process.versions&&process.versions.node;s?e=global:i&&(e=self);var h,n=!e.JS_MD5_NO_COMMON_JS&&"object"==typeof module&&module.exports,o="function"==typeof define&&define.amd,a="0123456789abcdef".split(""),f=[128,32768,8388608,-2147483648],u=["hex","array","digest","arrayBuffer"],y=[],c=new ArrayBuffer(68);h=new Uint8Array(c),y=new Uint32Array(c);var d=Array.isArray,p=ArrayBuffer.isView,l=function(t){return function(r){return new w(!0).update(r)[t]()}},b=function(r){var e=require("crypto"),i=require("buffer").Buffer,s=i.from;return function(h){if("string"==typeof h)return e.createHash("md5").update(h,"utf8").digest("hex");if(null==h)throw new Error(t);return h.constructor===ArrayBuffer&&(h=new Uint8Array(h)),d(h)||p(h)||h.constructor===i?e.createHash("md5").update(s(h)).digest("hex"):r(h)}};function w(t){if(t)y[0]=y[16]=y[1]=y[2]=y[3]=y[4]=y[5]=y[6]=y[7]=y[8]=y[9]=y[10]=y[11]=y[12]=y[13]=y[14]=y[15]=0,this.blocks=y,this.buffer8=h;else{var r=new ArrayBuffer(68);this.buffer8=new Uint8Array(r),this.blocks=new Uint32Array(r)}this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}w.prototype.update=function(r){if(this.finalized)throw new Error("finalize already called");var e=function(r){var e=typeof r;if("string"===e)return[r,!0];if("object"!==e||null===r)throw new Error(t);if(r.constructor===ArrayBuffer)return[new Uint8Array(r),!1];if(!d(r)&&!p(r))throw new Error(t);return[r,!1]}(r);r=e[0];for(var i,s,h=e[1],n=0,o=r.length,a=this.blocks,f=this.buffer8;n>>6,f[s++]=128|63&i):i<55296||i>=57344?(f[s++]=224|i>>>12,f[s++]=128|i>>>6&63,f[s++]=128|63&i):(i=65536+((1023&i)<<10|1023&r.charCodeAt(++n)),f[s++]=240|i>>>18,f[s++]=128|i>>>12&63,f[s++]=128|i>>>6&63,f[s++]=128|63&i);else for(s=this.start;n=64?(this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},w.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[r>>>2]|=f[3&r],r>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},w.prototype.hash=function(){var t,r,e,i,s,h,n=this.blocks;this.first?r=((r=((t=((t=n[0]-680876937)<<7|t>>>25)-271733879|0)^(e=((e=(-271733879^(i=((i=(-1732584194^2004318071&t)+n[1]-117830708)<<12|i>>>20)+t|0)&(-271733879^t))+n[2]-1126478375)<<17|e>>>15)+i|0)&(i^t))+n[3]-1316259209)<<22|r>>>10)+e|0:(t=this.h0,r=this.h1,e=this.h2,r=((r+=((t=((t+=((i=this.h3)^r&(e^i))+n[0]-680876936)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[1]-389564586)<<12|i>>>20)+t|0)&(t^r))+n[2]+606105819)<<17|e>>>15)+i|0)&(i^t))+n[3]-1044525330)<<22|r>>>10)+e|0),r=((r+=((t=((t+=(i^r&(e^i))+n[4]-176418897)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[5]+1200080426)<<12|i>>>20)+t|0)&(t^r))+n[6]-1473231341)<<17|e>>>15)+i|0)&(i^t))+n[7]-45705983)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+n[8]+1770035416)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[9]-1958414417)<<12|i>>>20)+t|0)&(t^r))+n[10]-42063)<<17|e>>>15)+i|0)&(i^t))+n[11]-1990404162)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+n[12]+1804603682)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[13]-40341101)<<12|i>>>20)+t|0)&(t^r))+n[14]-1502002290)<<17|e>>>15)+i|0)&(i^t))+n[15]+1236535329)<<22|r>>>10)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[1]-165796510)<<5|t>>>27)+r|0)^r))+n[6]-1069501632)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[11]+643717713)<<14|e>>>18)+i|0)^i))+n[0]-373897302)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[5]-701558691)<<5|t>>>27)+r|0)^r))+n[10]+38016083)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[15]-660478335)<<14|e>>>18)+i|0)^i))+n[4]-405537848)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[9]+568446438)<<5|t>>>27)+r|0)^r))+n[14]-1019803690)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[3]-187363961)<<14|e>>>18)+i|0)^i))+n[8]+1163531501)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[13]-1444681467)<<5|t>>>27)+r|0)^r))+n[2]-51403784)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[7]+1735328473)<<14|e>>>18)+i|0)^i))+n[12]-1926607734)<<20|r>>>12)+e|0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+n[5]-378558)<<4|t>>>28)+r|0))+n[8]-2022574463)<<11|i>>>21)+t|0)^t)^(e=((e+=(h^r)+n[11]+1839030562)<<16|e>>>16)+i|0))+n[14]-35309556)<<23|r>>>9)+e|0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+n[1]-1530992060)<<4|t>>>28)+r|0))+n[4]+1272893353)<<11|i>>>21)+t|0)^t)^(e=((e+=(h^r)+n[7]-155497632)<<16|e>>>16)+i|0))+n[10]-1094730640)<<23|r>>>9)+e|0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+n[13]+681279174)<<4|t>>>28)+r|0))+n[0]-358537222)<<11|i>>>21)+t|0)^t)^(e=((e+=(h^r)+n[3]-722521979)<<16|e>>>16)+i|0))+n[6]+76029189)<<23|r>>>9)+e|0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+n[9]-640364487)<<4|t>>>28)+r|0))+n[12]-421815835)<<11|i>>>21)+t|0)^t)^(e=((e+=(h^r)+n[15]+530742520)<<16|e>>>16)+i|0))+n[2]-995338651)<<23|r>>>9)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[0]-198630844)<<6|t>>>26)+r|0)|~e))+n[7]+1126891415)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[14]-1416354905)<<15|e>>>17)+i|0)|~t))+n[5]-57434055)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[12]+1700485571)<<6|t>>>26)+r|0)|~e))+n[3]-1894986606)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[10]-1051523)<<15|e>>>17)+i|0)|~t))+n[1]-2054922799)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[8]+1873313359)<<6|t>>>26)+r|0)|~e))+n[15]-30611744)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[6]-1560198380)<<15|e>>>17)+i|0)|~t))+n[13]+1309151649)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[4]-145523070)<<6|t>>>26)+r|0)|~e))+n[11]-1120210379)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[2]+718787259)<<15|e>>>17)+i|0)|~t))+n[9]-343485551)<<21|r>>>11)+e|0,this.first?(this.h0=t+1732584193|0,this.h1=r-271733879|0,this.h2=e-1732584194|0,this.h3=i+271733878|0,this.first=!1):(this.h0=this.h0+t|0,this.h1=this.h1+r|0,this.h2=this.h2+e|0,this.h3=this.h3+i|0)},w.prototype.hex=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return a[t>>>4&15]+a[15&t]+a[t>>>12&15]+a[t>>>8&15]+a[t>>>20&15]+a[t>>>16&15]+a[t>>>28&15]+a[t>>>24&15]+a[r>>>4&15]+a[15&r]+a[r>>>12&15]+a[r>>>8&15]+a[r>>>20&15]+a[r>>>16&15]+a[r>>>28&15]+a[r>>>24&15]+a[e>>>4&15]+a[15&e]+a[e>>>12&15]+a[e>>>8&15]+a[e>>>20&15]+a[e>>>16&15]+a[e>>>28&15]+a[e>>>24&15]+a[i>>>4&15]+a[15&i]+a[i>>>12&15]+a[i>>>8&15]+a[i>>>20&15]+a[i>>>16&15]+a[i>>>28&15]+a[i>>>24&15]},w.prototype.toString=w.prototype.hex,w.prototype.digest=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&i,i>>>8&255,i>>>16&255,i>>>24&255]},w.prototype.array=w.prototype.digest,w.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),r=new Uint32Array(t);return r[0]=this.h0,r[1]=this.h1,r[2]=this.h2,r[3]=this.h3,t};var v=function(){var t=l("hex");s&&(t=b(t)),t.create=function(){return new w},t.update=function(r){return t.create().update(r)};for(var r=0;r>>6,u[h++]=128|63&i):i<55296||i>=57344?(u[h++]=224|i>>>12,u[h++]=128|i>>>6&63,u[h++]=128|63&i):i<56320&&(s=r.charCodeAt(o+1))>=56320&&s<57344?(++o,i=65536+((1023&i)<<10|1023&s),u[h++]=240|i>>>18,u[h++]=128|i>>>12&63,u[h++]=128|i>>>6&63,u[h++]=128|63&i):(u[h++]=239,u[h++]=191,u[h++]=189);else for(h=this.start;o=64?(this.start=h-64,this.hash(),this.hashed=!0):this.start=h}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},w.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[r>>>2]|=f[3&r],r>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},w.prototype.hash=function(){var t,r,e,i,s,h,n=this.blocks;this.first?r=((r=((t=((t=n[0]-680876937)<<7|t>>>25)-271733879|0)^(e=((e=(-271733879^(i=((i=(-1732584194^2004318071&t)+n[1]-117830708)<<12|i>>>20)+t|0)&(-271733879^t))+n[2]-1126478375)<<17|e>>>15)+i|0)&(i^t))+n[3]-1316259209)<<22|r>>>10)+e|0:(t=this.h0,r=this.h1,e=this.h2,r=((r+=((t=((t+=((i=this.h3)^r&(e^i))+n[0]-680876936)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[1]-389564586)<<12|i>>>20)+t|0)&(t^r))+n[2]+606105819)<<17|e>>>15)+i|0)&(i^t))+n[3]-1044525330)<<22|r>>>10)+e|0),r=((r+=((t=((t+=(i^r&(e^i))+n[4]-176418897)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[5]+1200080426)<<12|i>>>20)+t|0)&(t^r))+n[6]-1473231341)<<17|e>>>15)+i|0)&(i^t))+n[7]-45705983)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+n[8]+1770035416)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[9]-1958414417)<<12|i>>>20)+t|0)&(t^r))+n[10]-42063)<<17|e>>>15)+i|0)&(i^t))+n[11]-1990404162)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+n[12]+1804603682)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[13]-40341101)<<12|i>>>20)+t|0)&(t^r))+n[14]-1502002290)<<17|e>>>15)+i|0)&(i^t))+n[15]+1236535329)<<22|r>>>10)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[1]-165796510)<<5|t>>>27)+r|0)^r))+n[6]-1069501632)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[11]+643717713)<<14|e>>>18)+i|0)^i))+n[0]-373897302)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[5]-701558691)<<5|t>>>27)+r|0)^r))+n[10]+38016083)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[15]-660478335)<<14|e>>>18)+i|0)^i))+n[4]-405537848)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[9]+568446438)<<5|t>>>27)+r|0)^r))+n[14]-1019803690)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[3]-187363961)<<14|e>>>18)+i|0)^i))+n[8]+1163531501)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[13]-1444681467)<<5|t>>>27)+r|0)^r))+n[2]-51403784)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[7]+1735328473)<<14|e>>>18)+i|0)^i))+n[12]-1926607734)<<20|r>>>12)+e|0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+n[5]-378558)<<4|t>>>28)+r|0))+n[8]-2022574463)<<11|i>>>21)+t|0)^t)^(e=((e+=(h^r)+n[11]+1839030562)<<16|e>>>16)+i|0))+n[14]-35309556)<<23|r>>>9)+e|0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+n[1]-1530992060)<<4|t>>>28)+r|0))+n[4]+1272893353)<<11|i>>>21)+t|0)^t)^(e=((e+=(h^r)+n[7]-155497632)<<16|e>>>16)+i|0))+n[10]-1094730640)<<23|r>>>9)+e|0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+n[13]+681279174)<<4|t>>>28)+r|0))+n[0]-358537222)<<11|i>>>21)+t|0)^t)^(e=((e+=(h^r)+n[3]-722521979)<<16|e>>>16)+i|0))+n[6]+76029189)<<23|r>>>9)+e|0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+n[9]-640364487)<<4|t>>>28)+r|0))+n[12]-421815835)<<11|i>>>21)+t|0)^t)^(e=((e+=(h^r)+n[15]+530742520)<<16|e>>>16)+i|0))+n[2]-995338651)<<23|r>>>9)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[0]-198630844)<<6|t>>>26)+r|0)|~e))+n[7]+1126891415)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[14]-1416354905)<<15|e>>>17)+i|0)|~t))+n[5]-57434055)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[12]+1700485571)<<6|t>>>26)+r|0)|~e))+n[3]-1894986606)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[10]-1051523)<<15|e>>>17)+i|0)|~t))+n[1]-2054922799)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[8]+1873313359)<<6|t>>>26)+r|0)|~e))+n[15]-30611744)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[6]-1560198380)<<15|e>>>17)+i|0)|~t))+n[13]+1309151649)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[4]-145523070)<<6|t>>>26)+r|0)|~e))+n[11]-1120210379)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[2]+718787259)<<15|e>>>17)+i|0)|~t))+n[9]-343485551)<<21|r>>>11)+e|0,this.first?(this.h0=t+1732584193|0,this.h1=r-271733879|0,this.h2=e-1732584194|0,this.h3=i+271733878|0,this.first=!1):(this.h0=this.h0+t|0,this.h1=this.h1+r|0,this.h2=this.h2+e|0,this.h3=this.h3+i|0)},w.prototype.hex=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return a[t>>>4&15]+a[15&t]+a[t>>>12&15]+a[t>>>8&15]+a[t>>>20&15]+a[t>>>16&15]+a[t>>>28&15]+a[t>>>24&15]+a[r>>>4&15]+a[15&r]+a[r>>>12&15]+a[r>>>8&15]+a[r>>>20&15]+a[r>>>16&15]+a[r>>>28&15]+a[r>>>24&15]+a[e>>>4&15]+a[15&e]+a[e>>>12&15]+a[e>>>8&15]+a[e>>>20&15]+a[e>>>16&15]+a[e>>>28&15]+a[e>>>24&15]+a[i>>>4&15]+a[15&i]+a[i>>>12&15]+a[i>>>8&15]+a[i>>>20&15]+a[i>>>16&15]+a[i>>>28&15]+a[i>>>24&15]},w.prototype.toString=w.prototype.hex,w.prototype.digest=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&i,i>>>8&255,i>>>16&255,i>>>24&255]},w.prototype.array=w.prototype.digest,w.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),r=new Uint32Array(t);return r[0]=this.h0,r[1]=this.h1,r[2]=this.h2,r[3]=this.h3,t};var v=function(){var t=l("hex");s&&(t=b(t)),t.create=function(){return new w},t.update=function(r){return t.create().update(r)};for(var r=0;r>>6,f[s++]=128|63&h):h<55296||h>=57344?(f[s++]=224|h>>>12,f[s++]=128|h>>>6&63,f[s++]=128|63&h):(h=65536+((1023&h)<<10|1023&i.charCodeAt(++n)),f[s++]=240|h>>>18,f[s++]=128|h>>>12&63,f[s++]=128|h>>>6&63,f[s++]=128|63&h);else for(s=this.start;n=64?(this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},d.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,i=this.lastByteIndex;t[i>>>2]|=a[3&i],i>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},d.prototype.hash=function(){var t,i,r,h,s,e,n=this.blocks;this.first?i=((i=((t=((t=n[0]-680876937)<<7|t>>>25)-271733879|0)^(r=((r=(-271733879^(h=((h=(-1732584194^2004318071&t)+n[1]-117830708)<<12|h>>>20)+t|0)&(-271733879^t))+n[2]-1126478375)<<17|r>>>15)+h|0)&(h^t))+n[3]-1316259209)<<22|i>>>10)+r|0:(t=this.h0,i=this.h1,r=this.h2,i=((i+=((t=((t+=((h=this.h3)^i&(r^h))+n[0]-680876936)<<7|t>>>25)+i|0)^(r=((r+=(i^(h=((h+=(r^t&(i^r))+n[1]-389564586)<<12|h>>>20)+t|0)&(t^i))+n[2]+606105819)<<17|r>>>15)+h|0)&(h^t))+n[3]-1044525330)<<22|i>>>10)+r|0),i=((i+=((t=((t+=(h^i&(r^h))+n[4]-176418897)<<7|t>>>25)+i|0)^(r=((r+=(i^(h=((h+=(r^t&(i^r))+n[5]+1200080426)<<12|h>>>20)+t|0)&(t^i))+n[6]-1473231341)<<17|r>>>15)+h|0)&(h^t))+n[7]-45705983)<<22|i>>>10)+r|0,i=((i+=((t=((t+=(h^i&(r^h))+n[8]+1770035416)<<7|t>>>25)+i|0)^(r=((r+=(i^(h=((h+=(r^t&(i^r))+n[9]-1958414417)<<12|h>>>20)+t|0)&(t^i))+n[10]-42063)<<17|r>>>15)+h|0)&(h^t))+n[11]-1990404162)<<22|i>>>10)+r|0,i=((i+=((t=((t+=(h^i&(r^h))+n[12]+1804603682)<<7|t>>>25)+i|0)^(r=((r+=(i^(h=((h+=(r^t&(i^r))+n[13]-40341101)<<12|h>>>20)+t|0)&(t^i))+n[14]-1502002290)<<17|r>>>15)+h|0)&(h^t))+n[15]+1236535329)<<22|i>>>10)+r|0,i=((i+=((h=((h+=(i^r&((t=((t+=(r^h&(i^r))+n[1]-165796510)<<5|t>>>27)+i|0)^i))+n[6]-1069501632)<<9|h>>>23)+t|0)^t&((r=((r+=(t^i&(h^t))+n[11]+643717713)<<14|r>>>18)+h|0)^h))+n[0]-373897302)<<20|i>>>12)+r|0,i=((i+=((h=((h+=(i^r&((t=((t+=(r^h&(i^r))+n[5]-701558691)<<5|t>>>27)+i|0)^i))+n[10]+38016083)<<9|h>>>23)+t|0)^t&((r=((r+=(t^i&(h^t))+n[15]-660478335)<<14|r>>>18)+h|0)^h))+n[4]-405537848)<<20|i>>>12)+r|0,i=((i+=((h=((h+=(i^r&((t=((t+=(r^h&(i^r))+n[9]+568446438)<<5|t>>>27)+i|0)^i))+n[14]-1019803690)<<9|h>>>23)+t|0)^t&((r=((r+=(t^i&(h^t))+n[3]-187363961)<<14|r>>>18)+h|0)^h))+n[8]+1163531501)<<20|i>>>12)+r|0,i=((i+=((h=((h+=(i^r&((t=((t+=(r^h&(i^r))+n[13]-1444681467)<<5|t>>>27)+i|0)^i))+n[2]-51403784)<<9|h>>>23)+t|0)^t&((r=((r+=(t^i&(h^t))+n[7]+1735328473)<<14|r>>>18)+h|0)^h))+n[12]-1926607734)<<20|i>>>12)+r|0,i=((i+=((e=(h=((h+=((s=i^r)^(t=((t+=(s^h)+n[5]-378558)<<4|t>>>28)+i|0))+n[8]-2022574463)<<11|h>>>21)+t|0)^t)^(r=((r+=(e^i)+n[11]+1839030562)<<16|r>>>16)+h|0))+n[14]-35309556)<<23|i>>>9)+r|0,i=((i+=((e=(h=((h+=((s=i^r)^(t=((t+=(s^h)+n[1]-1530992060)<<4|t>>>28)+i|0))+n[4]+1272893353)<<11|h>>>21)+t|0)^t)^(r=((r+=(e^i)+n[7]-155497632)<<16|r>>>16)+h|0))+n[10]-1094730640)<<23|i>>>9)+r|0,i=((i+=((e=(h=((h+=((s=i^r)^(t=((t+=(s^h)+n[13]+681279174)<<4|t>>>28)+i|0))+n[0]-358537222)<<11|h>>>21)+t|0)^t)^(r=((r+=(e^i)+n[3]-722521979)<<16|r>>>16)+h|0))+n[6]+76029189)<<23|i>>>9)+r|0,i=((i+=((e=(h=((h+=((s=i^r)^(t=((t+=(s^h)+n[9]-640364487)<<4|t>>>28)+i|0))+n[12]-421815835)<<11|h>>>21)+t|0)^t)^(r=((r+=(e^i)+n[15]+530742520)<<16|r>>>16)+h|0))+n[2]-995338651)<<23|i>>>9)+r|0,i=((i+=((h=((h+=(i^((t=((t+=(r^(i|~h))+n[0]-198630844)<<6|t>>>26)+i|0)|~r))+n[7]+1126891415)<<10|h>>>22)+t|0)^((r=((r+=(t^(h|~i))+n[14]-1416354905)<<15|r>>>17)+h|0)|~t))+n[5]-57434055)<<21|i>>>11)+r|0,i=((i+=((h=((h+=(i^((t=((t+=(r^(i|~h))+n[12]+1700485571)<<6|t>>>26)+i|0)|~r))+n[3]-1894986606)<<10|h>>>22)+t|0)^((r=((r+=(t^(h|~i))+n[10]-1051523)<<15|r>>>17)+h|0)|~t))+n[1]-2054922799)<<21|i>>>11)+r|0,i=((i+=((h=((h+=(i^((t=((t+=(r^(i|~h))+n[8]+1873313359)<<6|t>>>26)+i|0)|~r))+n[15]-30611744)<<10|h>>>22)+t|0)^((r=((r+=(t^(h|~i))+n[6]-1560198380)<<15|r>>>17)+h|0)|~t))+n[13]+1309151649)<<21|i>>>11)+r|0,i=((i+=((h=((h+=(i^((t=((t+=(r^(i|~h))+n[4]-145523070)<<6|t>>>26)+i|0)|~r))+n[11]-1120210379)<<10|h>>>22)+t|0)^((r=((r+=(t^(h|~i))+n[2]+718787259)<<15|r>>>17)+h|0)|~t))+n[9]-343485551)<<21|i>>>11)+r|0,this.first?(this.h0=t+1732584193|0,this.h1=i-271733879|0,this.h2=r-1732584194|0,this.h3=h+271733878|0,this.first=!1):(this.h0=this.h0+t|0,this.h1=this.h1+i|0,this.h2=this.h2+r|0,this.h3=this.h3+h|0)},d.prototype.hex=function(){this.finalize();var t=this.h0,i=this.h1,r=this.h2,h=this.h3;return n[t>>>4&15]+n[15&t]+n[t>>>12&15]+n[t>>>8&15]+n[t>>>20&15]+n[t>>>16&15]+n[t>>>28&15]+n[t>>>24&15]+n[i>>>4&15]+n[15&i]+n[i>>>12&15]+n[i>>>8&15]+n[i>>>20&15]+n[i>>>16&15]+n[i>>>28&15]+n[i>>>24&15]+n[r>>>4&15]+n[15&r]+n[r>>>12&15]+n[r>>>8&15]+n[r>>>20&15]+n[r>>>16&15]+n[r>>>28&15]+n[r>>>24&15]+n[h>>>4&15]+n[15&h]+n[h>>>12&15]+n[h>>>8&15]+n[h>>>20&15]+n[h>>>16&15]+n[h>>>28&15]+n[h>>>24&15]},d.prototype.toString=d.prototype.hex,d.prototype.digest=function(){this.finalize();var t=this.h0,i=this.h1,r=this.h2,h=this.h3;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&i,i>>>8&255,i>>>16&255,i>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255,255&h,h>>>8&255,h>>>16&255,h>>>24&255]},d.prototype.array=d.prototype.digest,d.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),i=new Uint32Array(t);return i[0]=this.h0,i[1]=this.h1,i[2]=this.h2,i[3]=this.h3,t};var c=function(){var t=l("hex");t.create=function(){return new d},t.update=function(i){return t.create().update(i)};for(var i=0;i>>6,u[e++]=128|63&h):h<55296||h>=57344?(u[e++]=224|h>>>12,u[e++]=128|h>>>6&63,u[e++]=128|63&h):h<56320&&(s=i.charCodeAt(a+1))>=56320&&s<57344?(++a,h=65536+((1023&h)<<10|1023&s),u[e++]=240|h>>>18,u[e++]=128|h>>>12&63,u[e++]=128|h>>>6&63,u[e++]=128|63&h):(u[e++]=239,u[e++]=191,u[e++]=189);else for(e=this.start;a=64?(this.start=e-64,this.hash(),this.hashed=!0):this.start=e}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},d.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,i=this.lastByteIndex;t[i>>>2]|=a[3&i],i>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},d.prototype.hash=function(){var t,i,r,h,s,e,n=this.blocks;this.first?i=((i=((t=((t=n[0]-680876937)<<7|t>>>25)-271733879|0)^(r=((r=(-271733879^(h=((h=(-1732584194^2004318071&t)+n[1]-117830708)<<12|h>>>20)+t|0)&(-271733879^t))+n[2]-1126478375)<<17|r>>>15)+h|0)&(h^t))+n[3]-1316259209)<<22|i>>>10)+r|0:(t=this.h0,i=this.h1,r=this.h2,i=((i+=((t=((t+=((h=this.h3)^i&(r^h))+n[0]-680876936)<<7|t>>>25)+i|0)^(r=((r+=(i^(h=((h+=(r^t&(i^r))+n[1]-389564586)<<12|h>>>20)+t|0)&(t^i))+n[2]+606105819)<<17|r>>>15)+h|0)&(h^t))+n[3]-1044525330)<<22|i>>>10)+r|0),i=((i+=((t=((t+=(h^i&(r^h))+n[4]-176418897)<<7|t>>>25)+i|0)^(r=((r+=(i^(h=((h+=(r^t&(i^r))+n[5]+1200080426)<<12|h>>>20)+t|0)&(t^i))+n[6]-1473231341)<<17|r>>>15)+h|0)&(h^t))+n[7]-45705983)<<22|i>>>10)+r|0,i=((i+=((t=((t+=(h^i&(r^h))+n[8]+1770035416)<<7|t>>>25)+i|0)^(r=((r+=(i^(h=((h+=(r^t&(i^r))+n[9]-1958414417)<<12|h>>>20)+t|0)&(t^i))+n[10]-42063)<<17|r>>>15)+h|0)&(h^t))+n[11]-1990404162)<<22|i>>>10)+r|0,i=((i+=((t=((t+=(h^i&(r^h))+n[12]+1804603682)<<7|t>>>25)+i|0)^(r=((r+=(i^(h=((h+=(r^t&(i^r))+n[13]-40341101)<<12|h>>>20)+t|0)&(t^i))+n[14]-1502002290)<<17|r>>>15)+h|0)&(h^t))+n[15]+1236535329)<<22|i>>>10)+r|0,i=((i+=((h=((h+=(i^r&((t=((t+=(r^h&(i^r))+n[1]-165796510)<<5|t>>>27)+i|0)^i))+n[6]-1069501632)<<9|h>>>23)+t|0)^t&((r=((r+=(t^i&(h^t))+n[11]+643717713)<<14|r>>>18)+h|0)^h))+n[0]-373897302)<<20|i>>>12)+r|0,i=((i+=((h=((h+=(i^r&((t=((t+=(r^h&(i^r))+n[5]-701558691)<<5|t>>>27)+i|0)^i))+n[10]+38016083)<<9|h>>>23)+t|0)^t&((r=((r+=(t^i&(h^t))+n[15]-660478335)<<14|r>>>18)+h|0)^h))+n[4]-405537848)<<20|i>>>12)+r|0,i=((i+=((h=((h+=(i^r&((t=((t+=(r^h&(i^r))+n[9]+568446438)<<5|t>>>27)+i|0)^i))+n[14]-1019803690)<<9|h>>>23)+t|0)^t&((r=((r+=(t^i&(h^t))+n[3]-187363961)<<14|r>>>18)+h|0)^h))+n[8]+1163531501)<<20|i>>>12)+r|0,i=((i+=((h=((h+=(i^r&((t=((t+=(r^h&(i^r))+n[13]-1444681467)<<5|t>>>27)+i|0)^i))+n[2]-51403784)<<9|h>>>23)+t|0)^t&((r=((r+=(t^i&(h^t))+n[7]+1735328473)<<14|r>>>18)+h|0)^h))+n[12]-1926607734)<<20|i>>>12)+r|0,i=((i+=((e=(h=((h+=((s=i^r)^(t=((t+=(s^h)+n[5]-378558)<<4|t>>>28)+i|0))+n[8]-2022574463)<<11|h>>>21)+t|0)^t)^(r=((r+=(e^i)+n[11]+1839030562)<<16|r>>>16)+h|0))+n[14]-35309556)<<23|i>>>9)+r|0,i=((i+=((e=(h=((h+=((s=i^r)^(t=((t+=(s^h)+n[1]-1530992060)<<4|t>>>28)+i|0))+n[4]+1272893353)<<11|h>>>21)+t|0)^t)^(r=((r+=(e^i)+n[7]-155497632)<<16|r>>>16)+h|0))+n[10]-1094730640)<<23|i>>>9)+r|0,i=((i+=((e=(h=((h+=((s=i^r)^(t=((t+=(s^h)+n[13]+681279174)<<4|t>>>28)+i|0))+n[0]-358537222)<<11|h>>>21)+t|0)^t)^(r=((r+=(e^i)+n[3]-722521979)<<16|r>>>16)+h|0))+n[6]+76029189)<<23|i>>>9)+r|0,i=((i+=((e=(h=((h+=((s=i^r)^(t=((t+=(s^h)+n[9]-640364487)<<4|t>>>28)+i|0))+n[12]-421815835)<<11|h>>>21)+t|0)^t)^(r=((r+=(e^i)+n[15]+530742520)<<16|r>>>16)+h|0))+n[2]-995338651)<<23|i>>>9)+r|0,i=((i+=((h=((h+=(i^((t=((t+=(r^(i|~h))+n[0]-198630844)<<6|t>>>26)+i|0)|~r))+n[7]+1126891415)<<10|h>>>22)+t|0)^((r=((r+=(t^(h|~i))+n[14]-1416354905)<<15|r>>>17)+h|0)|~t))+n[5]-57434055)<<21|i>>>11)+r|0,i=((i+=((h=((h+=(i^((t=((t+=(r^(i|~h))+n[12]+1700485571)<<6|t>>>26)+i|0)|~r))+n[3]-1894986606)<<10|h>>>22)+t|0)^((r=((r+=(t^(h|~i))+n[10]-1051523)<<15|r>>>17)+h|0)|~t))+n[1]-2054922799)<<21|i>>>11)+r|0,i=((i+=((h=((h+=(i^((t=((t+=(r^(i|~h))+n[8]+1873313359)<<6|t>>>26)+i|0)|~r))+n[15]-30611744)<<10|h>>>22)+t|0)^((r=((r+=(t^(h|~i))+n[6]-1560198380)<<15|r>>>17)+h|0)|~t))+n[13]+1309151649)<<21|i>>>11)+r|0,i=((i+=((h=((h+=(i^((t=((t+=(r^(i|~h))+n[4]-145523070)<<6|t>>>26)+i|0)|~r))+n[11]-1120210379)<<10|h>>>22)+t|0)^((r=((r+=(t^(h|~i))+n[2]+718787259)<<15|r>>>17)+h|0)|~t))+n[9]-343485551)<<21|i>>>11)+r|0,this.first?(this.h0=t+1732584193|0,this.h1=i-271733879|0,this.h2=r-1732584194|0,this.h3=h+271733878|0,this.first=!1):(this.h0=this.h0+t|0,this.h1=this.h1+i|0,this.h2=this.h2+r|0,this.h3=this.h3+h|0)},d.prototype.hex=function(){this.finalize();var t=this.h0,i=this.h1,r=this.h2,h=this.h3;return n[t>>>4&15]+n[15&t]+n[t>>>12&15]+n[t>>>8&15]+n[t>>>20&15]+n[t>>>16&15]+n[t>>>28&15]+n[t>>>24&15]+n[i>>>4&15]+n[15&i]+n[i>>>12&15]+n[i>>>8&15]+n[i>>>20&15]+n[i>>>16&15]+n[i>>>28&15]+n[i>>>24&15]+n[r>>>4&15]+n[15&r]+n[r>>>12&15]+n[r>>>8&15]+n[r>>>20&15]+n[r>>>16&15]+n[r>>>28&15]+n[r>>>24&15]+n[h>>>4&15]+n[15&h]+n[h>>>12&15]+n[h>>>8&15]+n[h>>>20&15]+n[h>>>16&15]+n[h>>>28&15]+n[h>>>24&15]},d.prototype.toString=d.prototype.hex,d.prototype.digest=function(){this.finalize();var t=this.h0,i=this.h1,r=this.h2,h=this.h3;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&i,i>>>8&255,i>>>16&255,i>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255,255&h,h>>>8&255,h>>>16&255,h>>>24&255]},d.prototype.array=d.prototype.digest,d.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),i=new Uint32Array(t);return i[0]=this.h0,i[1]=this.h1,i[2]=this.h2,i[3]=this.h3,t};var c=function(){var t=l("hex");t.create=function(){return new d},t.update=function(i){return t.create().update(i)};for(var i=0;i>> 12); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) { + ++index; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); + } else { + // unpaired surrogate: U+FFFD + buffer8[i++] = 0xef; + buffer8[i++] = 0xbf; + buffer8[i++] = 0xbd; } } } diff --git a/build/md5-lite.node.mjs b/build/md5-lite.node.mjs index 84407e8..d381f41 100644 --- a/build/md5-lite.node.mjs +++ b/build/md5-lite.node.mjs @@ -13,7 +13,7 @@ var md5$1 = {exports: {}}; * [js-md5]{@link https://github.com/emn178/js-md5} * * @namespace md5 - * @version 0.9.2 + * @version 0.10.0 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2014-2026 * @license MIT @@ -239,7 +239,7 @@ var md5$1 = {exports: {}}; var result = formatMessage(message); message = result[0]; var isString = result[1]; - var code, index = 0, i, length = message.length, blocks = this.blocks; + var code, code2, index = 0, i, length = message.length, blocks = this.blocks; var buffer8 = this.buffer8; while (index < length) { @@ -265,12 +265,18 @@ var md5$1 = {exports: {}}; buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) { + ++index; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); + } else { + // unpaired surrogate: U+FFFD + buffer8[i++] = 0xef; + buffer8[i++] = 0xbf; + buffer8[i++] = 0xbd; } } } diff --git a/build/md5.js b/build/md5.js index 84a3ce5..b6d3ba5 100644 --- a/build/md5.js +++ b/build/md5.js @@ -2,7 +2,7 @@ * [js-md5]{@link https://github.com/emn178/js-md5} * * @namespace md5 - * @version 0.9.2 + * @version 0.10.0 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2014-2026 * @license MIT @@ -369,7 +369,7 @@ var result = formatMessage(message); message = result[0]; var isString = result[1]; - var code, index = 0, i, length = message.length, blocks = this.blocks; + var code, code2, index = 0, i, length = message.length, blocks = this.blocks; var buffer8 = this.buffer8; while (index < length) { @@ -395,12 +395,18 @@ buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) { + ++index; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); + } else { + // unpaired surrogate: U+FFFD + buffer8[i++] = 0xef; + buffer8[i++] = 0xbf; + buffer8[i++] = 0xbd; } } } else { @@ -415,12 +421,18 @@ blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) { + ++index; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + // unpaired surrogate: U+FFFD + blocks[i >>> 2] |= 0xef << SHIFT[i++ & 3]; + blocks[i >>> 2] |= 0xbf << SHIFT[i++ & 3]; + blocks[i >>> 2] |= 0xbd << SHIFT[i++ & 3]; } } } @@ -803,7 +815,7 @@ var i, result = formatMessage(key); key = result[0]; if (result[1]) { - var bytes = [], length = key.length, index = 0, code; + var bytes = [], length = key.length, index = 0, code, code2; for (i = 0; i < length; ++i) { code = key.charCodeAt(i); if (code < 0x80) { @@ -815,12 +827,18 @@ bytes[index++] = (0xe0 | (code >>> 12)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f)); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = key.charCodeAt(i + 1)) >= 0xdc00 && code2 < 0xe000) { + ++i; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); bytes[index++] = (0xf0 | (code >>> 18)); bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f)); + } else { + // unpaired surrogate: U+FFFD + bytes[index++] = 0xef; + bytes[index++] = 0xbf; + bytes[index++] = 0xbd; } } key = bytes; diff --git a/build/md5.min.js b/build/md5.min.js index c63e551..925ba9a 100644 --- a/build/md5.min.js +++ b/build/md5.min.js @@ -2,9 +2,9 @@ * [js-md5]{@link https://github.com/emn178/js-md5} * * @namespace md5 - * @version 0.9.2 + * @version 0.10.0 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2014-2026 * @license MIT */ -!function(){var t="input is invalid type",r="object"==typeof window,e=r?window:{};e.JS_MD5_NO_WINDOW&&(r=!1);var i="undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope,s=!e.JS_MD5_NO_NODE_JS&&!r&&"object"==typeof process&&process.versions&&process.versions.node;s?e=global:i&&(e=self);var h=!e.JS_MD5_NO_COMMON_JS&&"object"==typeof module&&module.exports,n="function"==typeof define&&define.amd,o=!e.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,a="0123456789abcdef".split(""),f=[128,32768,8388608,-2147483648],u=[0,8,16,24],c=["hex","array","digest","arrayBuffer"];c.push("buffer"),c.push("base64");var y,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),d=[];if(o){var l=new ArrayBuffer(68);y=new Uint8Array(l),d=new Uint32Array(l)}var b=Array.isArray;!e.JS_MD5_NO_NODE_JS&&b||(b=function(t){return"[object Array]"===Object.prototype.toString.call(t)});var v=ArrayBuffer.isView;!o||!e.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&v||(v=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});var w=function(r){var e=typeof r;if("string"===e)return[r,!0];if("object"!==e||null===r)throw new Error(t);if(o&&r.constructor===ArrayBuffer)return[new Uint8Array(r),!1];if(!b(r)&&!v(r))throw new Error(t);return[r,!1]},A=function(t){return function(r){return new g(!0).update(r)[t]()}},_=function(r){var i=require("crypto"),s=require("buffer").Buffer,h=s.from;!e.JS_MD5_NO_BUFFER_FROM&&h||(h=function(t){return new s(t)});return function(e){if("string"==typeof e)return i.createHash("md5").update(e,"utf8").digest("hex");if(null==e)throw new Error(t);return e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),b(e)||v(e)||e.constructor===s?i.createHash("md5").update(h(e)).digest("hex"):r(e)}},B=function(t){return function(r,e){return new S(r,!0).update(e)[t]()}};function g(t){if(t)d[0]=d[16]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0,this.blocks=d,this.buffer8=y;else if(o){var r=new ArrayBuffer(68);this.buffer8=new Uint8Array(r),this.blocks=new Uint32Array(r)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}function S(t,r){var e,i=w(t);if(t=i[0],i[1]){var s,h=[],n=t.length,o=0;for(e=0;e>>6,h[o++]=128|63&s):s<55296||s>=57344?(h[o++]=224|s>>>12,h[o++]=128|s>>>6&63,h[o++]=128|63&s):(s=65536+((1023&s)<<10|1023&t.charCodeAt(++e)),h[o++]=240|s>>>18,h[o++]=128|s>>>12&63,h[o++]=128|s>>>6&63,h[o++]=128|63&s);t=h}t.length>64&&(t=new g(!0).update(t).array());var a=[],f=[];for(e=0;e<64;++e){var u=t[e]||0;a[e]=92^u,f[e]=54^u}g.call(this,r),this.update(f),this.oKeyPad=a,this.inner=!0,this.sharedMemory=r}g.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r=w(t);t=r[0];for(var e,i,s=r[1],h=0,n=t.length,a=this.blocks,f=this.buffer8;h>>6,f[i++]=128|63&e):e<55296||e>=57344?(f[i++]=224|e>>>12,f[i++]=128|e>>>6&63,f[i++]=128|63&e):(e=65536+((1023&e)<<10|1023&t.charCodeAt(++h)),f[i++]=240|e>>>18,f[i++]=128|e>>>12&63,f[i++]=128|e>>>6&63,f[i++]=128|63&e);else for(i=this.start;h>>2]|=e<>>2]|=(192|e>>>6)<>>2]|=(128|63&e)<=57344?(a[i>>>2]|=(224|e>>>12)<>>2]|=(128|e>>>6&63)<>>2]|=(128|63&e)<>>2]|=(240|e>>>18)<>>2]|=(128|e>>>12&63)<>>2]|=(128|e>>>6&63)<>>2]|=(128|63&e)<>>2]|=t[h]<=64?(this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},g.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[r>>>2]|=f[3&r],r>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},g.prototype.hash=function(){var t,r,e,i,s,h,n=this.blocks;this.first?r=((r=((t=((t=n[0]-680876937)<<7|t>>>25)-271733879|0)^(e=((e=(-271733879^(i=((i=(-1732584194^2004318071&t)+n[1]-117830708)<<12|i>>>20)+t|0)&(-271733879^t))+n[2]-1126478375)<<17|e>>>15)+i|0)&(i^t))+n[3]-1316259209)<<22|r>>>10)+e|0:(t=this.h0,r=this.h1,e=this.h2,r=((r+=((t=((t+=((i=this.h3)^r&(e^i))+n[0]-680876936)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[1]-389564586)<<12|i>>>20)+t|0)&(t^r))+n[2]+606105819)<<17|e>>>15)+i|0)&(i^t))+n[3]-1044525330)<<22|r>>>10)+e|0),r=((r+=((t=((t+=(i^r&(e^i))+n[4]-176418897)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[5]+1200080426)<<12|i>>>20)+t|0)&(t^r))+n[6]-1473231341)<<17|e>>>15)+i|0)&(i^t))+n[7]-45705983)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+n[8]+1770035416)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[9]-1958414417)<<12|i>>>20)+t|0)&(t^r))+n[10]-42063)<<17|e>>>15)+i|0)&(i^t))+n[11]-1990404162)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+n[12]+1804603682)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[13]-40341101)<<12|i>>>20)+t|0)&(t^r))+n[14]-1502002290)<<17|e>>>15)+i|0)&(i^t))+n[15]+1236535329)<<22|r>>>10)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[1]-165796510)<<5|t>>>27)+r|0)^r))+n[6]-1069501632)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[11]+643717713)<<14|e>>>18)+i|0)^i))+n[0]-373897302)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[5]-701558691)<<5|t>>>27)+r|0)^r))+n[10]+38016083)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[15]-660478335)<<14|e>>>18)+i|0)^i))+n[4]-405537848)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[9]+568446438)<<5|t>>>27)+r|0)^r))+n[14]-1019803690)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[3]-187363961)<<14|e>>>18)+i|0)^i))+n[8]+1163531501)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[13]-1444681467)<<5|t>>>27)+r|0)^r))+n[2]-51403784)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[7]+1735328473)<<14|e>>>18)+i|0)^i))+n[12]-1926607734)<<20|r>>>12)+e|0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+n[5]-378558)<<4|t>>>28)+r|0))+n[8]-2022574463)<<11|i>>>21)+t|0)^t)^(e=((e+=(h^r)+n[11]+1839030562)<<16|e>>>16)+i|0))+n[14]-35309556)<<23|r>>>9)+e|0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+n[1]-1530992060)<<4|t>>>28)+r|0))+n[4]+1272893353)<<11|i>>>21)+t|0)^t)^(e=((e+=(h^r)+n[7]-155497632)<<16|e>>>16)+i|0))+n[10]-1094730640)<<23|r>>>9)+e|0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+n[13]+681279174)<<4|t>>>28)+r|0))+n[0]-358537222)<<11|i>>>21)+t|0)^t)^(e=((e+=(h^r)+n[3]-722521979)<<16|e>>>16)+i|0))+n[6]+76029189)<<23|r>>>9)+e|0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+n[9]-640364487)<<4|t>>>28)+r|0))+n[12]-421815835)<<11|i>>>21)+t|0)^t)^(e=((e+=(h^r)+n[15]+530742520)<<16|e>>>16)+i|0))+n[2]-995338651)<<23|r>>>9)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[0]-198630844)<<6|t>>>26)+r|0)|~e))+n[7]+1126891415)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[14]-1416354905)<<15|e>>>17)+i|0)|~t))+n[5]-57434055)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[12]+1700485571)<<6|t>>>26)+r|0)|~e))+n[3]-1894986606)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[10]-1051523)<<15|e>>>17)+i|0)|~t))+n[1]-2054922799)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[8]+1873313359)<<6|t>>>26)+r|0)|~e))+n[15]-30611744)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[6]-1560198380)<<15|e>>>17)+i|0)|~t))+n[13]+1309151649)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[4]-145523070)<<6|t>>>26)+r|0)|~e))+n[11]-1120210379)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[2]+718787259)<<15|e>>>17)+i|0)|~t))+n[9]-343485551)<<21|r>>>11)+e|0,this.first?(this.h0=t+1732584193|0,this.h1=r-271733879|0,this.h2=e-1732584194|0,this.h3=i+271733878|0,this.first=!1):(this.h0=this.h0+t|0,this.h1=this.h1+r|0,this.h2=this.h2+e|0,this.h3=this.h3+i|0)},g.prototype.hex=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return a[t>>>4&15]+a[15&t]+a[t>>>12&15]+a[t>>>8&15]+a[t>>>20&15]+a[t>>>16&15]+a[t>>>28&15]+a[t>>>24&15]+a[r>>>4&15]+a[15&r]+a[r>>>12&15]+a[r>>>8&15]+a[r>>>20&15]+a[r>>>16&15]+a[r>>>28&15]+a[r>>>24&15]+a[e>>>4&15]+a[15&e]+a[e>>>12&15]+a[e>>>8&15]+a[e>>>20&15]+a[e>>>16&15]+a[e>>>28&15]+a[e>>>24&15]+a[i>>>4&15]+a[15&i]+a[i>>>12&15]+a[i>>>8&15]+a[i>>>20&15]+a[i>>>16&15]+a[i>>>28&15]+a[i>>>24&15]},g.prototype.toString=g.prototype.hex,g.prototype.digest=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&i,i>>>8&255,i>>>16&255,i>>>24&255]},g.prototype.array=g.prototype.digest,g.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),r=new Uint32Array(t);return r[0]=this.h0,r[1]=this.h1,r[2]=this.h2,r[3]=this.h3,t},g.prototype.buffer=g.prototype.arrayBuffer,g.prototype.base64=function(){for(var t,r,e,i="",s=this.array(),h=0;h<15;)t=s[h++],r=s[h++],e=s[h++],i+=p[t>>>2]+p[63&(t<<4|r>>>4)]+p[63&(r<<2|e>>>6)]+p[63&e];return t=s[h],i+=p[t>>>2]+p[t<<4&63]+"=="},S.prototype=new g,S.prototype.finalize=function(){if(g.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();g.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),g.prototype.finalize.call(this)}};var O=function(){var t=A("hex");s&&(t=_(t)),t.create=function(){return new g},t.update=function(r){return t.create().update(r)};for(var r=0;r>>6,n[a++]=128|63&s):s<55296||s>=57344?(n[a++]=224|s>>>12,n[a++]=128|s>>>6&63,n[a++]=128|63&s):s<56320&&(h=t.charCodeAt(e+1))>=56320&&h<57344?(++e,s=65536+((1023&s)<<10|1023&h),n[a++]=240|s>>>18,n[a++]=128|s>>>12&63,n[a++]=128|s>>>6&63,n[a++]=128|63&s):(n[a++]=239,n[a++]=191,n[a++]=189);t=n}t.length>64&&(t=new g(!0).update(t).array());var f=[],u=[];for(e=0;e<64;++e){var c=t[e]||0;f[e]=92^c,u[e]=54^c}g.call(this,r),this.update(u),this.oKeyPad=f,this.inner=!0,this.sharedMemory=r}g.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r=w(t);t=r[0];for(var e,i,s,h=r[1],n=0,a=t.length,f=this.blocks,c=this.buffer8;n>>6,c[s++]=128|63&e):e<55296||e>=57344?(c[s++]=224|e>>>12,c[s++]=128|e>>>6&63,c[s++]=128|63&e):e<56320&&(i=t.charCodeAt(n+1))>=56320&&i<57344?(++n,e=65536+((1023&e)<<10|1023&i),c[s++]=240|e>>>18,c[s++]=128|e>>>12&63,c[s++]=128|e>>>6&63,c[s++]=128|63&e):(c[s++]=239,c[s++]=191,c[s++]=189);else for(s=this.start;n>>2]|=e<>>2]|=(192|e>>>6)<>>2]|=(128|63&e)<=57344?(f[s>>>2]|=(224|e>>>12)<>>2]|=(128|e>>>6&63)<>>2]|=(128|63&e)<=56320&&i<57344?(++n,e=65536+((1023&e)<<10|1023&i),f[s>>>2]|=(240|e>>>18)<>>2]|=(128|e>>>12&63)<>>2]|=(128|e>>>6&63)<>>2]|=(128|63&e)<>>2]|=239<>>2]|=191<>>2]|=189<>>2]|=t[n]<=64?(this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},g.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[r>>>2]|=f[3&r],r>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},g.prototype.hash=function(){var t,r,e,i,s,h,n=this.blocks;this.first?r=((r=((t=((t=n[0]-680876937)<<7|t>>>25)-271733879|0)^(e=((e=(-271733879^(i=((i=(-1732584194^2004318071&t)+n[1]-117830708)<<12|i>>>20)+t|0)&(-271733879^t))+n[2]-1126478375)<<17|e>>>15)+i|0)&(i^t))+n[3]-1316259209)<<22|r>>>10)+e|0:(t=this.h0,r=this.h1,e=this.h2,r=((r+=((t=((t+=((i=this.h3)^r&(e^i))+n[0]-680876936)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[1]-389564586)<<12|i>>>20)+t|0)&(t^r))+n[2]+606105819)<<17|e>>>15)+i|0)&(i^t))+n[3]-1044525330)<<22|r>>>10)+e|0),r=((r+=((t=((t+=(i^r&(e^i))+n[4]-176418897)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[5]+1200080426)<<12|i>>>20)+t|0)&(t^r))+n[6]-1473231341)<<17|e>>>15)+i|0)&(i^t))+n[7]-45705983)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+n[8]+1770035416)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[9]-1958414417)<<12|i>>>20)+t|0)&(t^r))+n[10]-42063)<<17|e>>>15)+i|0)&(i^t))+n[11]-1990404162)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+n[12]+1804603682)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[13]-40341101)<<12|i>>>20)+t|0)&(t^r))+n[14]-1502002290)<<17|e>>>15)+i|0)&(i^t))+n[15]+1236535329)<<22|r>>>10)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[1]-165796510)<<5|t>>>27)+r|0)^r))+n[6]-1069501632)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[11]+643717713)<<14|e>>>18)+i|0)^i))+n[0]-373897302)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[5]-701558691)<<5|t>>>27)+r|0)^r))+n[10]+38016083)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[15]-660478335)<<14|e>>>18)+i|0)^i))+n[4]-405537848)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[9]+568446438)<<5|t>>>27)+r|0)^r))+n[14]-1019803690)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[3]-187363961)<<14|e>>>18)+i|0)^i))+n[8]+1163531501)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[13]-1444681467)<<5|t>>>27)+r|0)^r))+n[2]-51403784)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[7]+1735328473)<<14|e>>>18)+i|0)^i))+n[12]-1926607734)<<20|r>>>12)+e|0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+n[5]-378558)<<4|t>>>28)+r|0))+n[8]-2022574463)<<11|i>>>21)+t|0)^t)^(e=((e+=(h^r)+n[11]+1839030562)<<16|e>>>16)+i|0))+n[14]-35309556)<<23|r>>>9)+e|0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+n[1]-1530992060)<<4|t>>>28)+r|0))+n[4]+1272893353)<<11|i>>>21)+t|0)^t)^(e=((e+=(h^r)+n[7]-155497632)<<16|e>>>16)+i|0))+n[10]-1094730640)<<23|r>>>9)+e|0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+n[13]+681279174)<<4|t>>>28)+r|0))+n[0]-358537222)<<11|i>>>21)+t|0)^t)^(e=((e+=(h^r)+n[3]-722521979)<<16|e>>>16)+i|0))+n[6]+76029189)<<23|r>>>9)+e|0,r=((r+=((h=(i=((i+=((s=r^e)^(t=((t+=(s^i)+n[9]-640364487)<<4|t>>>28)+r|0))+n[12]-421815835)<<11|i>>>21)+t|0)^t)^(e=((e+=(h^r)+n[15]+530742520)<<16|e>>>16)+i|0))+n[2]-995338651)<<23|r>>>9)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[0]-198630844)<<6|t>>>26)+r|0)|~e))+n[7]+1126891415)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[14]-1416354905)<<15|e>>>17)+i|0)|~t))+n[5]-57434055)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[12]+1700485571)<<6|t>>>26)+r|0)|~e))+n[3]-1894986606)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[10]-1051523)<<15|e>>>17)+i|0)|~t))+n[1]-2054922799)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[8]+1873313359)<<6|t>>>26)+r|0)|~e))+n[15]-30611744)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[6]-1560198380)<<15|e>>>17)+i|0)|~t))+n[13]+1309151649)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[4]-145523070)<<6|t>>>26)+r|0)|~e))+n[11]-1120210379)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[2]+718787259)<<15|e>>>17)+i|0)|~t))+n[9]-343485551)<<21|r>>>11)+e|0,this.first?(this.h0=t+1732584193|0,this.h1=r-271733879|0,this.h2=e-1732584194|0,this.h3=i+271733878|0,this.first=!1):(this.h0=this.h0+t|0,this.h1=this.h1+r|0,this.h2=this.h2+e|0,this.h3=this.h3+i|0)},g.prototype.hex=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return a[t>>>4&15]+a[15&t]+a[t>>>12&15]+a[t>>>8&15]+a[t>>>20&15]+a[t>>>16&15]+a[t>>>28&15]+a[t>>>24&15]+a[r>>>4&15]+a[15&r]+a[r>>>12&15]+a[r>>>8&15]+a[r>>>20&15]+a[r>>>16&15]+a[r>>>28&15]+a[r>>>24&15]+a[e>>>4&15]+a[15&e]+a[e>>>12&15]+a[e>>>8&15]+a[e>>>20&15]+a[e>>>16&15]+a[e>>>28&15]+a[e>>>24&15]+a[i>>>4&15]+a[15&i]+a[i>>>12&15]+a[i>>>8&15]+a[i>>>20&15]+a[i>>>16&15]+a[i>>>28&15]+a[i>>>24&15]},g.prototype.toString=g.prototype.hex,g.prototype.digest=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&i,i>>>8&255,i>>>16&255,i>>>24&255]},g.prototype.array=g.prototype.digest,g.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),r=new Uint32Array(t);return r[0]=this.h0,r[1]=this.h1,r[2]=this.h2,r[3]=this.h3,t},g.prototype.buffer=g.prototype.arrayBuffer,g.prototype.base64=function(){for(var t,r,e,i="",s=this.array(),h=0;h<15;)t=s[h++],r=s[h++],e=s[h++],i+=p[t>>>2]+p[63&(t<<4|r>>>4)]+p[63&(r<<2|e>>>6)]+p[63&e];return t=s[h],i+=p[t>>>2]+p[t<<4&63]+"=="},S.prototype=new g,S.prototype.finalize=function(){if(g.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();g.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),g.prototype.finalize.call(this)}};var O=function(){var t=A("hex");s&&(t=_(t)),t.create=function(){return new g},t.update=function(r){return t.create().update(r)};for(var r=0;r>>6,s[n++]=128|63&h):h<55296||h>=57344?(s[n++]=224|h>>>12,s[n++]=128|h>>>6&63,s[n++]=128|63&h):(h=65536+((1023&h)<<10|1023&t.charCodeAt(++e)),s[n++]=240|h>>>18,s[n++]=128|h>>>12&63,s[n++]=128|h>>>6&63,s[n++]=128|63&h);t=s}t.length>64&&(t=new A(!0).update(t).array());var o=[],f=[];for(e=0;e<64;++e){var u=t[e]||0;o[e]=92^u,f[e]=54^u}A.call(this,r),this.update(f),this.oKeyPad=o,this.inner=!0,this.sharedMemory=r}A.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r=b(t);t=r[0];for(var e,i,h=r[1],a=0,n=t.length,f=this.blocks,u=this.buffer8;a>>6,u[i++]=128|63&e):e<55296||e>=57344?(u[i++]=224|e>>>12,u[i++]=128|e>>>6&63,u[i++]=128|63&e):(e=65536+((1023&e)<<10|1023&t.charCodeAt(++a)),u[i++]=240|e>>>18,u[i++]=128|e>>>12&63,u[i++]=128|e>>>6&63,u[i++]=128|63&e);else for(i=this.start;a>>2]|=e<>>2]|=(192|e>>>6)<>>2]|=(128|63&e)<=57344?(f[i>>>2]|=(224|e>>>12)<>>2]|=(128|e>>>6&63)<>>2]|=(128|63&e)<>>2]|=(240|e>>>18)<>>2]|=(128|e>>>12&63)<>>2]|=(128|e>>>6&63)<>>2]|=(128|63&e)<>>2]|=t[a]<=64?(this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},A.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[r>>>2]|=n[3&r],r>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},A.prototype.hash=function(){var t,r,e,i,h,s,a=this.blocks;this.first?r=((r=((t=((t=a[0]-680876937)<<7|t>>>25)-271733879|0)^(e=((e=(-271733879^(i=((i=(-1732584194^2004318071&t)+a[1]-117830708)<<12|i>>>20)+t|0)&(-271733879^t))+a[2]-1126478375)<<17|e>>>15)+i|0)&(i^t))+a[3]-1316259209)<<22|r>>>10)+e|0:(t=this.h0,r=this.h1,e=this.h2,r=((r+=((t=((t+=((i=this.h3)^r&(e^i))+a[0]-680876936)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[1]-389564586)<<12|i>>>20)+t|0)&(t^r))+a[2]+606105819)<<17|e>>>15)+i|0)&(i^t))+a[3]-1044525330)<<22|r>>>10)+e|0),r=((r+=((t=((t+=(i^r&(e^i))+a[4]-176418897)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[5]+1200080426)<<12|i>>>20)+t|0)&(t^r))+a[6]-1473231341)<<17|e>>>15)+i|0)&(i^t))+a[7]-45705983)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+a[8]+1770035416)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[9]-1958414417)<<12|i>>>20)+t|0)&(t^r))+a[10]-42063)<<17|e>>>15)+i|0)&(i^t))+a[11]-1990404162)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+a[12]+1804603682)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[13]-40341101)<<12|i>>>20)+t|0)&(t^r))+a[14]-1502002290)<<17|e>>>15)+i|0)&(i^t))+a[15]+1236535329)<<22|r>>>10)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[1]-165796510)<<5|t>>>27)+r|0)^r))+a[6]-1069501632)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[11]+643717713)<<14|e>>>18)+i|0)^i))+a[0]-373897302)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[5]-701558691)<<5|t>>>27)+r|0)^r))+a[10]+38016083)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[15]-660478335)<<14|e>>>18)+i|0)^i))+a[4]-405537848)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[9]+568446438)<<5|t>>>27)+r|0)^r))+a[14]-1019803690)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[3]-187363961)<<14|e>>>18)+i|0)^i))+a[8]+1163531501)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[13]-1444681467)<<5|t>>>27)+r|0)^r))+a[2]-51403784)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[7]+1735328473)<<14|e>>>18)+i|0)^i))+a[12]-1926607734)<<20|r>>>12)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[5]-378558)<<4|t>>>28)+r|0))+a[8]-2022574463)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[11]+1839030562)<<16|e>>>16)+i|0))+a[14]-35309556)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[1]-1530992060)<<4|t>>>28)+r|0))+a[4]+1272893353)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[7]-155497632)<<16|e>>>16)+i|0))+a[10]-1094730640)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[13]+681279174)<<4|t>>>28)+r|0))+a[0]-358537222)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[3]-722521979)<<16|e>>>16)+i|0))+a[6]+76029189)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[9]-640364487)<<4|t>>>28)+r|0))+a[12]-421815835)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[15]+530742520)<<16|e>>>16)+i|0))+a[2]-995338651)<<23|r>>>9)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[0]-198630844)<<6|t>>>26)+r|0)|~e))+a[7]+1126891415)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[14]-1416354905)<<15|e>>>17)+i|0)|~t))+a[5]-57434055)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[12]+1700485571)<<6|t>>>26)+r|0)|~e))+a[3]-1894986606)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[10]-1051523)<<15|e>>>17)+i|0)|~t))+a[1]-2054922799)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[8]+1873313359)<<6|t>>>26)+r|0)|~e))+a[15]-30611744)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[6]-1560198380)<<15|e>>>17)+i|0)|~t))+a[13]+1309151649)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[4]-145523070)<<6|t>>>26)+r|0)|~e))+a[11]-1120210379)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[2]+718787259)<<15|e>>>17)+i|0)|~t))+a[9]-343485551)<<21|r>>>11)+e|0,this.first?(this.h0=t+1732584193|0,this.h1=r-271733879|0,this.h2=e-1732584194|0,this.h3=i+271733878|0,this.first=!1):(this.h0=this.h0+t|0,this.h1=this.h1+r|0,this.h2=this.h2+e|0,this.h3=this.h3+i|0)},A.prototype.hex=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return a[t>>>4&15]+a[15&t]+a[t>>>12&15]+a[t>>>8&15]+a[t>>>20&15]+a[t>>>16&15]+a[t>>>28&15]+a[t>>>24&15]+a[r>>>4&15]+a[15&r]+a[r>>>12&15]+a[r>>>8&15]+a[r>>>20&15]+a[r>>>16&15]+a[r>>>28&15]+a[r>>>24&15]+a[e>>>4&15]+a[15&e]+a[e>>>12&15]+a[e>>>8&15]+a[e>>>20&15]+a[e>>>16&15]+a[e>>>28&15]+a[e>>>24&15]+a[i>>>4&15]+a[15&i]+a[i>>>12&15]+a[i>>>8&15]+a[i>>>20&15]+a[i>>>16&15]+a[i>>>28&15]+a[i>>>24&15]},A.prototype.toString=A.prototype.hex,A.prototype.digest=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&i,i>>>8&255,i>>>16&255,i>>>24&255]},A.prototype.array=A.prototype.digest,A.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),r=new Uint32Array(t);return r[0]=this.h0,r[1]=this.h1,r[2]=this.h2,r[3]=this.h3,t},A.prototype.buffer=A.prototype.arrayBuffer,A.prototype.base64=function(){for(var t,r,e,i="",h=this.array(),s=0;s<15;)t=h[s++],r=h[s++],e=h[s++],i+=p[t>>>2]+p[63&(t<<4|r>>>4)]+p[63&(r<<2|e>>>6)]+p[63&e];return t=h[s],i+=p[t>>>2]+p[t<<4&63]+"=="},_.prototype=new A,_.prototype.finalize=function(){if(A.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();A.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),A.prototype.finalize.call(this)}};var B=function(){var t=v("hex");t.create=function(){return new A},t.update=function(r){return t.create().update(r)};for(var r=0;r>>6,a[o++]=128|63&h):h<55296||h>=57344?(a[o++]=224|h>>>12,a[o++]=128|h>>>6&63,a[o++]=128|63&h):h<56320&&(s=t.charCodeAt(e+1))>=56320&&s<57344?(++e,h=65536+((1023&h)<<10|1023&s),a[o++]=240|h>>>18,a[o++]=128|h>>>12&63,a[o++]=128|h>>>6&63,a[o++]=128|63&h):(a[o++]=239,a[o++]=191,a[o++]=189);t=a}t.length>64&&(t=new A(!0).update(t).array());var f=[],u=[];for(e=0;e<64;++e){var p=t[e]||0;f[e]=92^p,u[e]=54^p}A.call(this,r),this.update(u),this.oKeyPad=f,this.inner=!0,this.sharedMemory=r}A.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r=b(t);t=r[0];for(var e,i,h,a=r[1],n=0,f=t.length,u=this.blocks,p=this.buffer8;n>>6,p[h++]=128|63&e):e<55296||e>=57344?(p[h++]=224|e>>>12,p[h++]=128|e>>>6&63,p[h++]=128|63&e):e<56320&&(i=t.charCodeAt(n+1))>=56320&&i<57344?(++n,e=65536+((1023&e)<<10|1023&i),p[h++]=240|e>>>18,p[h++]=128|e>>>12&63,p[h++]=128|e>>>6&63,p[h++]=128|63&e):(p[h++]=239,p[h++]=191,p[h++]=189);else for(h=this.start;n>>2]|=e<>>2]|=(192|e>>>6)<>>2]|=(128|63&e)<=57344?(u[h>>>2]|=(224|e>>>12)<>>2]|=(128|e>>>6&63)<>>2]|=(128|63&e)<=56320&&i<57344?(++n,e=65536+((1023&e)<<10|1023&i),u[h>>>2]|=(240|e>>>18)<>>2]|=(128|e>>>12&63)<>>2]|=(128|e>>>6&63)<>>2]|=(128|63&e)<>>2]|=239<>>2]|=191<>>2]|=189<>>2]|=t[n]<=64?(this.start=h-64,this.hash(),this.hashed=!0):this.start=h}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},A.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[r>>>2]|=n[3&r],r>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},A.prototype.hash=function(){var t,r,e,i,h,s,a=this.blocks;this.first?r=((r=((t=((t=a[0]-680876937)<<7|t>>>25)-271733879|0)^(e=((e=(-271733879^(i=((i=(-1732584194^2004318071&t)+a[1]-117830708)<<12|i>>>20)+t|0)&(-271733879^t))+a[2]-1126478375)<<17|e>>>15)+i|0)&(i^t))+a[3]-1316259209)<<22|r>>>10)+e|0:(t=this.h0,r=this.h1,e=this.h2,r=((r+=((t=((t+=((i=this.h3)^r&(e^i))+a[0]-680876936)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[1]-389564586)<<12|i>>>20)+t|0)&(t^r))+a[2]+606105819)<<17|e>>>15)+i|0)&(i^t))+a[3]-1044525330)<<22|r>>>10)+e|0),r=((r+=((t=((t+=(i^r&(e^i))+a[4]-176418897)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[5]+1200080426)<<12|i>>>20)+t|0)&(t^r))+a[6]-1473231341)<<17|e>>>15)+i|0)&(i^t))+a[7]-45705983)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+a[8]+1770035416)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[9]-1958414417)<<12|i>>>20)+t|0)&(t^r))+a[10]-42063)<<17|e>>>15)+i|0)&(i^t))+a[11]-1990404162)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+a[12]+1804603682)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[13]-40341101)<<12|i>>>20)+t|0)&(t^r))+a[14]-1502002290)<<17|e>>>15)+i|0)&(i^t))+a[15]+1236535329)<<22|r>>>10)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[1]-165796510)<<5|t>>>27)+r|0)^r))+a[6]-1069501632)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[11]+643717713)<<14|e>>>18)+i|0)^i))+a[0]-373897302)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[5]-701558691)<<5|t>>>27)+r|0)^r))+a[10]+38016083)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[15]-660478335)<<14|e>>>18)+i|0)^i))+a[4]-405537848)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[9]+568446438)<<5|t>>>27)+r|0)^r))+a[14]-1019803690)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[3]-187363961)<<14|e>>>18)+i|0)^i))+a[8]+1163531501)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[13]-1444681467)<<5|t>>>27)+r|0)^r))+a[2]-51403784)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[7]+1735328473)<<14|e>>>18)+i|0)^i))+a[12]-1926607734)<<20|r>>>12)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[5]-378558)<<4|t>>>28)+r|0))+a[8]-2022574463)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[11]+1839030562)<<16|e>>>16)+i|0))+a[14]-35309556)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[1]-1530992060)<<4|t>>>28)+r|0))+a[4]+1272893353)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[7]-155497632)<<16|e>>>16)+i|0))+a[10]-1094730640)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[13]+681279174)<<4|t>>>28)+r|0))+a[0]-358537222)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[3]-722521979)<<16|e>>>16)+i|0))+a[6]+76029189)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[9]-640364487)<<4|t>>>28)+r|0))+a[12]-421815835)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[15]+530742520)<<16|e>>>16)+i|0))+a[2]-995338651)<<23|r>>>9)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[0]-198630844)<<6|t>>>26)+r|0)|~e))+a[7]+1126891415)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[14]-1416354905)<<15|e>>>17)+i|0)|~t))+a[5]-57434055)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[12]+1700485571)<<6|t>>>26)+r|0)|~e))+a[3]-1894986606)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[10]-1051523)<<15|e>>>17)+i|0)|~t))+a[1]-2054922799)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[8]+1873313359)<<6|t>>>26)+r|0)|~e))+a[15]-30611744)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[6]-1560198380)<<15|e>>>17)+i|0)|~t))+a[13]+1309151649)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[4]-145523070)<<6|t>>>26)+r|0)|~e))+a[11]-1120210379)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[2]+718787259)<<15|e>>>17)+i|0)|~t))+a[9]-343485551)<<21|r>>>11)+e|0,this.first?(this.h0=t+1732584193|0,this.h1=r-271733879|0,this.h2=e-1732584194|0,this.h3=i+271733878|0,this.first=!1):(this.h0=this.h0+t|0,this.h1=this.h1+r|0,this.h2=this.h2+e|0,this.h3=this.h3+i|0)},A.prototype.hex=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return a[t>>>4&15]+a[15&t]+a[t>>>12&15]+a[t>>>8&15]+a[t>>>20&15]+a[t>>>16&15]+a[t>>>28&15]+a[t>>>24&15]+a[r>>>4&15]+a[15&r]+a[r>>>12&15]+a[r>>>8&15]+a[r>>>20&15]+a[r>>>16&15]+a[r>>>28&15]+a[r>>>24&15]+a[e>>>4&15]+a[15&e]+a[e>>>12&15]+a[e>>>8&15]+a[e>>>20&15]+a[e>>>16&15]+a[e>>>28&15]+a[e>>>24&15]+a[i>>>4&15]+a[15&i]+a[i>>>12&15]+a[i>>>8&15]+a[i>>>20&15]+a[i>>>16&15]+a[i>>>28&15]+a[i>>>24&15]},A.prototype.toString=A.prototype.hex,A.prototype.digest=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&i,i>>>8&255,i>>>16&255,i>>>24&255]},A.prototype.array=A.prototype.digest,A.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),r=new Uint32Array(t);return r[0]=this.h0,r[1]=this.h1,r[2]=this.h2,r[3]=this.h3,t},A.prototype.buffer=A.prototype.arrayBuffer,A.prototype.base64=function(){for(var t,r,e,i="",h=this.array(),s=0;s<15;)t=h[s++],r=h[s++],e=h[s++],i+=p[t>>>2]+p[63&(t<<4|r>>>4)]+p[63&(r<<2|e>>>6)]+p[63&e];return t=h[s],i+=p[t>>>2]+p[t<<4&63]+"=="},_.prototype=new A,_.prototype.finalize=function(){if(A.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();A.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),A.prototype.finalize.call(this)}};var B=function(){var t=v("hex");t.create=function(){return new A},t.update=function(r){return t.create().update(r)};for(var r=0;r>> 12); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) { + ++index; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); + } else { + // unpaired surrogate: U+FFFD + buffer8[i++] = 0xef; + buffer8[i++] = 0xbf; + buffer8[i++] = 0xbd; } } } else { @@ -386,12 +392,18 @@ var md5$1 = {exports: {}}; blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) { + ++index; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + // unpaired surrogate: U+FFFD + blocks[i >>> 2] |= 0xef << SHIFT[i++ & 3]; + blocks[i >>> 2] |= 0xbf << SHIFT[i++ & 3]; + blocks[i >>> 2] |= 0xbd << SHIFT[i++ & 3]; } } } @@ -774,7 +786,7 @@ var md5$1 = {exports: {}}; var i, result = formatMessage(key); key = result[0]; if (result[1]) { - var bytes = [], length = key.length, index = 0, code; + var bytes = [], length = key.length, index = 0, code, code2; for (i = 0; i < length; ++i) { code = key.charCodeAt(i); if (code < 0x80) { @@ -786,12 +798,18 @@ var md5$1 = {exports: {}}; bytes[index++] = (0xe0 | (code >>> 12)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f)); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = key.charCodeAt(i + 1)) >= 0xdc00 && code2 < 0xe000) { + ++i; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); bytes[index++] = (0xf0 | (code >>> 18)); bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f)); + } else { + // unpaired surrogate: U+FFFD + bytes[index++] = 0xef; + bytes[index++] = 0xbf; + bytes[index++] = 0xbd; } } key = bytes; diff --git a/build/md5.modern.js b/build/md5.modern.js index 0b321cc..a8ed9fc 100644 --- a/build/md5.modern.js +++ b/build/md5.modern.js @@ -2,7 +2,7 @@ * [js-md5]{@link https://github.com/emn178/js-md5} * * @namespace md5 - * @version 0.9.2 + * @version 0.10.0 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2014-2026 * @license MIT @@ -347,7 +347,7 @@ var result = formatMessage(message); message = result[0]; var isString = result[1]; - var code, index = 0, i, length = message.length, blocks = this.blocks; + var code, code2, index = 0, i, length = message.length, blocks = this.blocks; var buffer8 = this.buffer8; while (index < length) { @@ -373,12 +373,18 @@ buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) { + ++index; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); + } else { + // unpaired surrogate: U+FFFD + buffer8[i++] = 0xef; + buffer8[i++] = 0xbf; + buffer8[i++] = 0xbd; } } } @@ -757,7 +763,7 @@ var i, result = formatMessage(key); key = result[0]; if (result[1]) { - var bytes = [], length = key.length, index = 0, code; + var bytes = [], length = key.length, index = 0, code, code2; for (i = 0; i < length; ++i) { code = key.charCodeAt(i); if (code < 0x80) { @@ -769,12 +775,18 @@ bytes[index++] = (0xe0 | (code >>> 12)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f)); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = key.charCodeAt(i + 1)) >= 0xdc00 && code2 < 0xe000) { + ++i; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); bytes[index++] = (0xf0 | (code >>> 18)); bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f)); + } else { + // unpaired surrogate: U+FFFD + bytes[index++] = 0xef; + bytes[index++] = 0xbf; + bytes[index++] = 0xbd; } } key = bytes; diff --git a/build/md5.modern.min.js b/build/md5.modern.min.js index 2860c04..6226932 100644 --- a/build/md5.modern.min.js +++ b/build/md5.modern.min.js @@ -2,9 +2,9 @@ * [js-md5]{@link https://github.com/emn178/js-md5} * * @namespace md5 - * @version 0.9.2 + * @version 0.10.0 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2014-2026 * @license MIT */ -!function(){var t="input is invalid type",r="object"==typeof window,e=r?window:{};e.JS_MD5_NO_WINDOW&&(r=!1);var i="undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope,h=!e.JS_MD5_NO_NODE_JS&&!r&&"object"==typeof process&&process.versions&&process.versions.node;h?e=global:i&&(e=self);var s=!e.JS_MD5_NO_COMMON_JS&&"object"==typeof module&&module.exports,n="function"==typeof define&&define.amd,a="0123456789abcdef".split(""),o=[128,32768,8388608,-2147483648],f=["hex","array","digest","arrayBuffer"];f.push("buffer"),f.push("base64");var u,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),y=[],c=new ArrayBuffer(68);u=new Uint8Array(c),y=new Uint32Array(c);var d=Array.isArray,l=ArrayBuffer.isView,v=function(r){var e=typeof r;if("string"===e)return[r,!0];if("object"!==e||null===r)throw new Error(t);if(r.constructor===ArrayBuffer)return[new Uint8Array(r),!1];if(!d(r)&&!l(r))throw new Error(t);return[r,!1]},b=function(t){return function(r){return new B(!0).update(r)[t]()}},w=function(r){var e=require("crypto"),i=require("buffer").Buffer,h=i.from;return function(s){if("string"==typeof s)return e.createHash("md5").update(s,"utf8").digest("hex");if(null==s)throw new Error(t);return s.constructor===ArrayBuffer&&(s=new Uint8Array(s)),d(s)||l(s)||s.constructor===i?e.createHash("md5").update(h(s)).digest("hex"):r(s)}},A=function(t){return function(r,e){return new g(r,!0).update(e)[t]()}};function B(t){if(t)y[0]=y[16]=y[1]=y[2]=y[3]=y[4]=y[5]=y[6]=y[7]=y[8]=y[9]=y[10]=y[11]=y[12]=y[13]=y[14]=y[15]=0,this.blocks=y,this.buffer8=u;else{var r=new ArrayBuffer(68);this.buffer8=new Uint8Array(r),this.blocks=new Uint32Array(r)}this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}function g(t,r){var e,i=v(t);if(t=i[0],i[1]){var h,s=[],n=t.length,a=0;for(e=0;e>>6,s[a++]=128|63&h):h<55296||h>=57344?(s[a++]=224|h>>>12,s[a++]=128|h>>>6&63,s[a++]=128|63&h):(h=65536+((1023&h)<<10|1023&t.charCodeAt(++e)),s[a++]=240|h>>>18,s[a++]=128|h>>>12&63,s[a++]=128|h>>>6&63,s[a++]=128|63&h);t=s}t.length>64&&(t=new B(!0).update(t).array());var o=[],f=[];for(e=0;e<64;++e){var u=t[e]||0;o[e]=92^u,f[e]=54^u}B.call(this,r),this.update(f),this.oKeyPad=o,this.inner=!0,this.sharedMemory=r}B.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r=v(t);t=r[0];for(var e,i,h=r[1],s=0,n=t.length,a=this.blocks,o=this.buffer8;s>>6,o[i++]=128|63&e):e<55296||e>=57344?(o[i++]=224|e>>>12,o[i++]=128|e>>>6&63,o[i++]=128|63&e):(e=65536+((1023&e)<<10|1023&t.charCodeAt(++s)),o[i++]=240|e>>>18,o[i++]=128|e>>>12&63,o[i++]=128|e>>>6&63,o[i++]=128|63&e);else for(i=this.start;s=64?(this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},B.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[r>>>2]|=o[3&r],r>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},B.prototype.hash=function(){var t,r,e,i,h,s,n=this.blocks;this.first?r=((r=((t=((t=n[0]-680876937)<<7|t>>>25)-271733879|0)^(e=((e=(-271733879^(i=((i=(-1732584194^2004318071&t)+n[1]-117830708)<<12|i>>>20)+t|0)&(-271733879^t))+n[2]-1126478375)<<17|e>>>15)+i|0)&(i^t))+n[3]-1316259209)<<22|r>>>10)+e|0:(t=this.h0,r=this.h1,e=this.h2,r=((r+=((t=((t+=((i=this.h3)^r&(e^i))+n[0]-680876936)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[1]-389564586)<<12|i>>>20)+t|0)&(t^r))+n[2]+606105819)<<17|e>>>15)+i|0)&(i^t))+n[3]-1044525330)<<22|r>>>10)+e|0),r=((r+=((t=((t+=(i^r&(e^i))+n[4]-176418897)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[5]+1200080426)<<12|i>>>20)+t|0)&(t^r))+n[6]-1473231341)<<17|e>>>15)+i|0)&(i^t))+n[7]-45705983)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+n[8]+1770035416)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[9]-1958414417)<<12|i>>>20)+t|0)&(t^r))+n[10]-42063)<<17|e>>>15)+i|0)&(i^t))+n[11]-1990404162)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+n[12]+1804603682)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[13]-40341101)<<12|i>>>20)+t|0)&(t^r))+n[14]-1502002290)<<17|e>>>15)+i|0)&(i^t))+n[15]+1236535329)<<22|r>>>10)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[1]-165796510)<<5|t>>>27)+r|0)^r))+n[6]-1069501632)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[11]+643717713)<<14|e>>>18)+i|0)^i))+n[0]-373897302)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[5]-701558691)<<5|t>>>27)+r|0)^r))+n[10]+38016083)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[15]-660478335)<<14|e>>>18)+i|0)^i))+n[4]-405537848)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[9]+568446438)<<5|t>>>27)+r|0)^r))+n[14]-1019803690)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[3]-187363961)<<14|e>>>18)+i|0)^i))+n[8]+1163531501)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[13]-1444681467)<<5|t>>>27)+r|0)^r))+n[2]-51403784)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[7]+1735328473)<<14|e>>>18)+i|0)^i))+n[12]-1926607734)<<20|r>>>12)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+n[5]-378558)<<4|t>>>28)+r|0))+n[8]-2022574463)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+n[11]+1839030562)<<16|e>>>16)+i|0))+n[14]-35309556)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+n[1]-1530992060)<<4|t>>>28)+r|0))+n[4]+1272893353)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+n[7]-155497632)<<16|e>>>16)+i|0))+n[10]-1094730640)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+n[13]+681279174)<<4|t>>>28)+r|0))+n[0]-358537222)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+n[3]-722521979)<<16|e>>>16)+i|0))+n[6]+76029189)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+n[9]-640364487)<<4|t>>>28)+r|0))+n[12]-421815835)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+n[15]+530742520)<<16|e>>>16)+i|0))+n[2]-995338651)<<23|r>>>9)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[0]-198630844)<<6|t>>>26)+r|0)|~e))+n[7]+1126891415)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[14]-1416354905)<<15|e>>>17)+i|0)|~t))+n[5]-57434055)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[12]+1700485571)<<6|t>>>26)+r|0)|~e))+n[3]-1894986606)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[10]-1051523)<<15|e>>>17)+i|0)|~t))+n[1]-2054922799)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[8]+1873313359)<<6|t>>>26)+r|0)|~e))+n[15]-30611744)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[6]-1560198380)<<15|e>>>17)+i|0)|~t))+n[13]+1309151649)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[4]-145523070)<<6|t>>>26)+r|0)|~e))+n[11]-1120210379)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[2]+718787259)<<15|e>>>17)+i|0)|~t))+n[9]-343485551)<<21|r>>>11)+e|0,this.first?(this.h0=t+1732584193|0,this.h1=r-271733879|0,this.h2=e-1732584194|0,this.h3=i+271733878|0,this.first=!1):(this.h0=this.h0+t|0,this.h1=this.h1+r|0,this.h2=this.h2+e|0,this.h3=this.h3+i|0)},B.prototype.hex=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return a[t>>>4&15]+a[15&t]+a[t>>>12&15]+a[t>>>8&15]+a[t>>>20&15]+a[t>>>16&15]+a[t>>>28&15]+a[t>>>24&15]+a[r>>>4&15]+a[15&r]+a[r>>>12&15]+a[r>>>8&15]+a[r>>>20&15]+a[r>>>16&15]+a[r>>>28&15]+a[r>>>24&15]+a[e>>>4&15]+a[15&e]+a[e>>>12&15]+a[e>>>8&15]+a[e>>>20&15]+a[e>>>16&15]+a[e>>>28&15]+a[e>>>24&15]+a[i>>>4&15]+a[15&i]+a[i>>>12&15]+a[i>>>8&15]+a[i>>>20&15]+a[i>>>16&15]+a[i>>>28&15]+a[i>>>24&15]},B.prototype.toString=B.prototype.hex,B.prototype.digest=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&i,i>>>8&255,i>>>16&255,i>>>24&255]},B.prototype.array=B.prototype.digest,B.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),r=new Uint32Array(t);return r[0]=this.h0,r[1]=this.h1,r[2]=this.h2,r[3]=this.h3,t},B.prototype.buffer=B.prototype.arrayBuffer,B.prototype.base64=function(){for(var t,r,e,i="",h=this.array(),s=0;s<15;)t=h[s++],r=h[s++],e=h[s++],i+=p[t>>>2]+p[63&(t<<4|r>>>4)]+p[63&(r<<2|e>>>6)]+p[63&e];return t=h[s],i+=p[t>>>2]+p[t<<4&63]+"=="},g.prototype=new B,g.prototype.finalize=function(){if(B.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();B.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),B.prototype.finalize.call(this)}};var m=function(){var t=b("hex");h&&(t=w(t)),t.create=function(){return new B},t.update=function(r){return t.create().update(r)};for(var r=0;r>>6,n[o++]=128|63&h):h<55296||h>=57344?(n[o++]=224|h>>>12,n[o++]=128|h>>>6&63,n[o++]=128|63&h):h<56320&&(s=t.charCodeAt(e+1))>=56320&&s<57344?(++e,h=65536+((1023&h)<<10|1023&s),n[o++]=240|h>>>18,n[o++]=128|h>>>12&63,n[o++]=128|h>>>6&63,n[o++]=128|63&h):(n[o++]=239,n[o++]=191,n[o++]=189);t=n}t.length>64&&(t=new B(!0).update(t).array());var f=[],u=[];for(e=0;e<64;++e){var p=t[e]||0;f[e]=92^p,u[e]=54^p}B.call(this,r),this.update(u),this.oKeyPad=f,this.inner=!0,this.sharedMemory=r}B.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r=v(t);t=r[0];for(var e,i,h,s=r[1],n=0,a=t.length,o=this.blocks,f=this.buffer8;n>>6,f[h++]=128|63&e):e<55296||e>=57344?(f[h++]=224|e>>>12,f[h++]=128|e>>>6&63,f[h++]=128|63&e):e<56320&&(i=t.charCodeAt(n+1))>=56320&&i<57344?(++n,e=65536+((1023&e)<<10|1023&i),f[h++]=240|e>>>18,f[h++]=128|e>>>12&63,f[h++]=128|e>>>6&63,f[h++]=128|63&e):(f[h++]=239,f[h++]=191,f[h++]=189);else for(h=this.start;n=64?(this.start=h-64,this.hash(),this.hashed=!0):this.start=h}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},B.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[r>>>2]|=o[3&r],r>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},B.prototype.hash=function(){var t,r,e,i,h,s,n=this.blocks;this.first?r=((r=((t=((t=n[0]-680876937)<<7|t>>>25)-271733879|0)^(e=((e=(-271733879^(i=((i=(-1732584194^2004318071&t)+n[1]-117830708)<<12|i>>>20)+t|0)&(-271733879^t))+n[2]-1126478375)<<17|e>>>15)+i|0)&(i^t))+n[3]-1316259209)<<22|r>>>10)+e|0:(t=this.h0,r=this.h1,e=this.h2,r=((r+=((t=((t+=((i=this.h3)^r&(e^i))+n[0]-680876936)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[1]-389564586)<<12|i>>>20)+t|0)&(t^r))+n[2]+606105819)<<17|e>>>15)+i|0)&(i^t))+n[3]-1044525330)<<22|r>>>10)+e|0),r=((r+=((t=((t+=(i^r&(e^i))+n[4]-176418897)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[5]+1200080426)<<12|i>>>20)+t|0)&(t^r))+n[6]-1473231341)<<17|e>>>15)+i|0)&(i^t))+n[7]-45705983)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+n[8]+1770035416)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[9]-1958414417)<<12|i>>>20)+t|0)&(t^r))+n[10]-42063)<<17|e>>>15)+i|0)&(i^t))+n[11]-1990404162)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+n[12]+1804603682)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+n[13]-40341101)<<12|i>>>20)+t|0)&(t^r))+n[14]-1502002290)<<17|e>>>15)+i|0)&(i^t))+n[15]+1236535329)<<22|r>>>10)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[1]-165796510)<<5|t>>>27)+r|0)^r))+n[6]-1069501632)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[11]+643717713)<<14|e>>>18)+i|0)^i))+n[0]-373897302)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[5]-701558691)<<5|t>>>27)+r|0)^r))+n[10]+38016083)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[15]-660478335)<<14|e>>>18)+i|0)^i))+n[4]-405537848)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[9]+568446438)<<5|t>>>27)+r|0)^r))+n[14]-1019803690)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[3]-187363961)<<14|e>>>18)+i|0)^i))+n[8]+1163531501)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+n[13]-1444681467)<<5|t>>>27)+r|0)^r))+n[2]-51403784)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+n[7]+1735328473)<<14|e>>>18)+i|0)^i))+n[12]-1926607734)<<20|r>>>12)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+n[5]-378558)<<4|t>>>28)+r|0))+n[8]-2022574463)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+n[11]+1839030562)<<16|e>>>16)+i|0))+n[14]-35309556)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+n[1]-1530992060)<<4|t>>>28)+r|0))+n[4]+1272893353)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+n[7]-155497632)<<16|e>>>16)+i|0))+n[10]-1094730640)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+n[13]+681279174)<<4|t>>>28)+r|0))+n[0]-358537222)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+n[3]-722521979)<<16|e>>>16)+i|0))+n[6]+76029189)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+n[9]-640364487)<<4|t>>>28)+r|0))+n[12]-421815835)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+n[15]+530742520)<<16|e>>>16)+i|0))+n[2]-995338651)<<23|r>>>9)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[0]-198630844)<<6|t>>>26)+r|0)|~e))+n[7]+1126891415)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[14]-1416354905)<<15|e>>>17)+i|0)|~t))+n[5]-57434055)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[12]+1700485571)<<6|t>>>26)+r|0)|~e))+n[3]-1894986606)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[10]-1051523)<<15|e>>>17)+i|0)|~t))+n[1]-2054922799)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[8]+1873313359)<<6|t>>>26)+r|0)|~e))+n[15]-30611744)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[6]-1560198380)<<15|e>>>17)+i|0)|~t))+n[13]+1309151649)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+n[4]-145523070)<<6|t>>>26)+r|0)|~e))+n[11]-1120210379)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+n[2]+718787259)<<15|e>>>17)+i|0)|~t))+n[9]-343485551)<<21|r>>>11)+e|0,this.first?(this.h0=t+1732584193|0,this.h1=r-271733879|0,this.h2=e-1732584194|0,this.h3=i+271733878|0,this.first=!1):(this.h0=this.h0+t|0,this.h1=this.h1+r|0,this.h2=this.h2+e|0,this.h3=this.h3+i|0)},B.prototype.hex=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return a[t>>>4&15]+a[15&t]+a[t>>>12&15]+a[t>>>8&15]+a[t>>>20&15]+a[t>>>16&15]+a[t>>>28&15]+a[t>>>24&15]+a[r>>>4&15]+a[15&r]+a[r>>>12&15]+a[r>>>8&15]+a[r>>>20&15]+a[r>>>16&15]+a[r>>>28&15]+a[r>>>24&15]+a[e>>>4&15]+a[15&e]+a[e>>>12&15]+a[e>>>8&15]+a[e>>>20&15]+a[e>>>16&15]+a[e>>>28&15]+a[e>>>24&15]+a[i>>>4&15]+a[15&i]+a[i>>>12&15]+a[i>>>8&15]+a[i>>>20&15]+a[i>>>16&15]+a[i>>>28&15]+a[i>>>24&15]},B.prototype.toString=B.prototype.hex,B.prototype.digest=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&i,i>>>8&255,i>>>16&255,i>>>24&255]},B.prototype.array=B.prototype.digest,B.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),r=new Uint32Array(t);return r[0]=this.h0,r[1]=this.h1,r[2]=this.h2,r[3]=this.h3,t},B.prototype.buffer=B.prototype.arrayBuffer,B.prototype.base64=function(){for(var t,r,e,i="",h=this.array(),s=0;s<15;)t=h[s++],r=h[s++],e=h[s++],i+=p[t>>>2]+p[63&(t<<4|r>>>4)]+p[63&(r<<2|e>>>6)]+p[63&e];return t=h[s],i+=p[t>>>2]+p[t<<4&63]+"=="},g.prototype=new B,g.prototype.finalize=function(){if(B.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();B.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),B.prototype.finalize.call(this)}};var m=function(){var t=b("hex");h&&(t=w(t)),t.create=function(){return new B},t.update=function(r){return t.create().update(r)};for(var r=0;r>>6,s[n++]=128|63&h):h<55296||h>=57344?(s[n++]=224|h>>>12,s[n++]=128|h>>>6&63,s[n++]=128|63&h):(h=65536+((1023&h)<<10|1023&t.charCodeAt(++e)),s[n++]=240|h>>>18,s[n++]=128|h>>>12&63,s[n++]=128|h>>>6&63,s[n++]=128|63&h);t=s}t.length>64&&(t=new w(!0).update(t).array());var o=[],f=[];for(e=0;e<64;++e){var u=t[e]||0;o[e]=92^u,f[e]=54^u}w.call(this,r),this.update(f),this.oKeyPad=o,this.inner=!0,this.sharedMemory=r}w.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r=c(t);t=r[0];for(var e,i,h=r[1],s=0,a=t.length,n=this.blocks,o=this.buffer8;s>>6,o[i++]=128|63&e):e<55296||e>=57344?(o[i++]=224|e>>>12,o[i++]=128|e>>>6&63,o[i++]=128|63&e):(e=65536+((1023&e)<<10|1023&t.charCodeAt(++s)),o[i++]=240|e>>>18,o[i++]=128|e>>>12&63,o[i++]=128|e>>>6&63,o[i++]=128|63&e);else for(i=this.start;s=64?(this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},w.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[r>>>2]|=a[3&r],r>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},w.prototype.hash=function(){var t,r,e,i,h,s,a=this.blocks;this.first?r=((r=((t=((t=a[0]-680876937)<<7|t>>>25)-271733879|0)^(e=((e=(-271733879^(i=((i=(-1732584194^2004318071&t)+a[1]-117830708)<<12|i>>>20)+t|0)&(-271733879^t))+a[2]-1126478375)<<17|e>>>15)+i|0)&(i^t))+a[3]-1316259209)<<22|r>>>10)+e|0:(t=this.h0,r=this.h1,e=this.h2,r=((r+=((t=((t+=((i=this.h3)^r&(e^i))+a[0]-680876936)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[1]-389564586)<<12|i>>>20)+t|0)&(t^r))+a[2]+606105819)<<17|e>>>15)+i|0)&(i^t))+a[3]-1044525330)<<22|r>>>10)+e|0),r=((r+=((t=((t+=(i^r&(e^i))+a[4]-176418897)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[5]+1200080426)<<12|i>>>20)+t|0)&(t^r))+a[6]-1473231341)<<17|e>>>15)+i|0)&(i^t))+a[7]-45705983)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+a[8]+1770035416)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[9]-1958414417)<<12|i>>>20)+t|0)&(t^r))+a[10]-42063)<<17|e>>>15)+i|0)&(i^t))+a[11]-1990404162)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+a[12]+1804603682)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[13]-40341101)<<12|i>>>20)+t|0)&(t^r))+a[14]-1502002290)<<17|e>>>15)+i|0)&(i^t))+a[15]+1236535329)<<22|r>>>10)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[1]-165796510)<<5|t>>>27)+r|0)^r))+a[6]-1069501632)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[11]+643717713)<<14|e>>>18)+i|0)^i))+a[0]-373897302)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[5]-701558691)<<5|t>>>27)+r|0)^r))+a[10]+38016083)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[15]-660478335)<<14|e>>>18)+i|0)^i))+a[4]-405537848)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[9]+568446438)<<5|t>>>27)+r|0)^r))+a[14]-1019803690)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[3]-187363961)<<14|e>>>18)+i|0)^i))+a[8]+1163531501)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[13]-1444681467)<<5|t>>>27)+r|0)^r))+a[2]-51403784)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[7]+1735328473)<<14|e>>>18)+i|0)^i))+a[12]-1926607734)<<20|r>>>12)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[5]-378558)<<4|t>>>28)+r|0))+a[8]-2022574463)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[11]+1839030562)<<16|e>>>16)+i|0))+a[14]-35309556)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[1]-1530992060)<<4|t>>>28)+r|0))+a[4]+1272893353)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[7]-155497632)<<16|e>>>16)+i|0))+a[10]-1094730640)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[13]+681279174)<<4|t>>>28)+r|0))+a[0]-358537222)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[3]-722521979)<<16|e>>>16)+i|0))+a[6]+76029189)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[9]-640364487)<<4|t>>>28)+r|0))+a[12]-421815835)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[15]+530742520)<<16|e>>>16)+i|0))+a[2]-995338651)<<23|r>>>9)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[0]-198630844)<<6|t>>>26)+r|0)|~e))+a[7]+1126891415)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[14]-1416354905)<<15|e>>>17)+i|0)|~t))+a[5]-57434055)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[12]+1700485571)<<6|t>>>26)+r|0)|~e))+a[3]-1894986606)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[10]-1051523)<<15|e>>>17)+i|0)|~t))+a[1]-2054922799)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[8]+1873313359)<<6|t>>>26)+r|0)|~e))+a[15]-30611744)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[6]-1560198380)<<15|e>>>17)+i|0)|~t))+a[13]+1309151649)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[4]-145523070)<<6|t>>>26)+r|0)|~e))+a[11]-1120210379)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[2]+718787259)<<15|e>>>17)+i|0)|~t))+a[9]-343485551)<<21|r>>>11)+e|0,this.first?(this.h0=t+1732584193|0,this.h1=r-271733879|0,this.h2=e-1732584194|0,this.h3=i+271733878|0,this.first=!1):(this.h0=this.h0+t|0,this.h1=this.h1+r|0,this.h2=this.h2+e|0,this.h3=this.h3+i|0)},w.prototype.hex=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return s[t>>>4&15]+s[15&t]+s[t>>>12&15]+s[t>>>8&15]+s[t>>>20&15]+s[t>>>16&15]+s[t>>>28&15]+s[t>>>24&15]+s[r>>>4&15]+s[15&r]+s[r>>>12&15]+s[r>>>8&15]+s[r>>>20&15]+s[r>>>16&15]+s[r>>>28&15]+s[r>>>24&15]+s[e>>>4&15]+s[15&e]+s[e>>>12&15]+s[e>>>8&15]+s[e>>>20&15]+s[e>>>16&15]+s[e>>>28&15]+s[e>>>24&15]+s[i>>>4&15]+s[15&i]+s[i>>>12&15]+s[i>>>8&15]+s[i>>>20&15]+s[i>>>16&15]+s[i>>>28&15]+s[i>>>24&15]},w.prototype.toString=w.prototype.hex,w.prototype.digest=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&i,i>>>8&255,i>>>16&255,i>>>24&255]},w.prototype.array=w.prototype.digest,w.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),r=new Uint32Array(t);return r[0]=this.h0,r[1]=this.h1,r[2]=this.h2,r[3]=this.h3,t},w.prototype.buffer=w.prototype.arrayBuffer,w.prototype.base64=function(){for(var t,r,e,i="",h=this.array(),s=0;s<15;)t=h[s++],r=h[s++],e=h[s++],i+=f[t>>>2]+f[63&(t<<4|r>>>4)]+f[63&(r<<2|e>>>6)]+f[63&e];return t=h[s],i+=f[t>>>2]+f[t<<4&63]+"=="},b.prototype=new w,b.prototype.finalize=function(){if(w.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();w.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),w.prototype.finalize.call(this)}};var A=function(){var t=d("hex");t.create=function(){return new w},t.update=function(r){return t.create().update(r)};for(var r=0;r>>6,a[o++]=128|63&h):h<55296||h>=57344?(a[o++]=224|h>>>12,a[o++]=128|h>>>6&63,a[o++]=128|63&h):h<56320&&(s=t.charCodeAt(e+1))>=56320&&s<57344?(++e,h=65536+((1023&h)<<10|1023&s),a[o++]=240|h>>>18,a[o++]=128|h>>>12&63,a[o++]=128|h>>>6&63,a[o++]=128|63&h):(a[o++]=239,a[o++]=191,a[o++]=189);t=a}t.length>64&&(t=new w(!0).update(t).array());var f=[],u=[];for(e=0;e<64;++e){var p=t[e]||0;f[e]=92^p,u[e]=54^p}w.call(this,r),this.update(u),this.oKeyPad=f,this.inner=!0,this.sharedMemory=r}w.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r=c(t);t=r[0];for(var e,i,h,s=r[1],a=0,n=t.length,o=this.blocks,f=this.buffer8;a>>6,f[h++]=128|63&e):e<55296||e>=57344?(f[h++]=224|e>>>12,f[h++]=128|e>>>6&63,f[h++]=128|63&e):e<56320&&(i=t.charCodeAt(a+1))>=56320&&i<57344?(++a,e=65536+((1023&e)<<10|1023&i),f[h++]=240|e>>>18,f[h++]=128|e>>>12&63,f[h++]=128|e>>>6&63,f[h++]=128|63&e):(f[h++]=239,f[h++]=191,f[h++]=189);else for(h=this.start;a=64?(this.start=h-64,this.hash(),this.hashed=!0):this.start=h}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},w.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[r>>>2]|=a[3&r],r>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},w.prototype.hash=function(){var t,r,e,i,h,s,a=this.blocks;this.first?r=((r=((t=((t=a[0]-680876937)<<7|t>>>25)-271733879|0)^(e=((e=(-271733879^(i=((i=(-1732584194^2004318071&t)+a[1]-117830708)<<12|i>>>20)+t|0)&(-271733879^t))+a[2]-1126478375)<<17|e>>>15)+i|0)&(i^t))+a[3]-1316259209)<<22|r>>>10)+e|0:(t=this.h0,r=this.h1,e=this.h2,r=((r+=((t=((t+=((i=this.h3)^r&(e^i))+a[0]-680876936)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[1]-389564586)<<12|i>>>20)+t|0)&(t^r))+a[2]+606105819)<<17|e>>>15)+i|0)&(i^t))+a[3]-1044525330)<<22|r>>>10)+e|0),r=((r+=((t=((t+=(i^r&(e^i))+a[4]-176418897)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[5]+1200080426)<<12|i>>>20)+t|0)&(t^r))+a[6]-1473231341)<<17|e>>>15)+i|0)&(i^t))+a[7]-45705983)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+a[8]+1770035416)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[9]-1958414417)<<12|i>>>20)+t|0)&(t^r))+a[10]-42063)<<17|e>>>15)+i|0)&(i^t))+a[11]-1990404162)<<22|r>>>10)+e|0,r=((r+=((t=((t+=(i^r&(e^i))+a[12]+1804603682)<<7|t>>>25)+r|0)^(e=((e+=(r^(i=((i+=(e^t&(r^e))+a[13]-40341101)<<12|i>>>20)+t|0)&(t^r))+a[14]-1502002290)<<17|e>>>15)+i|0)&(i^t))+a[15]+1236535329)<<22|r>>>10)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[1]-165796510)<<5|t>>>27)+r|0)^r))+a[6]-1069501632)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[11]+643717713)<<14|e>>>18)+i|0)^i))+a[0]-373897302)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[5]-701558691)<<5|t>>>27)+r|0)^r))+a[10]+38016083)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[15]-660478335)<<14|e>>>18)+i|0)^i))+a[4]-405537848)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[9]+568446438)<<5|t>>>27)+r|0)^r))+a[14]-1019803690)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[3]-187363961)<<14|e>>>18)+i|0)^i))+a[8]+1163531501)<<20|r>>>12)+e|0,r=((r+=((i=((i+=(r^e&((t=((t+=(e^i&(r^e))+a[13]-1444681467)<<5|t>>>27)+r|0)^r))+a[2]-51403784)<<9|i>>>23)+t|0)^t&((e=((e+=(t^r&(i^t))+a[7]+1735328473)<<14|e>>>18)+i|0)^i))+a[12]-1926607734)<<20|r>>>12)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[5]-378558)<<4|t>>>28)+r|0))+a[8]-2022574463)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[11]+1839030562)<<16|e>>>16)+i|0))+a[14]-35309556)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[1]-1530992060)<<4|t>>>28)+r|0))+a[4]+1272893353)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[7]-155497632)<<16|e>>>16)+i|0))+a[10]-1094730640)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[13]+681279174)<<4|t>>>28)+r|0))+a[0]-358537222)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[3]-722521979)<<16|e>>>16)+i|0))+a[6]+76029189)<<23|r>>>9)+e|0,r=((r+=((s=(i=((i+=((h=r^e)^(t=((t+=(h^i)+a[9]-640364487)<<4|t>>>28)+r|0))+a[12]-421815835)<<11|i>>>21)+t|0)^t)^(e=((e+=(s^r)+a[15]+530742520)<<16|e>>>16)+i|0))+a[2]-995338651)<<23|r>>>9)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[0]-198630844)<<6|t>>>26)+r|0)|~e))+a[7]+1126891415)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[14]-1416354905)<<15|e>>>17)+i|0)|~t))+a[5]-57434055)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[12]+1700485571)<<6|t>>>26)+r|0)|~e))+a[3]-1894986606)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[10]-1051523)<<15|e>>>17)+i|0)|~t))+a[1]-2054922799)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[8]+1873313359)<<6|t>>>26)+r|0)|~e))+a[15]-30611744)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[6]-1560198380)<<15|e>>>17)+i|0)|~t))+a[13]+1309151649)<<21|r>>>11)+e|0,r=((r+=((i=((i+=(r^((t=((t+=(e^(r|~i))+a[4]-145523070)<<6|t>>>26)+r|0)|~e))+a[11]-1120210379)<<10|i>>>22)+t|0)^((e=((e+=(t^(i|~r))+a[2]+718787259)<<15|e>>>17)+i|0)|~t))+a[9]-343485551)<<21|r>>>11)+e|0,this.first?(this.h0=t+1732584193|0,this.h1=r-271733879|0,this.h2=e-1732584194|0,this.h3=i+271733878|0,this.first=!1):(this.h0=this.h0+t|0,this.h1=this.h1+r|0,this.h2=this.h2+e|0,this.h3=this.h3+i|0)},w.prototype.hex=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return s[t>>>4&15]+s[15&t]+s[t>>>12&15]+s[t>>>8&15]+s[t>>>20&15]+s[t>>>16&15]+s[t>>>28&15]+s[t>>>24&15]+s[r>>>4&15]+s[15&r]+s[r>>>12&15]+s[r>>>8&15]+s[r>>>20&15]+s[r>>>16&15]+s[r>>>28&15]+s[r>>>24&15]+s[e>>>4&15]+s[15&e]+s[e>>>12&15]+s[e>>>8&15]+s[e>>>20&15]+s[e>>>16&15]+s[e>>>28&15]+s[e>>>24&15]+s[i>>>4&15]+s[15&i]+s[i>>>12&15]+s[i>>>8&15]+s[i>>>20&15]+s[i>>>16&15]+s[i>>>28&15]+s[i>>>24&15]},w.prototype.toString=w.prototype.hex,w.prototype.digest=function(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&i,i>>>8&255,i>>>16&255,i>>>24&255]},w.prototype.array=w.prototype.digest,w.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),r=new Uint32Array(t);return r[0]=this.h0,r[1]=this.h1,r[2]=this.h2,r[3]=this.h3,t},w.prototype.buffer=w.prototype.arrayBuffer,w.prototype.base64=function(){for(var t,r,e,i="",h=this.array(),s=0;s<15;)t=h[s++],r=h[s++],e=h[s++],i+=f[t>>>2]+f[63&(t<<4|r>>>4)]+f[63&(r<<2|e>>>6)]+f[63&e];return t=h[s],i+=f[t>>>2]+f[t<<4&63]+"=="},b.prototype=new w,b.prototype.finalize=function(){if(w.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();w.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),w.prototype.finalize.call(this)}};var A=function(){var t=d("hex");t.create=function(){return new w},t.update=function(r){return t.create().update(r)};for(var r=0;r>> 12); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) { + ++index; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); + } else { + // unpaired surrogate: U+FFFD + buffer8[i++] = 0xef; + buffer8[i++] = 0xbf; + buffer8[i++] = 0xbd; } } } @@ -733,7 +739,7 @@ var md5$1 = {exports: {}}; var i, result = formatMessage(key); key = result[0]; if (result[1]) { - var bytes = [], length = key.length, index = 0, code; + var bytes = [], length = key.length, index = 0, code, code2; for (i = 0; i < length; ++i) { code = key.charCodeAt(i); if (code < 0x80) { @@ -745,12 +751,18 @@ var md5$1 = {exports: {}}; bytes[index++] = (0xe0 | (code >>> 12)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f)); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = key.charCodeAt(i + 1)) >= 0xdc00 && code2 < 0xe000) { + ++i; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); bytes[index++] = (0xf0 | (code >>> 18)); bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f)); + } else { + // unpaired surrogate: U+FFFD + bytes[index++] = 0xef; + bytes[index++] = 0xbf; + bytes[index++] = 0xbd; } } key = bytes; diff --git a/build/md5.modern.node.mjs b/build/md5.modern.node.mjs index b5d0e55..39c8205 100644 --- a/build/md5.modern.node.mjs +++ b/build/md5.modern.node.mjs @@ -13,7 +13,7 @@ var md5$1 = {exports: {}}; * [js-md5]{@link https://github.com/emn178/js-md5} * * @namespace md5 - * @version 0.9.2 + * @version 0.10.0 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2014-2026 * @license MIT @@ -359,7 +359,7 @@ var md5$1 = {exports: {}}; var result = formatMessage(message); message = result[0]; var isString = result[1]; - var code, index = 0, i, length = message.length, blocks = this.blocks; + var code, code2, index = 0, i, length = message.length, blocks = this.blocks; var buffer8 = this.buffer8; while (index < length) { @@ -385,12 +385,18 @@ var md5$1 = {exports: {}}; buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) { + ++index; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); + } else { + // unpaired surrogate: U+FFFD + buffer8[i++] = 0xef; + buffer8[i++] = 0xbf; + buffer8[i++] = 0xbd; } } } @@ -769,7 +775,7 @@ var md5$1 = {exports: {}}; var i, result = formatMessage(key); key = result[0]; if (result[1]) { - var bytes = [], length = key.length, index = 0, code; + var bytes = [], length = key.length, index = 0, code, code2; for (i = 0; i < length; ++i) { code = key.charCodeAt(i); if (code < 0x80) { @@ -781,12 +787,18 @@ var md5$1 = {exports: {}}; bytes[index++] = (0xe0 | (code >>> 12)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f)); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = key.charCodeAt(i + 1)) >= 0xdc00 && code2 < 0xe000) { + ++i; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); bytes[index++] = (0xf0 | (code >>> 18)); bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f)); + } else { + // unpaired surrogate: U+FFFD + bytes[index++] = 0xef; + bytes[index++] = 0xbf; + bytes[index++] = 0xbd; } } key = bytes; diff --git a/build/md5.node.mjs b/build/md5.node.mjs index b6aee7b..255f02b 100644 --- a/build/md5.node.mjs +++ b/build/md5.node.mjs @@ -13,7 +13,7 @@ var md5$1 = {exports: {}}; * [js-md5]{@link https://github.com/emn178/js-md5} * * @namespace md5 - * @version 0.9.2 + * @version 0.10.0 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2014-2026 * @license MIT @@ -381,7 +381,7 @@ var md5$1 = {exports: {}}; var result = formatMessage(message); message = result[0]; var isString = result[1]; - var code, index = 0, i, length = message.length, blocks = this.blocks; + var code, code2, index = 0, i, length = message.length, blocks = this.blocks; var buffer8 = this.buffer8; while (index < length) { @@ -407,12 +407,18 @@ var md5$1 = {exports: {}}; buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) { + ++index; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); + } else { + // unpaired surrogate: U+FFFD + buffer8[i++] = 0xef; + buffer8[i++] = 0xbf; + buffer8[i++] = 0xbd; } } } else { @@ -427,12 +433,18 @@ var md5$1 = {exports: {}}; blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) { + ++index; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + // unpaired surrogate: U+FFFD + blocks[i >>> 2] |= 0xef << SHIFT[i++ & 3]; + blocks[i >>> 2] |= 0xbf << SHIFT[i++ & 3]; + blocks[i >>> 2] |= 0xbd << SHIFT[i++ & 3]; } } } @@ -815,7 +827,7 @@ var md5$1 = {exports: {}}; var i, result = formatMessage(key); key = result[0]; if (result[1]) { - var bytes = [], length = key.length, index = 0, code; + var bytes = [], length = key.length, index = 0, code, code2; for (i = 0; i < length; ++i) { code = key.charCodeAt(i); if (code < 0x80) { @@ -827,12 +839,18 @@ var md5$1 = {exports: {}}; bytes[index++] = (0xe0 | (code >>> 12)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f)); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = key.charCodeAt(i + 1)) >= 0xdc00 && code2 < 0xe000) { + ++i; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); bytes[index++] = (0xf0 | (code >>> 18)); bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f)); + } else { + // unpaired surrogate: U+FFFD + bytes[index++] = 0xef; + bytes[index++] = 0xbf; + bytes[index++] = 0xbd; } } key = bytes; diff --git a/doc/HmacMd5.html b/doc/HmacMd5.html index 29f8a9a..07cefb6 100644 --- a/doc/HmacMd5.html +++ b/doc/HmacMd5.html @@ -93,7 +93,7 @@
Source:
@@ -224,7 +224,7 @@
Source:
@@ -351,7 +351,7 @@
Source:
@@ -478,7 +478,7 @@
Source:
@@ -607,7 +607,7 @@
Source:
@@ -734,7 +734,7 @@
Source:
@@ -861,7 +861,7 @@
Source:
@@ -988,7 +988,7 @@
Source:
diff --git a/doc/Md5_.html b/doc/Md5_.html index c1dfaec..7be0a5d 100644 --- a/doc/Md5_.html +++ b/doc/Md5_.html @@ -47,7 +47,7 @@
Version:
-
  • 0.9.2
+
  • 0.10.0
diff --git a/doc/global.html b/doc/global.html index 8252cee..9e3908d 100644 --- a/doc/global.html +++ b/doc/global.html @@ -214,7 +214,7 @@
Source:
diff --git a/doc/md5.html b/doc/md5.html index 943d049..17c8a22 100644 --- a/doc/md5.html +++ b/doc/md5.html @@ -208,7 +208,7 @@
Source:
@@ -330,7 +330,7 @@
Source:
@@ -452,7 +452,7 @@
Source:
@@ -576,7 +576,7 @@
Source:
@@ -698,7 +698,7 @@
Source:
@@ -820,7 +820,7 @@
Source:
@@ -942,7 +942,7 @@
Source:
diff --git a/doc/md5.js.html b/doc/md5.js.html index 7ab0e80..1b8a9ad 100644 --- a/doc/md5.js.html +++ b/doc/md5.js.html @@ -30,7 +30,7 @@ * [js-md5]{@link https://github.com/emn178/js-md5} * * @namespace md5 - * @version 0.9.2 + * @version 0.10.0 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2014-2026 * @license MIT @@ -405,7 +405,7 @@ var result = formatMessage(message); message = result[0]; var isString = result[1]; - var code, index = 0, i, length = message.length, blocks = this.blocks; + var code, code2, index = 0, i, length = message.length, blocks = this.blocks; var buffer8 = this.buffer8; while (index < length) { @@ -431,12 +431,18 @@ buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) { + ++index; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); + } else { + // unpaired surrogate: U+FFFD + buffer8[i++] = 0xef; + buffer8[i++] = 0xbf; + buffer8[i++] = 0xbd; } } } else { @@ -451,12 +457,18 @@ blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) { + ++index; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + // unpaired surrogate: U+FFFD + blocks[i >>> 2] |= 0xef << SHIFT[i++ & 3]; + blocks[i >>> 2] |= 0xbf << SHIFT[i++ & 3]; + blocks[i >>> 2] |= 0xbd << SHIFT[i++ & 3]; } } } @@ -839,7 +851,7 @@ var i, result = formatMessage(key); key = result[0]; if (result[1]) { - var bytes = [], length = key.length, index = 0, code; + var bytes = [], length = key.length, index = 0, code, code2; for (i = 0; i < length; ++i) { code = key.charCodeAt(i); if (code < 0x80) { @@ -851,12 +863,18 @@ bytes[index++] = (0xe0 | (code >>> 12)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f)); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = key.charCodeAt(i + 1)) >= 0xdc00 && code2 < 0xe000) { + ++i; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); bytes[index++] = (0xf0 | (code >>> 18)); bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f)); + } else { + // unpaired surrogate: U+FFFD + bytes[index++] = 0xef; + bytes[index++] = 0xbf; + bytes[index++] = 0xbd; } } key = bytes; diff --git a/package-lock.json b/package-lock.json index 01abc93..85d842c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "js-md5", - "version": "0.9.2", + "version": "0.10.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "js-md5", - "version": "0.9.2", + "version": "0.10.0", "license": "MIT", "devDependencies": { "@rollup/plugin-commonjs": "^29.0.3", diff --git a/package.json b/package.json index 3665bb1..d1fcc9b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "js-md5", - "version": "0.9.2", + "version": "0.10.0", "description": "A simple MD5 hash function for JavaScript supports UTF-8 encoding.", "main": "src/md5.js", "module": "build/md5.mjs", diff --git a/src/md5.js b/src/md5.js index 1b05119..563aa78 100644 --- a/src/md5.js +++ b/src/md5.js @@ -2,7 +2,7 @@ * [js-md5]{@link https://github.com/emn178/js-md5} * * @namespace md5 - * @version 0.9.2 + * @version 0.10.0 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2014-2026 * @license MIT @@ -377,7 +377,7 @@ var result = formatMessage(message); message = result[0]; var isString = result[1]; - var code, index = 0, i, length = message.length, blocks = this.blocks; + var code, code2, index = 0, i, length = message.length, blocks = this.blocks; var buffer8 = this.buffer8; while (index < length) { @@ -403,12 +403,18 @@ buffer8[i++] = 0xe0 | (code >>> 12); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) { + ++index; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); buffer8[i++] = 0xf0 | (code >>> 18); buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f); buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f); buffer8[i++] = 0x80 | (code & 0x3f); + } else { + // unpaired surrogate: U+FFFD + buffer8[i++] = 0xef; + buffer8[i++] = 0xbf; + buffer8[i++] = 0xbd; } } } else { @@ -423,12 +429,18 @@ blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = message.charCodeAt(index + 1)) >= 0xdc00 && code2 < 0xe000) { + ++index; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3]; blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + // unpaired surrogate: U+FFFD + blocks[i >>> 2] |= 0xef << SHIFT[i++ & 3]; + blocks[i >>> 2] |= 0xbf << SHIFT[i++ & 3]; + blocks[i >>> 2] |= 0xbd << SHIFT[i++ & 3]; } } } @@ -811,7 +823,7 @@ var i, result = formatMessage(key); key = result[0]; if (result[1]) { - var bytes = [], length = key.length, index = 0, code; + var bytes = [], length = key.length, index = 0, code, code2; for (i = 0; i < length; ++i) { code = key.charCodeAt(i); if (code < 0x80) { @@ -823,12 +835,18 @@ bytes[index++] = (0xe0 | (code >>> 12)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f)); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); + } else if (code < 0xdc00 && (code2 = key.charCodeAt(i + 1)) >= 0xdc00 && code2 < 0xe000) { + ++i; + code = 0x10000 + (((code & 0x3ff) << 10) | (code2 & 0x3ff)); bytes[index++] = (0xf0 | (code >>> 18)); bytes[index++] = (0x80 | ((code >>> 12) & 0x3f)); bytes[index++] = (0x80 | ((code >>> 6) & 0x3f)); bytes[index++] = (0x80 | (code & 0x3f)); + } else { + // unpaired surrogate: U+FFFD + bytes[index++] = 0xef; + bytes[index++] = 0xbf; + bytes[index++] = 0xbd; } } key = bytes; diff --git a/tests/hmac-test.js b/tests/hmac-test.js index 1c07d39..c3d653e 100644 --- a/tests/hmac-test.js +++ b/tests/hmac-test.js @@ -45,6 +45,10 @@ '05fe3b294344f4e93c811e10f9825a38': ['中文', '中文'], 'c1bc6df91f38e6332b8562324005103d': ['aécio', 'aécio'], '14eef78533c35078177d11fb4593a19e': ['𠜎', '𠜎'] + }, + 'UTF8 unpaired surrogates': { + '2ef4c67742d4f436cbdfdbad133659af': ['\ud800', 'a\ud83db'], + 'f537b6e97a3e8b23a9e87a29fb5c4173': ['a\udc00b', '\ud83d\ude00\udfff'] } } }; diff --git a/tests/test.js b/tests/test.js index e09d5c9..e5ebc98 100644 --- a/tests/test.js +++ b/tests/test.js @@ -27,6 +27,16 @@ 'edce615b179e6e29be23145b77ebbd61': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一', 'ad36c9ab669a0ba9ce46d3ce9134de34': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。' }, + 'UTF8 unpaired surrogates': { + '9b759040321a408a5c7768b4511287a6': '\ud800', + 'e240e5e976deb550ea69ec12f01d19ea': '\udc00x', + 'ff6405018d5ab2642e35fdba389b7c51': 'a\ud83db', + 'ef175e9b596d296034dda690087252f8': 'a\udc00', + '2e906629739ba554e03c1201e05b94f2': '\ud83d\ud83d\ude00', + '468a7f02af0808ae39ef3e3629ae048c': '\ud83d\ude00\udfff', + '6785af8cb378bd9950085c5d6375f9ad': Array(57).join('0') + '\ud800', + 'a20fb4cd303a71aa61dd524e8fc525ef': Array(64).join('0') + '\ud800b' + }, 'special length': { 'a119de63e4b2398427da06dd780263b3': '0123456780123456780123456780123456780123456780123456780', 'ddafd84ebe63aebc4626b037a569d78b': '01234567801234567801234567801234567801234567801234567801',