pure-md5 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.gitattributes ADDED
@@ -0,0 +1,3 @@
1
+ # Ensure test files use Unix line endings
2
+ * text eol=lf
3
+ test-file.txt text eol=lf
@@ -0,0 +1,7 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npm test)"
5
+ ]
6
+ }
7
+ }
@@ -1 +1 @@
1
- 'use strict';var C="0123456789abcdef".split(""),p=C;function B(o){let n="";for(let m=0;m<4;m++)n+=p[o>>m*8+4&15]+p[o>>m*8&15];return n}function P(o){let n=o.length,m=new Array(n);for(let e=0;e<n;e++)m[e]=B(o[e]);return m.join("")}var g=P;function D(o,n){return o+n&4294967295}var c=D;function U(o,n,m,e,r){let t=r||c;return n=t(t(n,o),t(m,e)),n}function _(o,n,m,e){var t=(e||c)(o<<n|o>>>32-n,m);return t}function s(o,n,m,e,r,t,u){return n=U(o,n,e,t,u),_(n,r,m,u)}function h(o,n,m,e,r,t,u,i){return s(m&e|~m&r,n,m,t,u,i,o)}function y(o,n,m,e,r,t,u,i){return s(m&r|e&~r,n,m,t,u,i,o)}function A(o,n,m,e,r,t,u,i){return s(m^e^r,n,m,t,u,i,o)}function x(o,n,m,e,r,t,u,i){return s(e^(m|~r),n,m,t,u,i,o)}function j(o,n,m){typeof m>"u"&&(m=c);let e=o[0],r=o[1],t=o[2],u=o[3],i=h.bind(null,m);e=i(e,r,t,u,n[0],7,-680876936),u=i(u,e,r,t,n[1],12,-389564586),t=i(t,u,e,r,n[2],17,606105819),r=i(r,t,u,e,n[3],22,-1044525330),e=i(e,r,t,u,n[4],7,-176418897),u=i(u,e,r,t,n[5],12,1200080426),t=i(t,u,e,r,n[6],17,-1473231341),r=i(r,t,u,e,n[7],22,-45705983),e=i(e,r,t,u,n[8],7,1770035416),u=i(u,e,r,t,n[9],12,-1958414417),t=i(t,u,e,r,n[10],17,-42063),r=i(r,t,u,e,n[11],22,-1990404162),e=i(e,r,t,u,n[12],7,1804603682),u=i(u,e,r,t,n[13],12,-40341101),t=i(t,u,e,r,n[14],17,-1502002290),r=i(r,t,u,e,n[15],22,1236535329);let d=y.bind(null,m);e=d(e,r,t,u,n[1],5,-165796510),u=d(u,e,r,t,n[6],9,-1069501632),t=d(t,u,e,r,n[11],14,643717713),r=d(r,t,u,e,n[0],20,-373897302),e=d(e,r,t,u,n[5],5,-701558691),u=d(u,e,r,t,n[10],9,38016083),t=d(t,u,e,r,n[15],14,-660478335),r=d(r,t,u,e,n[4],20,-405537848),e=d(e,r,t,u,n[9],5,568446438),u=d(u,e,r,t,n[14],9,-1019803690),t=d(t,u,e,r,n[3],14,-187363961),r=d(r,t,u,e,n[8],20,1163531501),e=d(e,r,t,u,n[13],5,-1444681467),u=d(u,e,r,t,n[2],9,-51403784),t=d(t,u,e,r,n[7],14,1735328473),r=d(r,t,u,e,n[12],20,-1926607734);let b=A.bind(null,m);e=b(e,r,t,u,n[5],4,-378558),u=b(u,e,r,t,n[8],11,-2022574463),t=b(t,u,e,r,n[11],16,1839030562),r=b(r,t,u,e,n[14],23,-35309556),e=b(e,r,t,u,n[1],4,-1530992060),u=b(u,e,r,t,n[4],11,1272893353),t=b(t,u,e,r,n[7],16,-155497632),r=b(r,t,u,e,n[10],23,-1094730640),e=b(e,r,t,u,n[13],4,681279174),u=b(u,e,r,t,n[0],11,-358537222),t=b(t,u,e,r,n[3],16,-722521979),r=b(r,t,u,e,n[6],23,76029189),e=b(e,r,t,u,n[9],4,-640364487),u=b(u,e,r,t,n[12],11,-421815835),t=b(t,u,e,r,n[15],16,530742520),r=b(r,t,u,e,n[2],23,-995338651);let f=x.bind(null,m);e=f(e,r,t,u,n[0],6,-198630844),u=f(u,e,r,t,n[7],10,1126891415),t=f(t,u,e,r,n[14],15,-1416354905),r=f(r,t,u,e,n[5],21,-57434055),e=f(e,r,t,u,n[12],6,1700485571),u=f(u,e,r,t,n[3],10,-1894986606),t=f(t,u,e,r,n[10],15,-1051523),r=f(r,t,u,e,n[1],21,-2054922799),e=f(e,r,t,u,n[8],6,1873313359),u=f(u,e,r,t,n[15],10,-30611744),t=f(t,u,e,r,n[6],15,-1560198380),r=f(r,t,u,e,n[13],21,1309151649),e=f(e,r,t,u,n[4],6,-145523070),u=f(u,e,r,t,n[11],10,-1120210379),t=f(t,u,e,r,n[2],15,718787259),r=f(r,t,u,e,n[9],21,-343485551),o[0]=m(e,o[0]),o[1]=m(r,o[1]),o[2]=m(t,o[2]),o[3]=m(u,o[3]);}var l=j;function E(o){let n=[];for(let m=0;m<64;m+=4)n[m>>2]=(o.charCodeAt(m)||0)+((o.charCodeAt(m+1)||0)<<8)+((o.charCodeAt(m+2)||0)<<16)+((o.charCodeAt(m+3)||0)<<24);return n}var F=E;function I(o,n){let m=o.length,e=[1732584193,-271733879,-1732584194,271733878],r;for(r=64;r<=m;r+=64)l(e,F(o.substring(r-64,r)),n);o=o.substring(r-64);var t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],u=o.length;for(r=0;r<u;r++)t[r>>2]|=(o.charCodeAt(r)&255)<<(r%4<<3);if(t[r>>2]|=128<<(r%4<<3),r>55)for(l(e,t,n),r=16;r--;)t[r]=0;return t[14]=m*8,l(e,t,n),e}var v=I;function a(o){return g(v(o,c))}var w=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(n){return a(n)}async hashBinary(n){let m=n instanceof ArrayBuffer?new TextDecoder().decode(n):new TextDecoder().decode(n);return a(m)}update(n){throw new Error("Web Crypto API does not support streaming updates")}digest(n){throw new Error("Web Crypto API does not support streaming")}reset(){}};exports.WebCryptoBackend=w;
1
+ 'use strict';var v="0123456789abcdef".split(""),l=v;function B(i){let n="";for(let o=0;o<4;o++)n+=l[i>>o*8+4&15]+l[i>>o*8&15];return n}function P(i){let n=i.length,o=new Array(n);for(let r=0;r<n;r++)o[r]=B(i[r]);return o.join("")}var a=P;function U(i,n){return i+n&4294967295}var c=U;function C(i,n,o,r,t){let e=t||c;return n=e(e(n,i),e(o,r)),n}function T(i,n,o,r){var e=(r||c)(i<<n|i>>>32-n,o);return e}function b(i,n,o,r,t,e,u){return n=C(i,n,r,e,u),T(n,t,o,u)}function h(i,n,o,r,t,e,u,m){return b(o&r|~o&t,n,o,e,u,m,i)}function g(i,n,o,r,t,e,u,m){return b(o&t|r&~t,n,o,e,u,m,i)}function y(i,n,o,r,t,e,u,m){return b(o^r^t,n,o,e,u,m,i)}function A(i,n,o,r,t,e,u,m){return b(r^(o|~t),n,o,e,u,m,i)}function D(i,n,o){typeof o>"u"&&(o=c);let r=i[0],t=i[1],e=i[2],u=i[3],m=h.bind(null,o);r=m(r,t,e,u,n[0],7,-680876936),u=m(u,r,t,e,n[1],12,-389564586),e=m(e,u,r,t,n[2],17,606105819),t=m(t,e,u,r,n[3],22,-1044525330),r=m(r,t,e,u,n[4],7,-176418897),u=m(u,r,t,e,n[5],12,1200080426),e=m(e,u,r,t,n[6],17,-1473231341),t=m(t,e,u,r,n[7],22,-45705983),r=m(r,t,e,u,n[8],7,1770035416),u=m(u,r,t,e,n[9],12,-1958414417),e=m(e,u,r,t,n[10],17,-42063),t=m(t,e,u,r,n[11],22,-1990404162),r=m(r,t,e,u,n[12],7,1804603682),u=m(u,r,t,e,n[13],12,-40341101),e=m(e,u,r,t,n[14],17,-1502002290),t=m(t,e,u,r,n[15],22,1236535329);let f=g.bind(null,o);r=f(r,t,e,u,n[1],5,-165796510),u=f(u,r,t,e,n[6],9,-1069501632),e=f(e,u,r,t,n[11],14,643717713),t=f(t,e,u,r,n[0],20,-373897302),r=f(r,t,e,u,n[5],5,-701558691),u=f(u,r,t,e,n[10],9,38016083),e=f(e,u,r,t,n[15],14,-660478335),t=f(t,e,u,r,n[4],20,-405537848),r=f(r,t,e,u,n[9],5,568446438),u=f(u,r,t,e,n[14],9,-1019803690),e=f(e,u,r,t,n[3],14,-187363961),t=f(t,e,u,r,n[8],20,1163531501),r=f(r,t,e,u,n[13],5,-1444681467),u=f(u,r,t,e,n[2],9,-51403784),e=f(e,u,r,t,n[7],14,1735328473),t=f(t,e,u,r,n[12],20,-1926607734);let d=y.bind(null,o);r=d(r,t,e,u,n[5],4,-378558),u=d(u,r,t,e,n[8],11,-2022574463),e=d(e,u,r,t,n[11],16,1839030562),t=d(t,e,u,r,n[14],23,-35309556),r=d(r,t,e,u,n[1],4,-1530992060),u=d(u,r,t,e,n[4],11,1272893353),e=d(e,u,r,t,n[7],16,-155497632),t=d(t,e,u,r,n[10],23,-1094730640),r=d(r,t,e,u,n[13],4,681279174),u=d(u,r,t,e,n[0],11,-358537222),e=d(e,u,r,t,n[3],16,-722521979),t=d(t,e,u,r,n[6],23,76029189),r=d(r,t,e,u,n[9],4,-640364487),u=d(u,r,t,e,n[12],11,-421815835),e=d(e,u,r,t,n[15],16,530742520),t=d(t,e,u,r,n[2],23,-995338651);let s=A.bind(null,o);r=s(r,t,e,u,n[0],6,-198630844),u=s(u,r,t,e,n[7],10,1126891415),e=s(e,u,r,t,n[14],15,-1416354905),t=s(t,e,u,r,n[5],21,-57434055),r=s(r,t,e,u,n[12],6,1700485571),u=s(u,r,t,e,n[3],10,-1894986606),e=s(e,u,r,t,n[10],15,-1051523),t=s(t,e,u,r,n[1],21,-2054922799),r=s(r,t,e,u,n[8],6,1873313359),u=s(u,r,t,e,n[15],10,-30611744),e=s(e,u,r,t,n[6],15,-1560198380),t=s(t,e,u,r,n[13],21,1309151649),r=s(r,t,e,u,n[4],6,-145523070),u=s(u,r,t,e,n[11],10,-1120210379),e=s(e,u,r,t,n[2],15,718787259),t=s(t,e,u,r,n[9],21,-343485551),i[0]=o(r,i[0]),i[1]=o(t,i[1]),i[2]=o(e,i[2]),i[3]=o(u,i[3]);}var p=D;function _(i){let n=[];for(let o=0;o<i.length;o++){let r=i.charCodeAt(o);if(r>=55296&&r<=56319&&o+1<i.length){let t=i.charCodeAt(o+1);t>=56320&&t<=57343&&(r=(r-55296<<10)+(t-56320)+65536,o++);}r<=127?n.push(r):r<=2047?(n.push(192|r>>6),n.push(128|r&63)):r<=65535?(n.push(224|r>>12),n.push(128|r>>6&63),n.push(128|r&63)):(n.push(240|r>>18),n.push(128|r>>12&63),n.push(128|r>>6&63),n.push(128|r&63));}return n}function j(i){let n=[];for(let o=0;o<16;o++)n[o]=i[o*4]+(i[o*4+1]<<8)+(i[o*4+2]<<16)+(i[o*4+3]<<24);return n}function E(i,n){let o=_(i),r=o.length,t=[1732584193,-271733879,-1732584194,271733878],e;for(e=64;e<=r;e+=64){let d=o.slice(e-64,e);p(t,j(d),n);}let u=o.slice(e-64),m=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=u.length;for(e=0;e<f;e++)m[e>>2]|=u[e]<<(e%4<<3);if(m[e>>2]|=128<<(e%4<<3),e>55)for(p(t,m,n),e=16;e--;)m[e]=0;return m[14]=r*8,p(t,m,n),t}var F=E;function x(i){return a(F(i,c))}var w=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(n){return x(n)}async hashBinary(n){let o=n instanceof ArrayBuffer?new TextDecoder().decode(n):new TextDecoder().decode(n);return x(o)}update(n){throw new Error("Web Crypto API does not support streaming updates")}digest(n){throw new Error("Web Crypto API does not support streaming")}reset(){}};exports.WebCryptoBackend=w;
@@ -1 +1 @@
1
- var C="0123456789abcdef".split(""),p=C;function B(o){let n="";for(let m=0;m<4;m++)n+=p[o>>m*8+4&15]+p[o>>m*8&15];return n}function P(o){let n=o.length,m=new Array(n);for(let e=0;e<n;e++)m[e]=B(o[e]);return m.join("")}var g=P;function D(o,n){return o+n&4294967295}var c=D;function U(o,n,m,e,r){let t=r||c;return n=t(t(n,o),t(m,e)),n}function _(o,n,m,e){var t=(e||c)(o<<n|o>>>32-n,m);return t}function s(o,n,m,e,r,t,u){return n=U(o,n,e,t,u),_(n,r,m,u)}function h(o,n,m,e,r,t,u,i){return s(m&e|~m&r,n,m,t,u,i,o)}function y(o,n,m,e,r,t,u,i){return s(m&r|e&~r,n,m,t,u,i,o)}function A(o,n,m,e,r,t,u,i){return s(m^e^r,n,m,t,u,i,o)}function x(o,n,m,e,r,t,u,i){return s(e^(m|~r),n,m,t,u,i,o)}function j(o,n,m){typeof m>"u"&&(m=c);let e=o[0],r=o[1],t=o[2],u=o[3],i=h.bind(null,m);e=i(e,r,t,u,n[0],7,-680876936),u=i(u,e,r,t,n[1],12,-389564586),t=i(t,u,e,r,n[2],17,606105819),r=i(r,t,u,e,n[3],22,-1044525330),e=i(e,r,t,u,n[4],7,-176418897),u=i(u,e,r,t,n[5],12,1200080426),t=i(t,u,e,r,n[6],17,-1473231341),r=i(r,t,u,e,n[7],22,-45705983),e=i(e,r,t,u,n[8],7,1770035416),u=i(u,e,r,t,n[9],12,-1958414417),t=i(t,u,e,r,n[10],17,-42063),r=i(r,t,u,e,n[11],22,-1990404162),e=i(e,r,t,u,n[12],7,1804603682),u=i(u,e,r,t,n[13],12,-40341101),t=i(t,u,e,r,n[14],17,-1502002290),r=i(r,t,u,e,n[15],22,1236535329);let d=y.bind(null,m);e=d(e,r,t,u,n[1],5,-165796510),u=d(u,e,r,t,n[6],9,-1069501632),t=d(t,u,e,r,n[11],14,643717713),r=d(r,t,u,e,n[0],20,-373897302),e=d(e,r,t,u,n[5],5,-701558691),u=d(u,e,r,t,n[10],9,38016083),t=d(t,u,e,r,n[15],14,-660478335),r=d(r,t,u,e,n[4],20,-405537848),e=d(e,r,t,u,n[9],5,568446438),u=d(u,e,r,t,n[14],9,-1019803690),t=d(t,u,e,r,n[3],14,-187363961),r=d(r,t,u,e,n[8],20,1163531501),e=d(e,r,t,u,n[13],5,-1444681467),u=d(u,e,r,t,n[2],9,-51403784),t=d(t,u,e,r,n[7],14,1735328473),r=d(r,t,u,e,n[12],20,-1926607734);let b=A.bind(null,m);e=b(e,r,t,u,n[5],4,-378558),u=b(u,e,r,t,n[8],11,-2022574463),t=b(t,u,e,r,n[11],16,1839030562),r=b(r,t,u,e,n[14],23,-35309556),e=b(e,r,t,u,n[1],4,-1530992060),u=b(u,e,r,t,n[4],11,1272893353),t=b(t,u,e,r,n[7],16,-155497632),r=b(r,t,u,e,n[10],23,-1094730640),e=b(e,r,t,u,n[13],4,681279174),u=b(u,e,r,t,n[0],11,-358537222),t=b(t,u,e,r,n[3],16,-722521979),r=b(r,t,u,e,n[6],23,76029189),e=b(e,r,t,u,n[9],4,-640364487),u=b(u,e,r,t,n[12],11,-421815835),t=b(t,u,e,r,n[15],16,530742520),r=b(r,t,u,e,n[2],23,-995338651);let f=x.bind(null,m);e=f(e,r,t,u,n[0],6,-198630844),u=f(u,e,r,t,n[7],10,1126891415),t=f(t,u,e,r,n[14],15,-1416354905),r=f(r,t,u,e,n[5],21,-57434055),e=f(e,r,t,u,n[12],6,1700485571),u=f(u,e,r,t,n[3],10,-1894986606),t=f(t,u,e,r,n[10],15,-1051523),r=f(r,t,u,e,n[1],21,-2054922799),e=f(e,r,t,u,n[8],6,1873313359),u=f(u,e,r,t,n[15],10,-30611744),t=f(t,u,e,r,n[6],15,-1560198380),r=f(r,t,u,e,n[13],21,1309151649),e=f(e,r,t,u,n[4],6,-145523070),u=f(u,e,r,t,n[11],10,-1120210379),t=f(t,u,e,r,n[2],15,718787259),r=f(r,t,u,e,n[9],21,-343485551),o[0]=m(e,o[0]),o[1]=m(r,o[1]),o[2]=m(t,o[2]),o[3]=m(u,o[3]);}var l=j;function E(o){let n=[];for(let m=0;m<64;m+=4)n[m>>2]=(o.charCodeAt(m)||0)+((o.charCodeAt(m+1)||0)<<8)+((o.charCodeAt(m+2)||0)<<16)+((o.charCodeAt(m+3)||0)<<24);return n}var F=E;function I(o,n){let m=o.length,e=[1732584193,-271733879,-1732584194,271733878],r;for(r=64;r<=m;r+=64)l(e,F(o.substring(r-64,r)),n);o=o.substring(r-64);var t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],u=o.length;for(r=0;r<u;r++)t[r>>2]|=(o.charCodeAt(r)&255)<<(r%4<<3);if(t[r>>2]|=128<<(r%4<<3),r>55)for(l(e,t,n),r=16;r--;)t[r]=0;return t[14]=m*8,l(e,t,n),e}var v=I;function a(o){return g(v(o,c))}var w=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(n){return a(n)}async hashBinary(n){let m=n instanceof ArrayBuffer?new TextDecoder().decode(n):new TextDecoder().decode(n);return a(m)}update(n){throw new Error("Web Crypto API does not support streaming updates")}digest(n){throw new Error("Web Crypto API does not support streaming")}reset(){}};export{w as WebCryptoBackend};
1
+ var v="0123456789abcdef".split(""),l=v;function B(i){let n="";for(let o=0;o<4;o++)n+=l[i>>o*8+4&15]+l[i>>o*8&15];return n}function P(i){let n=i.length,o=new Array(n);for(let r=0;r<n;r++)o[r]=B(i[r]);return o.join("")}var a=P;function U(i,n){return i+n&4294967295}var c=U;function C(i,n,o,r,t){let e=t||c;return n=e(e(n,i),e(o,r)),n}function T(i,n,o,r){var e=(r||c)(i<<n|i>>>32-n,o);return e}function b(i,n,o,r,t,e,u){return n=C(i,n,r,e,u),T(n,t,o,u)}function h(i,n,o,r,t,e,u,m){return b(o&r|~o&t,n,o,e,u,m,i)}function g(i,n,o,r,t,e,u,m){return b(o&t|r&~t,n,o,e,u,m,i)}function y(i,n,o,r,t,e,u,m){return b(o^r^t,n,o,e,u,m,i)}function A(i,n,o,r,t,e,u,m){return b(r^(o|~t),n,o,e,u,m,i)}function D(i,n,o){typeof o>"u"&&(o=c);let r=i[0],t=i[1],e=i[2],u=i[3],m=h.bind(null,o);r=m(r,t,e,u,n[0],7,-680876936),u=m(u,r,t,e,n[1],12,-389564586),e=m(e,u,r,t,n[2],17,606105819),t=m(t,e,u,r,n[3],22,-1044525330),r=m(r,t,e,u,n[4],7,-176418897),u=m(u,r,t,e,n[5],12,1200080426),e=m(e,u,r,t,n[6],17,-1473231341),t=m(t,e,u,r,n[7],22,-45705983),r=m(r,t,e,u,n[8],7,1770035416),u=m(u,r,t,e,n[9],12,-1958414417),e=m(e,u,r,t,n[10],17,-42063),t=m(t,e,u,r,n[11],22,-1990404162),r=m(r,t,e,u,n[12],7,1804603682),u=m(u,r,t,e,n[13],12,-40341101),e=m(e,u,r,t,n[14],17,-1502002290),t=m(t,e,u,r,n[15],22,1236535329);let f=g.bind(null,o);r=f(r,t,e,u,n[1],5,-165796510),u=f(u,r,t,e,n[6],9,-1069501632),e=f(e,u,r,t,n[11],14,643717713),t=f(t,e,u,r,n[0],20,-373897302),r=f(r,t,e,u,n[5],5,-701558691),u=f(u,r,t,e,n[10],9,38016083),e=f(e,u,r,t,n[15],14,-660478335),t=f(t,e,u,r,n[4],20,-405537848),r=f(r,t,e,u,n[9],5,568446438),u=f(u,r,t,e,n[14],9,-1019803690),e=f(e,u,r,t,n[3],14,-187363961),t=f(t,e,u,r,n[8],20,1163531501),r=f(r,t,e,u,n[13],5,-1444681467),u=f(u,r,t,e,n[2],9,-51403784),e=f(e,u,r,t,n[7],14,1735328473),t=f(t,e,u,r,n[12],20,-1926607734);let d=y.bind(null,o);r=d(r,t,e,u,n[5],4,-378558),u=d(u,r,t,e,n[8],11,-2022574463),e=d(e,u,r,t,n[11],16,1839030562),t=d(t,e,u,r,n[14],23,-35309556),r=d(r,t,e,u,n[1],4,-1530992060),u=d(u,r,t,e,n[4],11,1272893353),e=d(e,u,r,t,n[7],16,-155497632),t=d(t,e,u,r,n[10],23,-1094730640),r=d(r,t,e,u,n[13],4,681279174),u=d(u,r,t,e,n[0],11,-358537222),e=d(e,u,r,t,n[3],16,-722521979),t=d(t,e,u,r,n[6],23,76029189),r=d(r,t,e,u,n[9],4,-640364487),u=d(u,r,t,e,n[12],11,-421815835),e=d(e,u,r,t,n[15],16,530742520),t=d(t,e,u,r,n[2],23,-995338651);let s=A.bind(null,o);r=s(r,t,e,u,n[0],6,-198630844),u=s(u,r,t,e,n[7],10,1126891415),e=s(e,u,r,t,n[14],15,-1416354905),t=s(t,e,u,r,n[5],21,-57434055),r=s(r,t,e,u,n[12],6,1700485571),u=s(u,r,t,e,n[3],10,-1894986606),e=s(e,u,r,t,n[10],15,-1051523),t=s(t,e,u,r,n[1],21,-2054922799),r=s(r,t,e,u,n[8],6,1873313359),u=s(u,r,t,e,n[15],10,-30611744),e=s(e,u,r,t,n[6],15,-1560198380),t=s(t,e,u,r,n[13],21,1309151649),r=s(r,t,e,u,n[4],6,-145523070),u=s(u,r,t,e,n[11],10,-1120210379),e=s(e,u,r,t,n[2],15,718787259),t=s(t,e,u,r,n[9],21,-343485551),i[0]=o(r,i[0]),i[1]=o(t,i[1]),i[2]=o(e,i[2]),i[3]=o(u,i[3]);}var p=D;function _(i){let n=[];for(let o=0;o<i.length;o++){let r=i.charCodeAt(o);if(r>=55296&&r<=56319&&o+1<i.length){let t=i.charCodeAt(o+1);t>=56320&&t<=57343&&(r=(r-55296<<10)+(t-56320)+65536,o++);}r<=127?n.push(r):r<=2047?(n.push(192|r>>6),n.push(128|r&63)):r<=65535?(n.push(224|r>>12),n.push(128|r>>6&63),n.push(128|r&63)):(n.push(240|r>>18),n.push(128|r>>12&63),n.push(128|r>>6&63),n.push(128|r&63));}return n}function j(i){let n=[];for(let o=0;o<16;o++)n[o]=i[o*4]+(i[o*4+1]<<8)+(i[o*4+2]<<16)+(i[o*4+3]<<24);return n}function E(i,n){let o=_(i),r=o.length,t=[1732584193,-271733879,-1732584194,271733878],e;for(e=64;e<=r;e+=64){let d=o.slice(e-64,e);p(t,j(d),n);}let u=o.slice(e-64),m=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=u.length;for(e=0;e<f;e++)m[e>>2]|=u[e]<<(e%4<<3);if(m[e>>2]|=128<<(e%4<<3),e>55)for(p(t,m,n),e=16;e--;)m[e]=0;return m[14]=r*8,p(t,m,n),t}var F=E;function x(i){return a(F(i,c))}var w=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(n){return x(n)}async hashBinary(n){let o=n instanceof ArrayBuffer?new TextDecoder().decode(n):new TextDecoder().decode(n);return x(o)}update(n){throw new Error("Web Crypto API does not support streaming updates")}digest(n){throw new Error("Web Crypto API does not support streaming")}reset(){}};export{w as WebCryptoBackend};
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var stream=require('stream'),D=require('fs');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var D__default=/*#__PURE__*/_interopDefault(D);var N=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var Z="0123456789abcdef".split(""),O=Z;function ee(i){let e="";for(let n=0;n<4;n++)e+=O[i>>n*8+4&15]+O[i>>n*8&15];return e}function re(i){let e=i.length,n=new Array(e);for(let r=0;r<e;r++)n[r]=ee(i[r]);return n.join("")}var S=re;function te(i,e){return i+e&4294967295}var b=te;function ne(i,e,n,r,t){let s=t||b;return e=s(s(e,i),s(n,r)),e}function se(i,e,n,r){var s=(r||b)(i<<e|i>>>32-e,n);return s}function C(i,e,n,r,t,s,a){return e=ne(i,e,r,s,a),se(e,t,n,a)}function I(i,e,n,r,t,s,a,o){return C(n&r|~n&t,e,n,s,a,o,i)}function L(i,e,n,r,t,s,a,o){return C(n&t|r&~t,e,n,s,a,o,i)}function $(i,e,n,r,t,s,a,o){return C(n^r^t,e,n,s,a,o,i)}function _(i,e,n,r,t,s,a,o){return C(r^(n|~t),e,n,s,a,o,i)}function ie(i,e,n){typeof n>"u"&&(n=b);let r=i[0],t=i[1],s=i[2],a=i[3],o=I.bind(null,n);r=o(r,t,s,a,e[0],7,-680876936),a=o(a,r,t,s,e[1],12,-389564586),s=o(s,a,r,t,e[2],17,606105819),t=o(t,s,a,r,e[3],22,-1044525330),r=o(r,t,s,a,e[4],7,-176418897),a=o(a,r,t,s,e[5],12,1200080426),s=o(s,a,r,t,e[6],17,-1473231341),t=o(t,s,a,r,e[7],22,-45705983),r=o(r,t,s,a,e[8],7,1770035416),a=o(a,r,t,s,e[9],12,-1958414417),s=o(s,a,r,t,e[10],17,-42063),t=o(t,s,a,r,e[11],22,-1990404162),r=o(r,t,s,a,e[12],7,1804603682),a=o(a,r,t,s,e[13],12,-40341101),s=o(s,a,r,t,e[14],17,-1502002290),t=o(t,s,a,r,e[15],22,1236535329);let c=L.bind(null,n);r=c(r,t,s,a,e[1],5,-165796510),a=c(a,r,t,s,e[6],9,-1069501632),s=c(s,a,r,t,e[11],14,643717713),t=c(t,s,a,r,e[0],20,-373897302),r=c(r,t,s,a,e[5],5,-701558691),a=c(a,r,t,s,e[10],9,38016083),s=c(s,a,r,t,e[15],14,-660478335),t=c(t,s,a,r,e[4],20,-405537848),r=c(r,t,s,a,e[9],5,568446438),a=c(a,r,t,s,e[14],9,-1019803690),s=c(s,a,r,t,e[3],14,-187363961),t=c(t,s,a,r,e[8],20,1163531501),r=c(r,t,s,a,e[13],5,-1444681467),a=c(a,r,t,s,e[2],9,-51403784),s=c(s,a,r,t,e[7],14,1735328473),t=c(t,s,a,r,e[12],20,-1926607734);let u=$.bind(null,n);r=u(r,t,s,a,e[5],4,-378558),a=u(a,r,t,s,e[8],11,-2022574463),s=u(s,a,r,t,e[11],16,1839030562),t=u(t,s,a,r,e[14],23,-35309556),r=u(r,t,s,a,e[1],4,-1530992060),a=u(a,r,t,s,e[4],11,1272893353),s=u(s,a,r,t,e[7],16,-155497632),t=u(t,s,a,r,e[10],23,-1094730640),r=u(r,t,s,a,e[13],4,681279174),a=u(a,r,t,s,e[0],11,-358537222),s=u(s,a,r,t,e[3],16,-722521979),t=u(t,s,a,r,e[6],23,76029189),r=u(r,t,s,a,e[9],4,-640364487),a=u(a,r,t,s,e[12],11,-421815835),s=u(s,a,r,t,e[15],16,530742520),t=u(t,s,a,r,e[2],23,-995338651);let f=_.bind(null,n);r=f(r,t,s,a,e[0],6,-198630844),a=f(a,r,t,s,e[7],10,1126891415),s=f(s,a,r,t,e[14],15,-1416354905),t=f(t,s,a,r,e[5],21,-57434055),r=f(r,t,s,a,e[12],6,1700485571),a=f(a,r,t,s,e[3],10,-1894986606),s=f(s,a,r,t,e[10],15,-1051523),t=f(t,s,a,r,e[1],21,-2054922799),r=f(r,t,s,a,e[8],6,1873313359),a=f(a,r,t,s,e[15],10,-30611744),s=f(s,a,r,t,e[6],15,-1560198380),t=f(t,s,a,r,e[13],21,1309151649),r=f(r,t,s,a,e[4],6,-145523070),a=f(a,r,t,s,e[11],10,-1120210379),s=f(s,a,r,t,e[2],15,718787259),t=f(t,s,a,r,e[9],21,-343485551),i[0]=n(r,i[0]),i[1]=n(t,i[1]),i[2]=n(s,i[2]),i[3]=n(a,i[3]);}var m=ie;function ae(i){let e=[];for(let n=0;n<64;n+=4)e[n>>2]=(i.charCodeAt(n)||0)+((i.charCodeAt(n+1)||0)<<8)+((i.charCodeAt(n+2)||0)<<16)+((i.charCodeAt(n+3)||0)<<24);return e}var G=ae;function oe(i,e){let n=i.length,r=[1732584193,-271733879,-1732584194,271733878],t;for(t=64;t<=n;t+=64)m(r,G(i.substring(t-64,t)),e);i=i.substring(t-64);var s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a=i.length;for(t=0;t<a;t++)s[t>>2]|=(i.charCodeAt(t)&255)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(m(r,s,e),t=16;t--;)s[t]=0;return s[14]=n*8,m(r,s,e),r}var z=oe;function ce(i,e){let n=i.length,r=[1732584193,-271733879,-1732584194,271733878],t;for(t=64;t<=n;t+=64){let o=ue(i,t-64);m(r,o,e);}let s=n-t+64,a=new Array(16).fill(0);for(let o=0;o<s;o++)a[o>>2]|=(i[n-s+o]&255)<<(o%4<<3);if(a[s>>2]|=128<<(s%4<<3),s>55){m(r,a,e);for(let o=0;o<16;o++)a[o]=0;}return a[14]=n*8,a[15]=0,m(r,a,e),r}function ue(i,e){let n=[];for(let r=0;r<64;r+=4)n[r>>2]=(i[e+r]||0)+((i[e+r+1]||0)<<8)+((i[e+r+2]||0)<<16)+((i[e+r+3]||0)<<24);return n}var K=ce;function l(i){return S(z(i,b))}function q(i){return S(K(i,b))}var g=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(e){return l(e)}async hashBinary(e){let n=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return l(n)}update(e){throw new Error("Web Crypto API does not support streaming updates")}digest(e){throw new Error("Web Crypto API does not support streaming")}reset(){}};var w=class{constructor(){this.name="nodecrypto";this.version="1.0.0";}static isAvailable(){try{return typeof N("crypto").createHash=="function"}catch{return false}}hash(e){return N("crypto").createHash("md5").update(e).digest("hex")}async hashBinary(e){let n=N("crypto"),r=e instanceof Uint8Array?e:new Uint8Array(e);return n.createHash("md5").update(r).digest("hex")}update(e){}digest(e){throw new Error("Node crypto streaming not implemented")}reset(){}};var B=class{constructor(){this.name="ie11";this.version="1.0.0";}static isAvailable(){if(typeof window>"u")return false;let e=window;return typeof e.msCrypto<"u"&&typeof e.msCrypto.subtle<"u"&&typeof e.msCrypto.subtle.digest=="function"}async hash(e){let r=new TextEncoder().encode(e);return await this.hashBinary(r)}async hashBinary(e){let n=window,r=e instanceof Uint8Array?e.buffer:e,t=await n.msCrypto.subtle.digest("MD5",r);return this.bufferToHex(t)}bufferToHex(e){return Array.from(new Uint8Array(e)).map(n=>n.toString(16).padStart(2,"0")).join("")}update(e){throw new Error("msCrypto does not support streaming updates")}digest(e){throw new Error("msCrypto does not support streaming")}reset(){}};var p=class i extends stream.Transform{constructor(n){super({readableObjectMode:false,writableObjectMode:false});this.initialMD5State=[1732584193,-271733879,-1732584194,271733878];this.bufferCapacity=64;this.buffer=new Uint8Array(this.bufferCapacity);this.add32=n?.add32||b,this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer};}_transform(n,r,t){try{let s=n,a=s.length;if(a===0){t();return}if(this.state.bufferLength>0){let u=this.state.bufferLength,f=64-u,h=Math.min(a,f);for(let d=0;d<h;d++)this.buffer[u+d]=s[d];if(this.state.bufferLength+=h,this.state.bufferLength===64&&this._processBufferBlock(),h===a){t();return}let y=a-h;for(let d=0;d<y;d++)s[d]=s[h+d];let v=Buffer.alloc(y);for(let d=0;d<y;d++)v[d]=s[d];s=v;}let o=Math.floor(s.length/64);for(let u=0;u<o;u++){let f=u*64,h=[];for(let y=0;y<16;y++){let v=f+y*4;h[y]=s[v]+(s[v+1]<<8)+(s[v+2]<<16)+(s[v+3]<<24);}m(this.state.state,h,this.add32),this.state.bytesProcessed+=64;}let c=s.length%64;if(c>0){this.buffer.length<c&&(this.buffer=new Uint8Array(c),this.state.buffer=this.buffer);for(let u=0;u<c;u++)this.buffer[u]=s[o*64+u];this.state.bufferLength=c;}t();}catch(s){t(s);}}_processBufferBlock(){let n=this.state.buffer,r=[];for(let t=0;t<16;t++){let s=t*4;r[t]=n[s]+(n[s+1]<<8)+(n[s+2]<<16)+(n[s+3]<<24);}m(this.state.state,r,this.add32),this.state.bytesProcessed+=64,this.state.bufferLength=0;}_flush(n){try{let{state:r,bufferLength:t,buffer:s}=this.state,a=new Array(16).fill(0);for(let c=0;c<t;c++)a[c>>2]|=(s[c]&255)<<(c%4<<3);if(a[t>>2]|=128<<(t%4<<3),t>55){m(r,a,this.add32);for(let c=0;c<16;c++)a[c]=0;}a[14]=(this.state.bytesProcessed+t)*8,a[15]=0,m(r,a,this.add32);let o=S(r);this.emit("md5",{digest:o,bytesProcessed:this.state.bytesProcessed+t}),n();}catch(r){n(r);}}getCurrentState(){return {state:[...this.state.state],bytesProcessed:this.state.bytesProcessed+this.state.bufferLength}}getBytesProcessed(){return this.state.bytesProcessed+this.state.bufferLength}reset(){this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer},this.buffer=new Uint8Array(this.bufferCapacity),this.state.buffer=this.buffer,this.state.bufferLength=0;}static fromStream(n,r){let t=new i(r),s=E.call(t,n);return {stream:t,result:s}}};function R(i){return new p(i)}async function E(i){return new Promise((e,n)=>{let r=[];i.pipe(this).on("md5",t=>{r.push(t);}).on("error",n).on("finish",()=>{e(r[0]);});})}function j(i,e){let n=new p(e),r=E.call(n,i);return {stream:n,result:r}}var A=class{constructor(){this.name="stream";this.version="0.1.0";this.state=null;}initNodeStream(e){this.state={stream:e,type:"node"};}initWhatWGStream(e){this.state={stream:e,type:"whatwg"};}async hash(e){let n=new p;return (await new Promise((t,s)=>{n.on("md5",a=>t(a)).on("error",s).end(e);})).digest}async hashBinary(e){let n=new p,r;return e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),(await new Promise((s,a)=>{n.on("md5",o=>s(o)).on("error",a).end(r);})).digest}update(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let n=this.state.stream,r;typeof e=="string"||e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),n.write(r);}}digest(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let n=this.state.stream;return n.end(),new Promise((r,t)=>{n.on("md5",s=>{if(e==="buffer"){let a=s.digest,o=[];for(let c=0;c<a.length;c+=2)o.push(parseInt(a.substring(c,c+2),16));r(Buffer.from(o));}else r(s.digest);}).on("error",t);})}else return this.state.stream.getResult().then(r=>r.digest)}reset(){this.state&&this.state.type==="node"&&this.state.stream.reset();}static isAvailable(){return true}};var k=class{constructor(){this.name="purejs";this.version="0.1.0";this.state={data:"",finished:false};}hash(e){return l(e)}async hashBinary(e){let n=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return l(n)}update(e){this.state.finished&&(this.state={data:"",finished:false}),e instanceof ArrayBuffer?this.state.data+=new TextDecoder().decode(e):e instanceof Uint8Array?this.state.data+=new TextDecoder().decode(e):this.state.data+=e;}digest(e){let n=l(this.state.data);return this.state.finished=true,e==="buffer"?this.hexToBuffer(n):n}reset(){this.state={data:"",finished:false};}static isAvailable(){return true}hexToBuffer(e){let n=[];for(let r=0;r<e.length;r+=2)n.push(parseInt(e.substring(r,r+2),16));return new Uint8Array(n)}};async function de(i){switch(i){case "webcrypto":let e=g.isAvailable();return {backend:"webcrypto",available:e,reason:e?void 0:"Web Crypto API not available"};case "nodecrypto":let n=w.isAvailable();return {backend:"nodecrypto",available:n,reason:n?void 0:"Node.js crypto not available"};case "ie11":let r=B.isAvailable();return {backend:"ie11",available:r,reason:r?void 0:"IE11 msCrypto not available"};case "purejs":return {backend:"purejs",available:true,reason:"Always available"};case "stream":let t=typeof process<"u"&&process.versions&&"node"in process.versions,s=typeof window<"u";return {backend:"stream",available:t||s,reason:t||s?void 0:"Streams not available"};default:return {backend:i||"unknown",available:false,reason:"Unknown backend"}}}async function x(){let i=["webcrypto","nodecrypto","ie11","purejs","stream"],e=[];for(let n of i){let{available:r}=await de(n);r&&e.push(n);}return e}var me=[{name:"nodecrypto",priority:1,description:"Node.js native crypto (fastest)"},{name:"webcrypto",priority:2,description:"Web Crypto API (fast, hardware accelerated)"},{name:"ie11",priority:3,description:"IE11 msCrypto (legacy)"},{name:"stream",priority:4,description:"Streaming backend (for large files and memory efficiency)"},{name:"purejs",priority:5,description:"Pure JavaScript (always available, slower)"}];function F(i){let e=[...me].sort((n,r)=>n.priority-r.priority);for(let{name:n}of e)if(i.includes(n))return n;return "purejs"}var M=class i{constructor(){}static getInstance(){return i.instance||(i.instance=new i),i.instance}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new B;case "stream":return new A;default:return new k}}async createBackend(e){let n=e||F(await x());return this.createBackendByName(n)}},le=M.getInstance(),P=class{constructor(e=["nodecrypto","webcrypto","stream","ie11","purejs"]){this.detector=M.getInstance(),this.fallbackOrder=e;}async execute(e){let n=[];for(let r of this.fallbackOrder)try{let t=await this.detector.createBackendByName(r),s=await e(t);return {success:!0,backend:r,data:s}}catch(t){if(n.push({backend:r,error:t}),r===this.fallbackOrder[this.fallbackOrder.length-1])return {success:false,backend:r,data:null,errors:n}}return {success:false,backend:"",data:null,errors:n}}async hash(e){return this.execute(async n=>n.hash(e))}async hashBinary(e){return this.execute(async n=>n.hashBinary(e))}async getBestBackend(){let e=await this.getAvailableBackends();return e.length===0?"purejs":e[0]}async getAvailableBackends(){let e=[];for(let n of this.fallbackOrder)try{await this.detector.createBackendByName(n),e.push(n);}catch{}return e}getMetrics(){return {}}},be=new P;async function pe(i,e={}){let n=new P;if(e.forceBackend)return (await n.detector.createBackendByName(e.forceBackend)).hash(i);if(e.fallback===false)return (await n.detector.createBackend()).hash(i);let r=await n.hash(i);if(r.success)return e.reportFallback&&r.backend!=="nodecrypto"&&r.backend!=="webcrypto"&&console.info(`MD5 used fallback backend: ${r.backend}`),r.data;let t=r.errors?r.errors.map(s=>`${s.backend}: ${s.error.message}`).join(", "):"All backends failed";throw new Error(`MD5 hash failed after all attempts: ${t}`)}var U=class{constructor(){this.metrics={nodecrypto:{success:0,fail:0},webcrypto:{success:0,fail:0},ie11:{success:0,fail:0},stream:{success:0,fail:0},purejs:{success:0,fail:0}};}recordSuccess(e){this.metrics[e]&&this.metrics[e].success++;}recordFail(e){this.metrics[e]&&this.metrics[e].fail++;}getMetrics(){return this.metrics}getSummary(){return `Total operations: ${Object.values(this.metrics).reduce((n,r)=>n+r.success+r.fail,0)}
2
- `+Object.entries(this.metrics).map(([,n])=>`${n.success} success, ${n.fail} fail`).join(`
3
- `)}reset(){Object.keys(this.metrics).forEach(e=>{this.metrics[e]={success:0,fail:0};});}},he=new U;async function W(i,e={}){if(typeof i!="string"||i.trim()==="")throw new Error("Invalid file path: must be a non-empty string");if(!D__default.default.existsSync(i))throw new Error(`File not found: ${i}`);let n;try{n=D__default.default.statSync(i);}catch(t){throw new Error(`Failed to access file ${i}: ${t.message}`)}if(!n.isFile())throw new Error(`Path is not a file: ${i}`);let r=D__default.default.createReadStream(i,{highWaterMark:e.chunkSize||64*1024});try{return await T(r,{onProgress:e.onProgress,totalSize:n.size})}finally{r.destroy();}}async function T(i,e={}){if(!i||typeof i.on!="function")throw new Error("Invalid readable stream: stream must have event listener support");let n=R(),r=0;return e.onProgress&&i.on("data",t=>{r+=t.length,e.onProgress?.(r);}),i.on("error",t=>{n.destroy(t);}),i.on("end",()=>{n.end();}),new Promise((t,s)=>{n.on("md5",a=>{t(a);}).on("error",a=>{s(a);}),i.pipe(n);})}async function J(i,e={}){return (await W(i,e)).digest}async function Y(i,e={}){return (await T(i,e)).digest}async function Q(i,e,n={}){return (await W(i,n)).digest.toLowerCase()===e.toLowerCase()}function V(i){if(typeof i!="string"||i.trim()==="")throw new Error("Invalid file path: must be a non-empty string");if(!D__default.default.existsSync(i))throw new Error(`File not found: ${i}`);let e;try{e=D__default.default.statSync(i);}catch(r){throw new Error(`Failed to access file ${i}: ${r.message}`)}if(!e.isFile())throw new Error(`Path is not a file: ${i}`);let n;try{n=D__default.default.readFileSync(i);}catch(r){throw new Error(`Failed to read file ${i}: ${r.message}`)}return q(n)}function X(i,e){let n=0;return r=>{if(i>0){let t=Math.min(100,r/i*100);Math.floor(t)!==Math.floor(n)&&(e(t),n=t);}}}Object.defineProperty(p,"fromStream",{value:j,writable:false,configurable:false});var H=class{constructor(){this.backend=null;this.backendName=null;}async hash(e){return (await this.getBackend()).hash(e)}async hashBinary(e){return (await this.getBackend()).hashBinary(e)}async getBackendName(){if(!this.backendName){let e=await x();this.backendName=F(e);}return this.backendName}static async getAvailableBackends(){return await x()}async useBackend(e){this.backend=await this.createBackendByName(e),this.backendName=e;}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new B;case "stream":return new A;default:return {hash:n=>l(n),hashBinary:async n=>l(n instanceof Uint8Array?new TextDecoder().decode(n):new TextDecoder().decode(new Uint8Array(n))),update:()=>{},digest:()=>"",reset:()=>{},name:"purejs",version:"0.1.0"}}}async getBackend(){if(this.backend)return this.backend;let e=await x(),n=F(e);return this.backend=await this.createBackendByName(n),this.backendName=n,this.backend}};function Ar(i){return l(i)}var ye=new H;async function xr(i){return ye.hash(i)}exports.BackendDetector=M;exports.FallbackManager=P;exports.IE11Backend=B;exports.MD5Stream=p;exports.MetricsCollector=U;exports.NodeCryptoBackend=w;exports.PureJSBackend=k;exports.WebCryptoBackend=g;exports.createMD5Stream=R;exports.createProgressTracker=X;exports.detector=le;exports.fallbackManager=be;exports.fromStream=j;exports.getAllAvailableBackends=x;exports.getBestAvailableBackend=F;exports.hashFile=W;exports.hashFileDigest=J;exports.hashFileStream=T;exports.hashFileStreamDigest=Y;exports.hashFileSync=V;exports.md5=Ar;exports.md5Adapter=ye;exports.md5Async=xr;exports.md5Core=l;exports.md5Original=l;exports.metrics=he;exports.pipeThroughMD5=E;exports.robustHash=pe;exports.verifyFile=Q;
1
+ 'use strict';var stream=require('stream'),D=require('fs');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var D__default=/*#__PURE__*/_interopDefault(D);var N=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var X="0123456789abcdef".split(""),O=X;function Z(i){let e="";for(let t=0;t<4;t++)e+=O[i>>t*8+4&15]+O[i>>t*8&15];return e}function ee(i){let e=i.length,t=new Array(e);for(let r=0;r<e;r++)t[r]=Z(i[r]);return t.join("")}var S=ee;function re(i,e){return i+e&4294967295}var b=re;function te(i,e,t,r,s){let n=s||b;return e=n(n(e,i),n(t,r)),e}function ne(i,e,t,r){var n=(r||b)(i<<e|i>>>32-e,t);return n}function C(i,e,t,r,s,n,a){return e=te(i,e,r,n,a),ne(e,s,t,a)}function I(i,e,t,r,s,n,a,o){return C(t&r|~t&s,e,t,n,a,o,i)}function L(i,e,t,r,s,n,a,o){return C(t&s|r&~s,e,t,n,a,o,i)}function $(i,e,t,r,s,n,a,o){return C(t^r^s,e,t,n,a,o,i)}function _(i,e,t,r,s,n,a,o){return C(r^(t|~s),e,t,n,a,o,i)}function se(i,e,t){typeof t>"u"&&(t=b);let r=i[0],s=i[1],n=i[2],a=i[3],o=I.bind(null,t);r=o(r,s,n,a,e[0],7,-680876936),a=o(a,r,s,n,e[1],12,-389564586),n=o(n,a,r,s,e[2],17,606105819),s=o(s,n,a,r,e[3],22,-1044525330),r=o(r,s,n,a,e[4],7,-176418897),a=o(a,r,s,n,e[5],12,1200080426),n=o(n,a,r,s,e[6],17,-1473231341),s=o(s,n,a,r,e[7],22,-45705983),r=o(r,s,n,a,e[8],7,1770035416),a=o(a,r,s,n,e[9],12,-1958414417),n=o(n,a,r,s,e[10],17,-42063),s=o(s,n,a,r,e[11],22,-1990404162),r=o(r,s,n,a,e[12],7,1804603682),a=o(a,r,s,n,e[13],12,-40341101),n=o(n,a,r,s,e[14],17,-1502002290),s=o(s,n,a,r,e[15],22,1236535329);let c=L.bind(null,t);r=c(r,s,n,a,e[1],5,-165796510),a=c(a,r,s,n,e[6],9,-1069501632),n=c(n,a,r,s,e[11],14,643717713),s=c(s,n,a,r,e[0],20,-373897302),r=c(r,s,n,a,e[5],5,-701558691),a=c(a,r,s,n,e[10],9,38016083),n=c(n,a,r,s,e[15],14,-660478335),s=c(s,n,a,r,e[4],20,-405537848),r=c(r,s,n,a,e[9],5,568446438),a=c(a,r,s,n,e[14],9,-1019803690),n=c(n,a,r,s,e[3],14,-187363961),s=c(s,n,a,r,e[8],20,1163531501),r=c(r,s,n,a,e[13],5,-1444681467),a=c(a,r,s,n,e[2],9,-51403784),n=c(n,a,r,s,e[7],14,1735328473),s=c(s,n,a,r,e[12],20,-1926607734);let u=$.bind(null,t);r=u(r,s,n,a,e[5],4,-378558),a=u(a,r,s,n,e[8],11,-2022574463),n=u(n,a,r,s,e[11],16,1839030562),s=u(s,n,a,r,e[14],23,-35309556),r=u(r,s,n,a,e[1],4,-1530992060),a=u(a,r,s,n,e[4],11,1272893353),n=u(n,a,r,s,e[7],16,-155497632),s=u(s,n,a,r,e[10],23,-1094730640),r=u(r,s,n,a,e[13],4,681279174),a=u(a,r,s,n,e[0],11,-358537222),n=u(n,a,r,s,e[3],16,-722521979),s=u(s,n,a,r,e[6],23,76029189),r=u(r,s,n,a,e[9],4,-640364487),a=u(a,r,s,n,e[12],11,-421815835),n=u(n,a,r,s,e[15],16,530742520),s=u(s,n,a,r,e[2],23,-995338651);let f=_.bind(null,t);r=f(r,s,n,a,e[0],6,-198630844),a=f(a,r,s,n,e[7],10,1126891415),n=f(n,a,r,s,e[14],15,-1416354905),s=f(s,n,a,r,e[5],21,-57434055),r=f(r,s,n,a,e[12],6,1700485571),a=f(a,r,s,n,e[3],10,-1894986606),n=f(n,a,r,s,e[10],15,-1051523),s=f(s,n,a,r,e[1],21,-2054922799),r=f(r,s,n,a,e[8],6,1873313359),a=f(a,r,s,n,e[15],10,-30611744),n=f(n,a,r,s,e[6],15,-1560198380),s=f(s,n,a,r,e[13],21,1309151649),r=f(r,s,n,a,e[4],6,-145523070),a=f(a,r,s,n,e[11],10,-1120210379),n=f(n,a,r,s,e[2],15,718787259),s=f(s,n,a,r,e[9],21,-343485551),i[0]=t(r,i[0]),i[1]=t(s,i[1]),i[2]=t(n,i[2]),i[3]=t(a,i[3]);}var m=se;function ie(i){let e=[];for(let t=0;t<i.length;t++){let r=i.charCodeAt(t);if(r>=55296&&r<=56319&&t+1<i.length){let s=i.charCodeAt(t+1);s>=56320&&s<=57343&&(r=(r-55296<<10)+(s-56320)+65536,t++);}r<=127?e.push(r):r<=2047?(e.push(192|r>>6),e.push(128|r&63)):r<=65535?(e.push(224|r>>12),e.push(128|r>>6&63),e.push(128|r&63)):(e.push(240|r>>18),e.push(128|r>>12&63),e.push(128|r>>6&63),e.push(128|r&63));}return e}function ae(i){let e=[];for(let t=0;t<16;t++)e[t]=i[t*4]+(i[t*4+1]<<8)+(i[t*4+2]<<16)+(i[t*4+3]<<24);return e}function oe(i,e){let t=ie(i),r=t.length,s=[1732584193,-271733879,-1732584194,271733878],n;for(n=64;n<=r;n+=64){let u=t.slice(n-64,n);m(s,ae(u),e);}let a=t.slice(n-64),o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=a.length;for(n=0;n<c;n++)o[n>>2]|=a[n]<<(n%4<<3);if(o[n>>2]|=128<<(n%4<<3),n>55)for(m(s,o,e),n=16;n--;)o[n]=0;return o[14]=r*8,m(s,o,e),s}var G=oe;function ce(i,e){let t=i.length,r=[1732584193,-271733879,-1732584194,271733878],s;for(s=64;s<=t;s+=64){let o=ue(i,s-64);m(r,o,e);}let n=t-s+64,a=new Array(16).fill(0);for(let o=0;o<n;o++)a[o>>2]|=(i[t-n+o]&255)<<(o%4<<3);if(a[n>>2]|=128<<(n%4<<3),n>55){m(r,a,e);for(let o=0;o<16;o++)a[o]=0;}return a[14]=t*8,a[15]=0,m(r,a,e),r}function ue(i,e){let t=[];for(let r=0;r<64;r+=4)t[r>>2]=(i[e+r]||0)+((i[e+r+1]||0)<<8)+((i[e+r+2]||0)<<16)+((i[e+r+3]||0)<<24);return t}var z=ce;function l(i){return S(G(i,b))}function K(i){return S(z(i,b))}var g=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(e){return l(e)}async hashBinary(e){let t=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return l(t)}update(e){throw new Error("Web Crypto API does not support streaming updates")}digest(e){throw new Error("Web Crypto API does not support streaming")}reset(){}};var w=class{constructor(){this.name="nodecrypto";this.version="1.0.0";}static isAvailable(){try{return typeof N("crypto").createHash=="function"}catch{return false}}hash(e){return N("crypto").createHash("md5").update(e).digest("hex")}async hashBinary(e){let t=N("crypto"),r=e instanceof Uint8Array?e:new Uint8Array(e);return t.createHash("md5").update(r).digest("hex")}update(e){}digest(e){throw new Error("Node crypto streaming not implemented")}reset(){}};var B=class{constructor(){this.name="ie11";this.version="1.0.0";}static isAvailable(){if(typeof window>"u")return false;let e=window;return typeof e.msCrypto<"u"&&typeof e.msCrypto.subtle<"u"&&typeof e.msCrypto.subtle.digest=="function"}async hash(e){let r=new TextEncoder().encode(e);return await this.hashBinary(r)}async hashBinary(e){let t=window,r=e instanceof Uint8Array?e.buffer:e,s=await t.msCrypto.subtle.digest("MD5",r);return this.bufferToHex(s)}bufferToHex(e){return Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")}update(e){throw new Error("msCrypto does not support streaming updates")}digest(e){throw new Error("msCrypto does not support streaming")}reset(){}};var p=class i extends stream.Transform{constructor(t){super({readableObjectMode:false,writableObjectMode:false});this.initialMD5State=[1732584193,-271733879,-1732584194,271733878];this.bufferCapacity=64;this.buffer=new Uint8Array(this.bufferCapacity);this.add32=t?.add32||b,this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer};}_transform(t,r,s){try{let n=t,a=n.length;if(a===0){s();return}if(this.state.bufferLength>0){let u=this.state.bufferLength,f=64-u,h=Math.min(a,f);for(let d=0;d<h;d++)this.buffer[u+d]=n[d];if(this.state.bufferLength+=h,this.state.bufferLength===64&&this._processBufferBlock(),h===a){s();return}let y=a-h;for(let d=0;d<y;d++)n[d]=n[h+d];let x=Buffer.alloc(y);for(let d=0;d<y;d++)x[d]=n[d];n=x;}let o=Math.floor(n.length/64);for(let u=0;u<o;u++){let f=u*64,h=[];for(let y=0;y<16;y++){let x=f+y*4;h[y]=n[x]+(n[x+1]<<8)+(n[x+2]<<16)+(n[x+3]<<24);}m(this.state.state,h,this.add32),this.state.bytesProcessed+=64;}let c=n.length%64;if(c>0){this.buffer.length<c&&(this.buffer=new Uint8Array(c),this.state.buffer=this.buffer);for(let u=0;u<c;u++)this.buffer[u]=n[o*64+u];this.state.bufferLength=c;}s();}catch(n){s(n);}}_processBufferBlock(){let t=this.state.buffer,r=[];for(let s=0;s<16;s++){let n=s*4;r[s]=t[n]+(t[n+1]<<8)+(t[n+2]<<16)+(t[n+3]<<24);}m(this.state.state,r,this.add32),this.state.bytesProcessed+=64,this.state.bufferLength=0;}_flush(t){try{let{state:r,bufferLength:s,buffer:n}=this.state,a=new Array(16).fill(0);for(let c=0;c<s;c++)a[c>>2]|=(n[c]&255)<<(c%4<<3);if(a[s>>2]|=128<<(s%4<<3),s>55){m(r,a,this.add32);for(let c=0;c<16;c++)a[c]=0;}a[14]=(this.state.bytesProcessed+s)*8,a[15]=0,m(r,a,this.add32);let o=S(r);this.emit("md5",{digest:o,bytesProcessed:this.state.bytesProcessed+s}),t();}catch(r){t(r);}}getCurrentState(){return {state:[...this.state.state],bytesProcessed:this.state.bytesProcessed+this.state.bufferLength}}getBytesProcessed(){return this.state.bytesProcessed+this.state.bufferLength}reset(){this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer},this.buffer=new Uint8Array(this.bufferCapacity),this.state.buffer=this.buffer,this.state.bufferLength=0;}static fromStream(t,r){let s=new i(r),n=U.call(s,t);return {stream:s,result:n}}};function R(i){return new p(i)}async function U(i){return new Promise((e,t)=>{let r=[];i.pipe(this).on("md5",s=>{r.push(s);}).on("error",t).on("finish",()=>{e(r[0]);});})}function j(i,e){let t=new p(e),r=U.call(t,i);return {stream:t,result:r}}var A=class{constructor(){this.name="stream";this.version="0.1.0";this.state=null;}initNodeStream(e){this.state={stream:e,type:"node"};}initWhatWGStream(e){this.state={stream:e,type:"whatwg"};}async hash(e){let t=new p;return (await new Promise((s,n)=>{t.on("md5",a=>s(a)).on("error",n).end(e);})).digest}async hashBinary(e){let t=new p,r;return e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),(await new Promise((n,a)=>{t.on("md5",o=>n(o)).on("error",a).end(r);})).digest}update(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let t=this.state.stream,r;typeof e=="string"||e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),t.write(r);}}digest(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let t=this.state.stream;return t.end(),new Promise((r,s)=>{t.on("md5",n=>{if(e==="buffer"){let a=n.digest,o=[];for(let c=0;c<a.length;c+=2)o.push(parseInt(a.substring(c,c+2),16));r(Buffer.from(o));}else r(n.digest);}).on("error",s);})}else return this.state.stream.getResult().then(r=>r.digest)}reset(){this.state&&this.state.type==="node"&&this.state.stream.reset();}static isAvailable(){return true}};var k=class{constructor(){this.name="purejs";this.version="0.1.0";this.state={data:"",finished:false};}hash(e){return l(e)}async hashBinary(e){let t=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return l(t)}update(e){this.state.finished&&(this.state={data:"",finished:false}),e instanceof ArrayBuffer?this.state.data+=new TextDecoder().decode(e):e instanceof Uint8Array?this.state.data+=new TextDecoder().decode(e):this.state.data+=e;}digest(e){let t=l(this.state.data);return this.state.finished=true,e==="buffer"?this.hexToBuffer(t):t}reset(){this.state={data:"",finished:false};}static isAvailable(){return true}hexToBuffer(e){let t=[];for(let r=0;r<e.length;r+=2)t.push(parseInt(e.substring(r,r+2),16));return new Uint8Array(t)}};async function de(i){switch(i){case "webcrypto":let e=g.isAvailable();return {backend:"webcrypto",available:e,reason:e?void 0:"Web Crypto API not available"};case "nodecrypto":let t=w.isAvailable();return {backend:"nodecrypto",available:t,reason:t?void 0:"Node.js crypto not available"};case "ie11":let r=B.isAvailable();return {backend:"ie11",available:r,reason:r?void 0:"IE11 msCrypto not available"};case "purejs":return {backend:"purejs",available:true,reason:"Always available"};case "stream":let s=typeof process<"u"&&process.versions&&"node"in process.versions,n=typeof window<"u";return {backend:"stream",available:s||n,reason:s||n?void 0:"Streams not available"};default:return {backend:i||"unknown",available:false,reason:"Unknown backend"}}}async function v(){let i=["webcrypto","nodecrypto","ie11","purejs","stream"],e=[];for(let t of i){let{available:r}=await de(t);r&&e.push(t);}return e}var me=[{name:"nodecrypto",priority:1,description:"Node.js native crypto (fastest)"},{name:"webcrypto",priority:2,description:"Web Crypto API (fast, hardware accelerated)"},{name:"ie11",priority:3,description:"IE11 msCrypto (legacy)"},{name:"stream",priority:4,description:"Streaming backend (for large files and memory efficiency)"},{name:"purejs",priority:5,description:"Pure JavaScript (always available, slower)"}];function F(i){let e=[...me].sort((t,r)=>t.priority-r.priority);for(let{name:t}of e)if(i.includes(t))return t;return "purejs"}var M=class i{constructor(){}static getInstance(){return i.instance||(i.instance=new i),i.instance}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new B;case "stream":return new A;default:return new k}}async createBackend(e){let t=e||F(await v());return this.createBackendByName(t)}},le=M.getInstance(),P=class{constructor(e=["nodecrypto","webcrypto","stream","ie11","purejs"]){this.detector=M.getInstance(),this.fallbackOrder=e;}async execute(e){let t=[];for(let r of this.fallbackOrder)try{let s=await this.detector.createBackendByName(r),n=await e(s);return {success:!0,backend:r,data:n}}catch(s){if(t.push({backend:r,error:s}),r===this.fallbackOrder[this.fallbackOrder.length-1])return {success:false,backend:r,data:null,errors:t}}return {success:false,backend:"",data:null,errors:t}}async hash(e){return this.execute(async t=>t.hash(e))}async hashBinary(e){return this.execute(async t=>t.hashBinary(e))}async getBestBackend(){let e=await this.getAvailableBackends();return e.length===0?"purejs":e[0]}async getAvailableBackends(){let e=[];for(let t of this.fallbackOrder)try{await this.detector.createBackendByName(t),e.push(t);}catch{}return e}getMetrics(){return {}}},be=new P;async function pe(i,e={}){let t=new P;if(e.forceBackend)return (await t.detector.createBackendByName(e.forceBackend)).hash(i);if(e.fallback===false)return (await t.detector.createBackend()).hash(i);let r=await t.hash(i);if(r.success)return e.reportFallback&&r.backend!=="nodecrypto"&&r.backend!=="webcrypto"&&console.info(`MD5 used fallback backend: ${r.backend}`),r.data;let s=r.errors?r.errors.map(n=>`${n.backend}: ${n.error.message}`).join(", "):"All backends failed";throw new Error(`MD5 hash failed after all attempts: ${s}`)}var E=class{constructor(){this.metrics={nodecrypto:{success:0,fail:0},webcrypto:{success:0,fail:0},ie11:{success:0,fail:0},stream:{success:0,fail:0},purejs:{success:0,fail:0}};}recordSuccess(e){this.metrics[e]&&this.metrics[e].success++;}recordFail(e){this.metrics[e]&&this.metrics[e].fail++;}getMetrics(){return this.metrics}getSummary(){return `Total operations: ${Object.values(this.metrics).reduce((t,r)=>t+r.success+r.fail,0)}
2
+ `+Object.entries(this.metrics).map(([,t])=>`${t.success} success, ${t.fail} fail`).join(`
3
+ `)}reset(){Object.keys(this.metrics).forEach(e=>{this.metrics[e]={success:0,fail:0};});}},he=new E;async function T(i,e={}){if(typeof i!="string"||i.trim()==="")throw new Error("Invalid file path: must be a non-empty string");if(!D__default.default.existsSync(i))throw new Error(`File not found: ${i}`);let t;try{t=D__default.default.statSync(i);}catch(s){throw new Error(`Failed to access file ${i}: ${s.message}`)}if(!t.isFile())throw new Error(`Path is not a file: ${i}`);let r=D__default.default.createReadStream(i,{highWaterMark:e.chunkSize||64*1024});try{return await W(r,{onProgress:e.onProgress,totalSize:t.size})}finally{r.destroy();}}async function W(i,e={}){if(!i||typeof i.on!="function")throw new Error("Invalid readable stream: stream must have event listener support");let t=R(),r=0;return e.onProgress&&i.on("data",s=>{r+=s.length,e.onProgress?.(r);}),i.on("error",s=>{t.destroy(s);}),i.on("end",()=>{t.end();}),new Promise((s,n)=>{t.on("md5",a=>{s(a);}).on("error",a=>{n(a);}),i.pipe(t);})}async function q(i,e={}){return (await T(i,e)).digest}async function J(i,e={}){return (await W(i,e)).digest}async function Y(i,e,t={}){return (await T(i,t)).digest.toLowerCase()===e.toLowerCase()}function Q(i){if(typeof i!="string"||i.trim()==="")throw new Error("Invalid file path: must be a non-empty string");if(!D__default.default.existsSync(i))throw new Error(`File not found: ${i}`);let e;try{e=D__default.default.statSync(i);}catch(r){throw new Error(`Failed to access file ${i}: ${r.message}`)}if(!e.isFile())throw new Error(`Path is not a file: ${i}`);let t;try{t=D__default.default.readFileSync(i);}catch(r){throw new Error(`Failed to read file ${i}: ${r.message}`)}return K(t)}function V(i,e){let t=0;return r=>{if(i>0){let s=Math.min(100,r/i*100);Math.floor(s)!==Math.floor(t)&&(e(s),t=s);}}}Object.defineProperty(p,"fromStream",{value:j,writable:false,configurable:false});var H=class{constructor(){this.backend=null;this.backendName=null;}async hash(e){return (await this.getBackend()).hash(e)}async hashBinary(e){return (await this.getBackend()).hashBinary(e)}async getBackendName(){if(!this.backendName){let e=await v();this.backendName=F(e);}return this.backendName}static async getAvailableBackends(){return await v()}async useBackend(e){this.backend=await this.createBackendByName(e),this.backendName=e;}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new B;case "stream":return new A;default:return {hash:t=>l(t),hashBinary:async t=>l(t instanceof Uint8Array?new TextDecoder().decode(t):new TextDecoder().decode(new Uint8Array(t))),update:()=>{},digest:()=>"",reset:()=>{},name:"purejs",version:"0.1.0"}}}async getBackend(){if(this.backend)return this.backend;let e=await v(),t=F(e);return this.backend=await this.createBackendByName(t),this.backendName=t,this.backend}};function Br(i){return l(i)}var ye=new H;async function xr(i){return ye.hash(i)}exports.BackendDetector=M;exports.FallbackManager=P;exports.IE11Backend=B;exports.MD5Stream=p;exports.MetricsCollector=E;exports.NodeCryptoBackend=w;exports.PureJSBackend=k;exports.WebCryptoBackend=g;exports.createMD5Stream=R;exports.createProgressTracker=V;exports.detector=le;exports.fallbackManager=be;exports.fromStream=j;exports.getAllAvailableBackends=v;exports.getBestAvailableBackend=F;exports.hashFile=T;exports.hashFileDigest=q;exports.hashFileStream=W;exports.hashFileStreamDigest=J;exports.hashFileSync=Q;exports.md5=Br;exports.md5Adapter=ye;exports.md5Async=xr;exports.md5Core=l;exports.md5Original=l;exports.metrics=he;exports.pipeThroughMD5=U;exports.robustHash=pe;exports.verifyFile=Y;
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import {Transform}from'stream';import D from'fs';var N=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var Z="0123456789abcdef".split(""),O=Z;function ee(i){let e="";for(let n=0;n<4;n++)e+=O[i>>n*8+4&15]+O[i>>n*8&15];return e}function re(i){let e=i.length,n=new Array(e);for(let r=0;r<e;r++)n[r]=ee(i[r]);return n.join("")}var S=re;function te(i,e){return i+e&4294967295}var b=te;function ne(i,e,n,r,t){let s=t||b;return e=s(s(e,i),s(n,r)),e}function se(i,e,n,r){var s=(r||b)(i<<e|i>>>32-e,n);return s}function C(i,e,n,r,t,s,a){return e=ne(i,e,r,s,a),se(e,t,n,a)}function I(i,e,n,r,t,s,a,o){return C(n&r|~n&t,e,n,s,a,o,i)}function L(i,e,n,r,t,s,a,o){return C(n&t|r&~t,e,n,s,a,o,i)}function $(i,e,n,r,t,s,a,o){return C(n^r^t,e,n,s,a,o,i)}function _(i,e,n,r,t,s,a,o){return C(r^(n|~t),e,n,s,a,o,i)}function ie(i,e,n){typeof n>"u"&&(n=b);let r=i[0],t=i[1],s=i[2],a=i[3],o=I.bind(null,n);r=o(r,t,s,a,e[0],7,-680876936),a=o(a,r,t,s,e[1],12,-389564586),s=o(s,a,r,t,e[2],17,606105819),t=o(t,s,a,r,e[3],22,-1044525330),r=o(r,t,s,a,e[4],7,-176418897),a=o(a,r,t,s,e[5],12,1200080426),s=o(s,a,r,t,e[6],17,-1473231341),t=o(t,s,a,r,e[7],22,-45705983),r=o(r,t,s,a,e[8],7,1770035416),a=o(a,r,t,s,e[9],12,-1958414417),s=o(s,a,r,t,e[10],17,-42063),t=o(t,s,a,r,e[11],22,-1990404162),r=o(r,t,s,a,e[12],7,1804603682),a=o(a,r,t,s,e[13],12,-40341101),s=o(s,a,r,t,e[14],17,-1502002290),t=o(t,s,a,r,e[15],22,1236535329);let c=L.bind(null,n);r=c(r,t,s,a,e[1],5,-165796510),a=c(a,r,t,s,e[6],9,-1069501632),s=c(s,a,r,t,e[11],14,643717713),t=c(t,s,a,r,e[0],20,-373897302),r=c(r,t,s,a,e[5],5,-701558691),a=c(a,r,t,s,e[10],9,38016083),s=c(s,a,r,t,e[15],14,-660478335),t=c(t,s,a,r,e[4],20,-405537848),r=c(r,t,s,a,e[9],5,568446438),a=c(a,r,t,s,e[14],9,-1019803690),s=c(s,a,r,t,e[3],14,-187363961),t=c(t,s,a,r,e[8],20,1163531501),r=c(r,t,s,a,e[13],5,-1444681467),a=c(a,r,t,s,e[2],9,-51403784),s=c(s,a,r,t,e[7],14,1735328473),t=c(t,s,a,r,e[12],20,-1926607734);let u=$.bind(null,n);r=u(r,t,s,a,e[5],4,-378558),a=u(a,r,t,s,e[8],11,-2022574463),s=u(s,a,r,t,e[11],16,1839030562),t=u(t,s,a,r,e[14],23,-35309556),r=u(r,t,s,a,e[1],4,-1530992060),a=u(a,r,t,s,e[4],11,1272893353),s=u(s,a,r,t,e[7],16,-155497632),t=u(t,s,a,r,e[10],23,-1094730640),r=u(r,t,s,a,e[13],4,681279174),a=u(a,r,t,s,e[0],11,-358537222),s=u(s,a,r,t,e[3],16,-722521979),t=u(t,s,a,r,e[6],23,76029189),r=u(r,t,s,a,e[9],4,-640364487),a=u(a,r,t,s,e[12],11,-421815835),s=u(s,a,r,t,e[15],16,530742520),t=u(t,s,a,r,e[2],23,-995338651);let f=_.bind(null,n);r=f(r,t,s,a,e[0],6,-198630844),a=f(a,r,t,s,e[7],10,1126891415),s=f(s,a,r,t,e[14],15,-1416354905),t=f(t,s,a,r,e[5],21,-57434055),r=f(r,t,s,a,e[12],6,1700485571),a=f(a,r,t,s,e[3],10,-1894986606),s=f(s,a,r,t,e[10],15,-1051523),t=f(t,s,a,r,e[1],21,-2054922799),r=f(r,t,s,a,e[8],6,1873313359),a=f(a,r,t,s,e[15],10,-30611744),s=f(s,a,r,t,e[6],15,-1560198380),t=f(t,s,a,r,e[13],21,1309151649),r=f(r,t,s,a,e[4],6,-145523070),a=f(a,r,t,s,e[11],10,-1120210379),s=f(s,a,r,t,e[2],15,718787259),t=f(t,s,a,r,e[9],21,-343485551),i[0]=n(r,i[0]),i[1]=n(t,i[1]),i[2]=n(s,i[2]),i[3]=n(a,i[3]);}var m=ie;function ae(i){let e=[];for(let n=0;n<64;n+=4)e[n>>2]=(i.charCodeAt(n)||0)+((i.charCodeAt(n+1)||0)<<8)+((i.charCodeAt(n+2)||0)<<16)+((i.charCodeAt(n+3)||0)<<24);return e}var G=ae;function oe(i,e){let n=i.length,r=[1732584193,-271733879,-1732584194,271733878],t;for(t=64;t<=n;t+=64)m(r,G(i.substring(t-64,t)),e);i=i.substring(t-64);var s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a=i.length;for(t=0;t<a;t++)s[t>>2]|=(i.charCodeAt(t)&255)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(m(r,s,e),t=16;t--;)s[t]=0;return s[14]=n*8,m(r,s,e),r}var z=oe;function ce(i,e){let n=i.length,r=[1732584193,-271733879,-1732584194,271733878],t;for(t=64;t<=n;t+=64){let o=ue(i,t-64);m(r,o,e);}let s=n-t+64,a=new Array(16).fill(0);for(let o=0;o<s;o++)a[o>>2]|=(i[n-s+o]&255)<<(o%4<<3);if(a[s>>2]|=128<<(s%4<<3),s>55){m(r,a,e);for(let o=0;o<16;o++)a[o]=0;}return a[14]=n*8,a[15]=0,m(r,a,e),r}function ue(i,e){let n=[];for(let r=0;r<64;r+=4)n[r>>2]=(i[e+r]||0)+((i[e+r+1]||0)<<8)+((i[e+r+2]||0)<<16)+((i[e+r+3]||0)<<24);return n}var K=ce;function l(i){return S(z(i,b))}function q(i){return S(K(i,b))}var g=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(e){return l(e)}async hashBinary(e){let n=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return l(n)}update(e){throw new Error("Web Crypto API does not support streaming updates")}digest(e){throw new Error("Web Crypto API does not support streaming")}reset(){}};var w=class{constructor(){this.name="nodecrypto";this.version="1.0.0";}static isAvailable(){try{return typeof N("crypto").createHash=="function"}catch{return false}}hash(e){return N("crypto").createHash("md5").update(e).digest("hex")}async hashBinary(e){let n=N("crypto"),r=e instanceof Uint8Array?e:new Uint8Array(e);return n.createHash("md5").update(r).digest("hex")}update(e){}digest(e){throw new Error("Node crypto streaming not implemented")}reset(){}};var B=class{constructor(){this.name="ie11";this.version="1.0.0";}static isAvailable(){if(typeof window>"u")return false;let e=window;return typeof e.msCrypto<"u"&&typeof e.msCrypto.subtle<"u"&&typeof e.msCrypto.subtle.digest=="function"}async hash(e){let r=new TextEncoder().encode(e);return await this.hashBinary(r)}async hashBinary(e){let n=window,r=e instanceof Uint8Array?e.buffer:e,t=await n.msCrypto.subtle.digest("MD5",r);return this.bufferToHex(t)}bufferToHex(e){return Array.from(new Uint8Array(e)).map(n=>n.toString(16).padStart(2,"0")).join("")}update(e){throw new Error("msCrypto does not support streaming updates")}digest(e){throw new Error("msCrypto does not support streaming")}reset(){}};var p=class i extends Transform{constructor(n){super({readableObjectMode:false,writableObjectMode:false});this.initialMD5State=[1732584193,-271733879,-1732584194,271733878];this.bufferCapacity=64;this.buffer=new Uint8Array(this.bufferCapacity);this.add32=n?.add32||b,this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer};}_transform(n,r,t){try{let s=n,a=s.length;if(a===0){t();return}if(this.state.bufferLength>0){let u=this.state.bufferLength,f=64-u,h=Math.min(a,f);for(let d=0;d<h;d++)this.buffer[u+d]=s[d];if(this.state.bufferLength+=h,this.state.bufferLength===64&&this._processBufferBlock(),h===a){t();return}let y=a-h;for(let d=0;d<y;d++)s[d]=s[h+d];let v=Buffer.alloc(y);for(let d=0;d<y;d++)v[d]=s[d];s=v;}let o=Math.floor(s.length/64);for(let u=0;u<o;u++){let f=u*64,h=[];for(let y=0;y<16;y++){let v=f+y*4;h[y]=s[v]+(s[v+1]<<8)+(s[v+2]<<16)+(s[v+3]<<24);}m(this.state.state,h,this.add32),this.state.bytesProcessed+=64;}let c=s.length%64;if(c>0){this.buffer.length<c&&(this.buffer=new Uint8Array(c),this.state.buffer=this.buffer);for(let u=0;u<c;u++)this.buffer[u]=s[o*64+u];this.state.bufferLength=c;}t();}catch(s){t(s);}}_processBufferBlock(){let n=this.state.buffer,r=[];for(let t=0;t<16;t++){let s=t*4;r[t]=n[s]+(n[s+1]<<8)+(n[s+2]<<16)+(n[s+3]<<24);}m(this.state.state,r,this.add32),this.state.bytesProcessed+=64,this.state.bufferLength=0;}_flush(n){try{let{state:r,bufferLength:t,buffer:s}=this.state,a=new Array(16).fill(0);for(let c=0;c<t;c++)a[c>>2]|=(s[c]&255)<<(c%4<<3);if(a[t>>2]|=128<<(t%4<<3),t>55){m(r,a,this.add32);for(let c=0;c<16;c++)a[c]=0;}a[14]=(this.state.bytesProcessed+t)*8,a[15]=0,m(r,a,this.add32);let o=S(r);this.emit("md5",{digest:o,bytesProcessed:this.state.bytesProcessed+t}),n();}catch(r){n(r);}}getCurrentState(){return {state:[...this.state.state],bytesProcessed:this.state.bytesProcessed+this.state.bufferLength}}getBytesProcessed(){return this.state.bytesProcessed+this.state.bufferLength}reset(){this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer},this.buffer=new Uint8Array(this.bufferCapacity),this.state.buffer=this.buffer,this.state.bufferLength=0;}static fromStream(n,r){let t=new i(r),s=E.call(t,n);return {stream:t,result:s}}};function R(i){return new p(i)}async function E(i){return new Promise((e,n)=>{let r=[];i.pipe(this).on("md5",t=>{r.push(t);}).on("error",n).on("finish",()=>{e(r[0]);});})}function j(i,e){let n=new p(e),r=E.call(n,i);return {stream:n,result:r}}var A=class{constructor(){this.name="stream";this.version="0.1.0";this.state=null;}initNodeStream(e){this.state={stream:e,type:"node"};}initWhatWGStream(e){this.state={stream:e,type:"whatwg"};}async hash(e){let n=new p;return (await new Promise((t,s)=>{n.on("md5",a=>t(a)).on("error",s).end(e);})).digest}async hashBinary(e){let n=new p,r;return e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),(await new Promise((s,a)=>{n.on("md5",o=>s(o)).on("error",a).end(r);})).digest}update(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let n=this.state.stream,r;typeof e=="string"||e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),n.write(r);}}digest(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let n=this.state.stream;return n.end(),new Promise((r,t)=>{n.on("md5",s=>{if(e==="buffer"){let a=s.digest,o=[];for(let c=0;c<a.length;c+=2)o.push(parseInt(a.substring(c,c+2),16));r(Buffer.from(o));}else r(s.digest);}).on("error",t);})}else return this.state.stream.getResult().then(r=>r.digest)}reset(){this.state&&this.state.type==="node"&&this.state.stream.reset();}static isAvailable(){return true}};var k=class{constructor(){this.name="purejs";this.version="0.1.0";this.state={data:"",finished:false};}hash(e){return l(e)}async hashBinary(e){let n=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return l(n)}update(e){this.state.finished&&(this.state={data:"",finished:false}),e instanceof ArrayBuffer?this.state.data+=new TextDecoder().decode(e):e instanceof Uint8Array?this.state.data+=new TextDecoder().decode(e):this.state.data+=e;}digest(e){let n=l(this.state.data);return this.state.finished=true,e==="buffer"?this.hexToBuffer(n):n}reset(){this.state={data:"",finished:false};}static isAvailable(){return true}hexToBuffer(e){let n=[];for(let r=0;r<e.length;r+=2)n.push(parseInt(e.substring(r,r+2),16));return new Uint8Array(n)}};async function de(i){switch(i){case "webcrypto":let e=g.isAvailable();return {backend:"webcrypto",available:e,reason:e?void 0:"Web Crypto API not available"};case "nodecrypto":let n=w.isAvailable();return {backend:"nodecrypto",available:n,reason:n?void 0:"Node.js crypto not available"};case "ie11":let r=B.isAvailable();return {backend:"ie11",available:r,reason:r?void 0:"IE11 msCrypto not available"};case "purejs":return {backend:"purejs",available:true,reason:"Always available"};case "stream":let t=typeof process<"u"&&process.versions&&"node"in process.versions,s=typeof window<"u";return {backend:"stream",available:t||s,reason:t||s?void 0:"Streams not available"};default:return {backend:i||"unknown",available:false,reason:"Unknown backend"}}}async function x(){let i=["webcrypto","nodecrypto","ie11","purejs","stream"],e=[];for(let n of i){let{available:r}=await de(n);r&&e.push(n);}return e}var me=[{name:"nodecrypto",priority:1,description:"Node.js native crypto (fastest)"},{name:"webcrypto",priority:2,description:"Web Crypto API (fast, hardware accelerated)"},{name:"ie11",priority:3,description:"IE11 msCrypto (legacy)"},{name:"stream",priority:4,description:"Streaming backend (for large files and memory efficiency)"},{name:"purejs",priority:5,description:"Pure JavaScript (always available, slower)"}];function F(i){let e=[...me].sort((n,r)=>n.priority-r.priority);for(let{name:n}of e)if(i.includes(n))return n;return "purejs"}var M=class i{constructor(){}static getInstance(){return i.instance||(i.instance=new i),i.instance}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new B;case "stream":return new A;default:return new k}}async createBackend(e){let n=e||F(await x());return this.createBackendByName(n)}},le=M.getInstance(),P=class{constructor(e=["nodecrypto","webcrypto","stream","ie11","purejs"]){this.detector=M.getInstance(),this.fallbackOrder=e;}async execute(e){let n=[];for(let r of this.fallbackOrder)try{let t=await this.detector.createBackendByName(r),s=await e(t);return {success:!0,backend:r,data:s}}catch(t){if(n.push({backend:r,error:t}),r===this.fallbackOrder[this.fallbackOrder.length-1])return {success:false,backend:r,data:null,errors:n}}return {success:false,backend:"",data:null,errors:n}}async hash(e){return this.execute(async n=>n.hash(e))}async hashBinary(e){return this.execute(async n=>n.hashBinary(e))}async getBestBackend(){let e=await this.getAvailableBackends();return e.length===0?"purejs":e[0]}async getAvailableBackends(){let e=[];for(let n of this.fallbackOrder)try{await this.detector.createBackendByName(n),e.push(n);}catch{}return e}getMetrics(){return {}}},be=new P;async function pe(i,e={}){let n=new P;if(e.forceBackend)return (await n.detector.createBackendByName(e.forceBackend)).hash(i);if(e.fallback===false)return (await n.detector.createBackend()).hash(i);let r=await n.hash(i);if(r.success)return e.reportFallback&&r.backend!=="nodecrypto"&&r.backend!=="webcrypto"&&console.info(`MD5 used fallback backend: ${r.backend}`),r.data;let t=r.errors?r.errors.map(s=>`${s.backend}: ${s.error.message}`).join(", "):"All backends failed";throw new Error(`MD5 hash failed after all attempts: ${t}`)}var U=class{constructor(){this.metrics={nodecrypto:{success:0,fail:0},webcrypto:{success:0,fail:0},ie11:{success:0,fail:0},stream:{success:0,fail:0},purejs:{success:0,fail:0}};}recordSuccess(e){this.metrics[e]&&this.metrics[e].success++;}recordFail(e){this.metrics[e]&&this.metrics[e].fail++;}getMetrics(){return this.metrics}getSummary(){return `Total operations: ${Object.values(this.metrics).reduce((n,r)=>n+r.success+r.fail,0)}
2
- `+Object.entries(this.metrics).map(([,n])=>`${n.success} success, ${n.fail} fail`).join(`
3
- `)}reset(){Object.keys(this.metrics).forEach(e=>{this.metrics[e]={success:0,fail:0};});}},he=new U;async function W(i,e={}){if(typeof i!="string"||i.trim()==="")throw new Error("Invalid file path: must be a non-empty string");if(!D.existsSync(i))throw new Error(`File not found: ${i}`);let n;try{n=D.statSync(i);}catch(t){throw new Error(`Failed to access file ${i}: ${t.message}`)}if(!n.isFile())throw new Error(`Path is not a file: ${i}`);let r=D.createReadStream(i,{highWaterMark:e.chunkSize||64*1024});try{return await T(r,{onProgress:e.onProgress,totalSize:n.size})}finally{r.destroy();}}async function T(i,e={}){if(!i||typeof i.on!="function")throw new Error("Invalid readable stream: stream must have event listener support");let n=R(),r=0;return e.onProgress&&i.on("data",t=>{r+=t.length,e.onProgress?.(r);}),i.on("error",t=>{n.destroy(t);}),i.on("end",()=>{n.end();}),new Promise((t,s)=>{n.on("md5",a=>{t(a);}).on("error",a=>{s(a);}),i.pipe(n);})}async function J(i,e={}){return (await W(i,e)).digest}async function Y(i,e={}){return (await T(i,e)).digest}async function Q(i,e,n={}){return (await W(i,n)).digest.toLowerCase()===e.toLowerCase()}function V(i){if(typeof i!="string"||i.trim()==="")throw new Error("Invalid file path: must be a non-empty string");if(!D.existsSync(i))throw new Error(`File not found: ${i}`);let e;try{e=D.statSync(i);}catch(r){throw new Error(`Failed to access file ${i}: ${r.message}`)}if(!e.isFile())throw new Error(`Path is not a file: ${i}`);let n;try{n=D.readFileSync(i);}catch(r){throw new Error(`Failed to read file ${i}: ${r.message}`)}return q(n)}function X(i,e){let n=0;return r=>{if(i>0){let t=Math.min(100,r/i*100);Math.floor(t)!==Math.floor(n)&&(e(t),n=t);}}}Object.defineProperty(p,"fromStream",{value:j,writable:false,configurable:false});var H=class{constructor(){this.backend=null;this.backendName=null;}async hash(e){return (await this.getBackend()).hash(e)}async hashBinary(e){return (await this.getBackend()).hashBinary(e)}async getBackendName(){if(!this.backendName){let e=await x();this.backendName=F(e);}return this.backendName}static async getAvailableBackends(){return await x()}async useBackend(e){this.backend=await this.createBackendByName(e),this.backendName=e;}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new B;case "stream":return new A;default:return {hash:n=>l(n),hashBinary:async n=>l(n instanceof Uint8Array?new TextDecoder().decode(n):new TextDecoder().decode(new Uint8Array(n))),update:()=>{},digest:()=>"",reset:()=>{},name:"purejs",version:"0.1.0"}}}async getBackend(){if(this.backend)return this.backend;let e=await x(),n=F(e);return this.backend=await this.createBackendByName(n),this.backendName=n,this.backend}};function Ar(i){return l(i)}var ye=new H;async function xr(i){return ye.hash(i)}export{M as BackendDetector,P as FallbackManager,B as IE11Backend,p as MD5Stream,U as MetricsCollector,w as NodeCryptoBackend,k as PureJSBackend,g as WebCryptoBackend,R as createMD5Stream,X as createProgressTracker,le as detector,be as fallbackManager,j as fromStream,x as getAllAvailableBackends,F as getBestAvailableBackend,W as hashFile,J as hashFileDigest,T as hashFileStream,Y as hashFileStreamDigest,V as hashFileSync,Ar as md5,ye as md5Adapter,xr as md5Async,l as md5Core,l as md5Original,he as metrics,E as pipeThroughMD5,pe as robustHash,Q as verifyFile};
1
+ import {Transform}from'stream';import D from'fs';var N=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var X="0123456789abcdef".split(""),O=X;function Z(i){let e="";for(let t=0;t<4;t++)e+=O[i>>t*8+4&15]+O[i>>t*8&15];return e}function ee(i){let e=i.length,t=new Array(e);for(let r=0;r<e;r++)t[r]=Z(i[r]);return t.join("")}var S=ee;function re(i,e){return i+e&4294967295}var b=re;function te(i,e,t,r,s){let n=s||b;return e=n(n(e,i),n(t,r)),e}function ne(i,e,t,r){var n=(r||b)(i<<e|i>>>32-e,t);return n}function C(i,e,t,r,s,n,a){return e=te(i,e,r,n,a),ne(e,s,t,a)}function I(i,e,t,r,s,n,a,o){return C(t&r|~t&s,e,t,n,a,o,i)}function L(i,e,t,r,s,n,a,o){return C(t&s|r&~s,e,t,n,a,o,i)}function $(i,e,t,r,s,n,a,o){return C(t^r^s,e,t,n,a,o,i)}function _(i,e,t,r,s,n,a,o){return C(r^(t|~s),e,t,n,a,o,i)}function se(i,e,t){typeof t>"u"&&(t=b);let r=i[0],s=i[1],n=i[2],a=i[3],o=I.bind(null,t);r=o(r,s,n,a,e[0],7,-680876936),a=o(a,r,s,n,e[1],12,-389564586),n=o(n,a,r,s,e[2],17,606105819),s=o(s,n,a,r,e[3],22,-1044525330),r=o(r,s,n,a,e[4],7,-176418897),a=o(a,r,s,n,e[5],12,1200080426),n=o(n,a,r,s,e[6],17,-1473231341),s=o(s,n,a,r,e[7],22,-45705983),r=o(r,s,n,a,e[8],7,1770035416),a=o(a,r,s,n,e[9],12,-1958414417),n=o(n,a,r,s,e[10],17,-42063),s=o(s,n,a,r,e[11],22,-1990404162),r=o(r,s,n,a,e[12],7,1804603682),a=o(a,r,s,n,e[13],12,-40341101),n=o(n,a,r,s,e[14],17,-1502002290),s=o(s,n,a,r,e[15],22,1236535329);let c=L.bind(null,t);r=c(r,s,n,a,e[1],5,-165796510),a=c(a,r,s,n,e[6],9,-1069501632),n=c(n,a,r,s,e[11],14,643717713),s=c(s,n,a,r,e[0],20,-373897302),r=c(r,s,n,a,e[5],5,-701558691),a=c(a,r,s,n,e[10],9,38016083),n=c(n,a,r,s,e[15],14,-660478335),s=c(s,n,a,r,e[4],20,-405537848),r=c(r,s,n,a,e[9],5,568446438),a=c(a,r,s,n,e[14],9,-1019803690),n=c(n,a,r,s,e[3],14,-187363961),s=c(s,n,a,r,e[8],20,1163531501),r=c(r,s,n,a,e[13],5,-1444681467),a=c(a,r,s,n,e[2],9,-51403784),n=c(n,a,r,s,e[7],14,1735328473),s=c(s,n,a,r,e[12],20,-1926607734);let u=$.bind(null,t);r=u(r,s,n,a,e[5],4,-378558),a=u(a,r,s,n,e[8],11,-2022574463),n=u(n,a,r,s,e[11],16,1839030562),s=u(s,n,a,r,e[14],23,-35309556),r=u(r,s,n,a,e[1],4,-1530992060),a=u(a,r,s,n,e[4],11,1272893353),n=u(n,a,r,s,e[7],16,-155497632),s=u(s,n,a,r,e[10],23,-1094730640),r=u(r,s,n,a,e[13],4,681279174),a=u(a,r,s,n,e[0],11,-358537222),n=u(n,a,r,s,e[3],16,-722521979),s=u(s,n,a,r,e[6],23,76029189),r=u(r,s,n,a,e[9],4,-640364487),a=u(a,r,s,n,e[12],11,-421815835),n=u(n,a,r,s,e[15],16,530742520),s=u(s,n,a,r,e[2],23,-995338651);let f=_.bind(null,t);r=f(r,s,n,a,e[0],6,-198630844),a=f(a,r,s,n,e[7],10,1126891415),n=f(n,a,r,s,e[14],15,-1416354905),s=f(s,n,a,r,e[5],21,-57434055),r=f(r,s,n,a,e[12],6,1700485571),a=f(a,r,s,n,e[3],10,-1894986606),n=f(n,a,r,s,e[10],15,-1051523),s=f(s,n,a,r,e[1],21,-2054922799),r=f(r,s,n,a,e[8],6,1873313359),a=f(a,r,s,n,e[15],10,-30611744),n=f(n,a,r,s,e[6],15,-1560198380),s=f(s,n,a,r,e[13],21,1309151649),r=f(r,s,n,a,e[4],6,-145523070),a=f(a,r,s,n,e[11],10,-1120210379),n=f(n,a,r,s,e[2],15,718787259),s=f(s,n,a,r,e[9],21,-343485551),i[0]=t(r,i[0]),i[1]=t(s,i[1]),i[2]=t(n,i[2]),i[3]=t(a,i[3]);}var m=se;function ie(i){let e=[];for(let t=0;t<i.length;t++){let r=i.charCodeAt(t);if(r>=55296&&r<=56319&&t+1<i.length){let s=i.charCodeAt(t+1);s>=56320&&s<=57343&&(r=(r-55296<<10)+(s-56320)+65536,t++);}r<=127?e.push(r):r<=2047?(e.push(192|r>>6),e.push(128|r&63)):r<=65535?(e.push(224|r>>12),e.push(128|r>>6&63),e.push(128|r&63)):(e.push(240|r>>18),e.push(128|r>>12&63),e.push(128|r>>6&63),e.push(128|r&63));}return e}function ae(i){let e=[];for(let t=0;t<16;t++)e[t]=i[t*4]+(i[t*4+1]<<8)+(i[t*4+2]<<16)+(i[t*4+3]<<24);return e}function oe(i,e){let t=ie(i),r=t.length,s=[1732584193,-271733879,-1732584194,271733878],n;for(n=64;n<=r;n+=64){let u=t.slice(n-64,n);m(s,ae(u),e);}let a=t.slice(n-64),o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=a.length;for(n=0;n<c;n++)o[n>>2]|=a[n]<<(n%4<<3);if(o[n>>2]|=128<<(n%4<<3),n>55)for(m(s,o,e),n=16;n--;)o[n]=0;return o[14]=r*8,m(s,o,e),s}var G=oe;function ce(i,e){let t=i.length,r=[1732584193,-271733879,-1732584194,271733878],s;for(s=64;s<=t;s+=64){let o=ue(i,s-64);m(r,o,e);}let n=t-s+64,a=new Array(16).fill(0);for(let o=0;o<n;o++)a[o>>2]|=(i[t-n+o]&255)<<(o%4<<3);if(a[n>>2]|=128<<(n%4<<3),n>55){m(r,a,e);for(let o=0;o<16;o++)a[o]=0;}return a[14]=t*8,a[15]=0,m(r,a,e),r}function ue(i,e){let t=[];for(let r=0;r<64;r+=4)t[r>>2]=(i[e+r]||0)+((i[e+r+1]||0)<<8)+((i[e+r+2]||0)<<16)+((i[e+r+3]||0)<<24);return t}var z=ce;function l(i){return S(G(i,b))}function K(i){return S(z(i,b))}var g=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(e){return l(e)}async hashBinary(e){let t=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return l(t)}update(e){throw new Error("Web Crypto API does not support streaming updates")}digest(e){throw new Error("Web Crypto API does not support streaming")}reset(){}};var w=class{constructor(){this.name="nodecrypto";this.version="1.0.0";}static isAvailable(){try{return typeof N("crypto").createHash=="function"}catch{return false}}hash(e){return N("crypto").createHash("md5").update(e).digest("hex")}async hashBinary(e){let t=N("crypto"),r=e instanceof Uint8Array?e:new Uint8Array(e);return t.createHash("md5").update(r).digest("hex")}update(e){}digest(e){throw new Error("Node crypto streaming not implemented")}reset(){}};var B=class{constructor(){this.name="ie11";this.version="1.0.0";}static isAvailable(){if(typeof window>"u")return false;let e=window;return typeof e.msCrypto<"u"&&typeof e.msCrypto.subtle<"u"&&typeof e.msCrypto.subtle.digest=="function"}async hash(e){let r=new TextEncoder().encode(e);return await this.hashBinary(r)}async hashBinary(e){let t=window,r=e instanceof Uint8Array?e.buffer:e,s=await t.msCrypto.subtle.digest("MD5",r);return this.bufferToHex(s)}bufferToHex(e){return Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")}update(e){throw new Error("msCrypto does not support streaming updates")}digest(e){throw new Error("msCrypto does not support streaming")}reset(){}};var p=class i extends Transform{constructor(t){super({readableObjectMode:false,writableObjectMode:false});this.initialMD5State=[1732584193,-271733879,-1732584194,271733878];this.bufferCapacity=64;this.buffer=new Uint8Array(this.bufferCapacity);this.add32=t?.add32||b,this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer};}_transform(t,r,s){try{let n=t,a=n.length;if(a===0){s();return}if(this.state.bufferLength>0){let u=this.state.bufferLength,f=64-u,h=Math.min(a,f);for(let d=0;d<h;d++)this.buffer[u+d]=n[d];if(this.state.bufferLength+=h,this.state.bufferLength===64&&this._processBufferBlock(),h===a){s();return}let y=a-h;for(let d=0;d<y;d++)n[d]=n[h+d];let x=Buffer.alloc(y);for(let d=0;d<y;d++)x[d]=n[d];n=x;}let o=Math.floor(n.length/64);for(let u=0;u<o;u++){let f=u*64,h=[];for(let y=0;y<16;y++){let x=f+y*4;h[y]=n[x]+(n[x+1]<<8)+(n[x+2]<<16)+(n[x+3]<<24);}m(this.state.state,h,this.add32),this.state.bytesProcessed+=64;}let c=n.length%64;if(c>0){this.buffer.length<c&&(this.buffer=new Uint8Array(c),this.state.buffer=this.buffer);for(let u=0;u<c;u++)this.buffer[u]=n[o*64+u];this.state.bufferLength=c;}s();}catch(n){s(n);}}_processBufferBlock(){let t=this.state.buffer,r=[];for(let s=0;s<16;s++){let n=s*4;r[s]=t[n]+(t[n+1]<<8)+(t[n+2]<<16)+(t[n+3]<<24);}m(this.state.state,r,this.add32),this.state.bytesProcessed+=64,this.state.bufferLength=0;}_flush(t){try{let{state:r,bufferLength:s,buffer:n}=this.state,a=new Array(16).fill(0);for(let c=0;c<s;c++)a[c>>2]|=(n[c]&255)<<(c%4<<3);if(a[s>>2]|=128<<(s%4<<3),s>55){m(r,a,this.add32);for(let c=0;c<16;c++)a[c]=0;}a[14]=(this.state.bytesProcessed+s)*8,a[15]=0,m(r,a,this.add32);let o=S(r);this.emit("md5",{digest:o,bytesProcessed:this.state.bytesProcessed+s}),t();}catch(r){t(r);}}getCurrentState(){return {state:[...this.state.state],bytesProcessed:this.state.bytesProcessed+this.state.bufferLength}}getBytesProcessed(){return this.state.bytesProcessed+this.state.bufferLength}reset(){this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer},this.buffer=new Uint8Array(this.bufferCapacity),this.state.buffer=this.buffer,this.state.bufferLength=0;}static fromStream(t,r){let s=new i(r),n=U.call(s,t);return {stream:s,result:n}}};function R(i){return new p(i)}async function U(i){return new Promise((e,t)=>{let r=[];i.pipe(this).on("md5",s=>{r.push(s);}).on("error",t).on("finish",()=>{e(r[0]);});})}function j(i,e){let t=new p(e),r=U.call(t,i);return {stream:t,result:r}}var A=class{constructor(){this.name="stream";this.version="0.1.0";this.state=null;}initNodeStream(e){this.state={stream:e,type:"node"};}initWhatWGStream(e){this.state={stream:e,type:"whatwg"};}async hash(e){let t=new p;return (await new Promise((s,n)=>{t.on("md5",a=>s(a)).on("error",n).end(e);})).digest}async hashBinary(e){let t=new p,r;return e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),(await new Promise((n,a)=>{t.on("md5",o=>n(o)).on("error",a).end(r);})).digest}update(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let t=this.state.stream,r;typeof e=="string"||e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),t.write(r);}}digest(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let t=this.state.stream;return t.end(),new Promise((r,s)=>{t.on("md5",n=>{if(e==="buffer"){let a=n.digest,o=[];for(let c=0;c<a.length;c+=2)o.push(parseInt(a.substring(c,c+2),16));r(Buffer.from(o));}else r(n.digest);}).on("error",s);})}else return this.state.stream.getResult().then(r=>r.digest)}reset(){this.state&&this.state.type==="node"&&this.state.stream.reset();}static isAvailable(){return true}};var k=class{constructor(){this.name="purejs";this.version="0.1.0";this.state={data:"",finished:false};}hash(e){return l(e)}async hashBinary(e){let t=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return l(t)}update(e){this.state.finished&&(this.state={data:"",finished:false}),e instanceof ArrayBuffer?this.state.data+=new TextDecoder().decode(e):e instanceof Uint8Array?this.state.data+=new TextDecoder().decode(e):this.state.data+=e;}digest(e){let t=l(this.state.data);return this.state.finished=true,e==="buffer"?this.hexToBuffer(t):t}reset(){this.state={data:"",finished:false};}static isAvailable(){return true}hexToBuffer(e){let t=[];for(let r=0;r<e.length;r+=2)t.push(parseInt(e.substring(r,r+2),16));return new Uint8Array(t)}};async function de(i){switch(i){case "webcrypto":let e=g.isAvailable();return {backend:"webcrypto",available:e,reason:e?void 0:"Web Crypto API not available"};case "nodecrypto":let t=w.isAvailable();return {backend:"nodecrypto",available:t,reason:t?void 0:"Node.js crypto not available"};case "ie11":let r=B.isAvailable();return {backend:"ie11",available:r,reason:r?void 0:"IE11 msCrypto not available"};case "purejs":return {backend:"purejs",available:true,reason:"Always available"};case "stream":let s=typeof process<"u"&&process.versions&&"node"in process.versions,n=typeof window<"u";return {backend:"stream",available:s||n,reason:s||n?void 0:"Streams not available"};default:return {backend:i||"unknown",available:false,reason:"Unknown backend"}}}async function v(){let i=["webcrypto","nodecrypto","ie11","purejs","stream"],e=[];for(let t of i){let{available:r}=await de(t);r&&e.push(t);}return e}var me=[{name:"nodecrypto",priority:1,description:"Node.js native crypto (fastest)"},{name:"webcrypto",priority:2,description:"Web Crypto API (fast, hardware accelerated)"},{name:"ie11",priority:3,description:"IE11 msCrypto (legacy)"},{name:"stream",priority:4,description:"Streaming backend (for large files and memory efficiency)"},{name:"purejs",priority:5,description:"Pure JavaScript (always available, slower)"}];function F(i){let e=[...me].sort((t,r)=>t.priority-r.priority);for(let{name:t}of e)if(i.includes(t))return t;return "purejs"}var M=class i{constructor(){}static getInstance(){return i.instance||(i.instance=new i),i.instance}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new B;case "stream":return new A;default:return new k}}async createBackend(e){let t=e||F(await v());return this.createBackendByName(t)}},le=M.getInstance(),P=class{constructor(e=["nodecrypto","webcrypto","stream","ie11","purejs"]){this.detector=M.getInstance(),this.fallbackOrder=e;}async execute(e){let t=[];for(let r of this.fallbackOrder)try{let s=await this.detector.createBackendByName(r),n=await e(s);return {success:!0,backend:r,data:n}}catch(s){if(t.push({backend:r,error:s}),r===this.fallbackOrder[this.fallbackOrder.length-1])return {success:false,backend:r,data:null,errors:t}}return {success:false,backend:"",data:null,errors:t}}async hash(e){return this.execute(async t=>t.hash(e))}async hashBinary(e){return this.execute(async t=>t.hashBinary(e))}async getBestBackend(){let e=await this.getAvailableBackends();return e.length===0?"purejs":e[0]}async getAvailableBackends(){let e=[];for(let t of this.fallbackOrder)try{await this.detector.createBackendByName(t),e.push(t);}catch{}return e}getMetrics(){return {}}},be=new P;async function pe(i,e={}){let t=new P;if(e.forceBackend)return (await t.detector.createBackendByName(e.forceBackend)).hash(i);if(e.fallback===false)return (await t.detector.createBackend()).hash(i);let r=await t.hash(i);if(r.success)return e.reportFallback&&r.backend!=="nodecrypto"&&r.backend!=="webcrypto"&&console.info(`MD5 used fallback backend: ${r.backend}`),r.data;let s=r.errors?r.errors.map(n=>`${n.backend}: ${n.error.message}`).join(", "):"All backends failed";throw new Error(`MD5 hash failed after all attempts: ${s}`)}var E=class{constructor(){this.metrics={nodecrypto:{success:0,fail:0},webcrypto:{success:0,fail:0},ie11:{success:0,fail:0},stream:{success:0,fail:0},purejs:{success:0,fail:0}};}recordSuccess(e){this.metrics[e]&&this.metrics[e].success++;}recordFail(e){this.metrics[e]&&this.metrics[e].fail++;}getMetrics(){return this.metrics}getSummary(){return `Total operations: ${Object.values(this.metrics).reduce((t,r)=>t+r.success+r.fail,0)}
2
+ `+Object.entries(this.metrics).map(([,t])=>`${t.success} success, ${t.fail} fail`).join(`
3
+ `)}reset(){Object.keys(this.metrics).forEach(e=>{this.metrics[e]={success:0,fail:0};});}},he=new E;async function T(i,e={}){if(typeof i!="string"||i.trim()==="")throw new Error("Invalid file path: must be a non-empty string");if(!D.existsSync(i))throw new Error(`File not found: ${i}`);let t;try{t=D.statSync(i);}catch(s){throw new Error(`Failed to access file ${i}: ${s.message}`)}if(!t.isFile())throw new Error(`Path is not a file: ${i}`);let r=D.createReadStream(i,{highWaterMark:e.chunkSize||64*1024});try{return await W(r,{onProgress:e.onProgress,totalSize:t.size})}finally{r.destroy();}}async function W(i,e={}){if(!i||typeof i.on!="function")throw new Error("Invalid readable stream: stream must have event listener support");let t=R(),r=0;return e.onProgress&&i.on("data",s=>{r+=s.length,e.onProgress?.(r);}),i.on("error",s=>{t.destroy(s);}),i.on("end",()=>{t.end();}),new Promise((s,n)=>{t.on("md5",a=>{s(a);}).on("error",a=>{n(a);}),i.pipe(t);})}async function q(i,e={}){return (await T(i,e)).digest}async function J(i,e={}){return (await W(i,e)).digest}async function Y(i,e,t={}){return (await T(i,t)).digest.toLowerCase()===e.toLowerCase()}function Q(i){if(typeof i!="string"||i.trim()==="")throw new Error("Invalid file path: must be a non-empty string");if(!D.existsSync(i))throw new Error(`File not found: ${i}`);let e;try{e=D.statSync(i);}catch(r){throw new Error(`Failed to access file ${i}: ${r.message}`)}if(!e.isFile())throw new Error(`Path is not a file: ${i}`);let t;try{t=D.readFileSync(i);}catch(r){throw new Error(`Failed to read file ${i}: ${r.message}`)}return K(t)}function V(i,e){let t=0;return r=>{if(i>0){let s=Math.min(100,r/i*100);Math.floor(s)!==Math.floor(t)&&(e(s),t=s);}}}Object.defineProperty(p,"fromStream",{value:j,writable:false,configurable:false});var H=class{constructor(){this.backend=null;this.backendName=null;}async hash(e){return (await this.getBackend()).hash(e)}async hashBinary(e){return (await this.getBackend()).hashBinary(e)}async getBackendName(){if(!this.backendName){let e=await v();this.backendName=F(e);}return this.backendName}static async getAvailableBackends(){return await v()}async useBackend(e){this.backend=await this.createBackendByName(e),this.backendName=e;}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new B;case "stream":return new A;default:return {hash:t=>l(t),hashBinary:async t=>l(t instanceof Uint8Array?new TextDecoder().decode(t):new TextDecoder().decode(new Uint8Array(t))),update:()=>{},digest:()=>"",reset:()=>{},name:"purejs",version:"0.1.0"}}}async getBackend(){if(this.backend)return this.backend;let e=await v(),t=F(e);return this.backend=await this.createBackendByName(t),this.backendName=t,this.backend}};function Br(i){return l(i)}var ye=new H;async function xr(i){return ye.hash(i)}export{M as BackendDetector,P as FallbackManager,B as IE11Backend,p as MD5Stream,E as MetricsCollector,w as NodeCryptoBackend,k as PureJSBackend,g as WebCryptoBackend,R as createMD5Stream,V as createProgressTracker,le as detector,be as fallbackManager,j as fromStream,v as getAllAvailableBackends,F as getBestAvailableBackend,T as hashFile,q as hashFileDigest,W as hashFileStream,J as hashFileStreamDigest,Q as hashFileSync,Br as md5,ye as md5Adapter,xr as md5Async,l as md5Core,l as md5Original,he as metrics,U as pipeThroughMD5,pe as robustHash,Y as verifyFile};
package/dist/md5.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var C="0123456789abcdef".split(""),h=C;function v(m){let u="";for(let o=0;o<4;o++)u+=h[m>>o*8+4&15]+h[m>>o*8&15];return u}function j(m){let u=m.length,o=new Array(u);for(let r=0;r<u;r++)o[r]=v(m[r]);return o.join("")}var s=j;function w(m,u){return m+u&4294967295}var f=w;function _(m,u,o,r,n){let e=n||f;return u=e(e(u,m),e(o,r)),u}function q(m,u,o,r){var e=(r||f)(m<<u|m>>>32-u,o);return e}function l(m,u,o,r,n,e,t){return u=_(m,u,r,e,t),q(u,n,o,t)}function g(m,u,o,r,n,e,t,b){return l(o&r|~o&n,u,o,e,t,b,m)}function a(m,u,o,r,n,e,t,b){return l(o&n|r&~n,u,o,e,t,b,m)}function A(m,u,o,r,n,e,t,b){return l(o^r^n,u,o,e,t,b,m)}function x(m,u,o,r,n,e,t,b){return l(r^(o|~n),u,o,e,t,b,m)}function z(m,u,o){typeof o>"u"&&(o=f);let r=m[0],n=m[1],e=m[2],t=m[3],b=g.bind(null,o);r=b(r,n,e,t,u[0],7,-680876936),t=b(t,r,n,e,u[1],12,-389564586),e=b(e,t,r,n,u[2],17,606105819),n=b(n,e,t,r,u[3],22,-1044525330),r=b(r,n,e,t,u[4],7,-176418897),t=b(t,r,n,e,u[5],12,1200080426),e=b(e,t,r,n,u[6],17,-1473231341),n=b(n,e,t,r,u[7],22,-45705983),r=b(r,n,e,t,u[8],7,1770035416),t=b(t,r,n,e,u[9],12,-1958414417),e=b(e,t,r,n,u[10],17,-42063),n=b(n,e,t,r,u[11],22,-1990404162),r=b(r,n,e,t,u[12],7,1804603682),t=b(t,r,n,e,u[13],12,-40341101),e=b(e,t,r,n,u[14],17,-1502002290),n=b(n,e,t,r,u[15],22,1236535329);let i=a.bind(null,o);r=i(r,n,e,t,u[1],5,-165796510),t=i(t,r,n,e,u[6],9,-1069501632),e=i(e,t,r,n,u[11],14,643717713),n=i(n,e,t,r,u[0],20,-373897302),r=i(r,n,e,t,u[5],5,-701558691),t=i(t,r,n,e,u[10],9,38016083),e=i(e,t,r,n,u[15],14,-660478335),n=i(n,e,t,r,u[4],20,-405537848),r=i(r,n,e,t,u[9],5,568446438),t=i(t,r,n,e,u[14],9,-1019803690),e=i(e,t,r,n,u[3],14,-187363961),n=i(n,e,t,r,u[8],20,1163531501),r=i(r,n,e,t,u[13],5,-1444681467),t=i(t,r,n,e,u[2],9,-51403784),e=i(e,t,r,n,u[7],14,1735328473),n=i(n,e,t,r,u[12],20,-1926607734);let d=A.bind(null,o);r=d(r,n,e,t,u[5],4,-378558),t=d(t,r,n,e,u[8],11,-2022574463),e=d(e,t,r,n,u[11],16,1839030562),n=d(n,e,t,r,u[14],23,-35309556),r=d(r,n,e,t,u[1],4,-1530992060),t=d(t,r,n,e,u[4],11,1272893353),e=d(e,t,r,n,u[7],16,-155497632),n=d(n,e,t,r,u[10],23,-1094730640),r=d(r,n,e,t,u[13],4,681279174),t=d(t,r,n,e,u[0],11,-358537222),e=d(e,t,r,n,u[3],16,-722521979),n=d(n,e,t,r,u[6],23,76029189),r=d(r,n,e,t,u[9],4,-640364487),t=d(t,r,n,e,u[12],11,-421815835),e=d(e,t,r,n,u[15],16,530742520),n=d(n,e,t,r,u[2],23,-995338651);let c=x.bind(null,o);r=c(r,n,e,t,u[0],6,-198630844),t=c(t,r,n,e,u[7],10,1126891415),e=c(e,t,r,n,u[14],15,-1416354905),n=c(n,e,t,r,u[5],21,-57434055),r=c(r,n,e,t,u[12],6,1700485571),t=c(t,r,n,e,u[3],10,-1894986606),e=c(e,t,r,n,u[10],15,-1051523),n=c(n,e,t,r,u[1],21,-2054922799),r=c(r,n,e,t,u[8],6,1873313359),t=c(t,r,n,e,u[15],10,-30611744),e=c(e,t,r,n,u[6],15,-1560198380),n=c(n,e,t,r,u[13],21,1309151649),r=c(r,n,e,t,u[4],6,-145523070),t=c(t,r,n,e,u[11],10,-1120210379),e=c(e,t,r,n,u[2],15,718787259),n=c(n,e,t,r,u[9],21,-343485551),m[0]=o(r,m[0]),m[1]=o(n,m[1]),m[2]=o(e,m[2]),m[3]=o(t,m[3]);}var p=z;function B(m){let u=[];for(let o=0;o<64;o+=4)u[o>>2]=(m.charCodeAt(o)||0)+((m.charCodeAt(o+1)||0)<<8)+((m.charCodeAt(o+2)||0)<<16)+((m.charCodeAt(o+3)||0)<<24);return u}var F=B;function D(m,u){let o=m.length,r=[1732584193,-271733879,-1732584194,271733878],n;for(n=64;n<=o;n+=64)p(r,F(m.substring(n-64,n)),u);m=m.substring(n-64);var e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=m.length;for(n=0;n<t;n++)e[n>>2]|=(m.charCodeAt(n)&255)<<(n%4<<3);if(e[n>>2]|=128<<(n%4<<3),n>55)for(p(r,e,u),n=16;n--;)e[n]=0;return e[14]=o*8,p(r,e,u),r}var y=D;function V(m){return s(y(m,f))}exports.md5=V;
1
+ 'use strict';var F="0123456789abcdef".split(""),x=F;function T(o){let e="";for(let m=0;m<4;m++)e+=x[o>>m*8+4&15]+x[o>>m*8&15];return e}function j(o){let e=o.length,m=new Array(e);for(let n=0;n<e;n++)m[n]=T(o[n]);return m.join("")}var p=j;function v(o,e){return o+e&4294967295}var d=v;function w(o,e,m,n,u){let r=u||d;return e=r(r(e,o),r(m,n)),e}function C(o,e,m,n){var r=(n||d)(o<<e|o>>>32-e,m);return r}function l(o,e,m,n,u,r,t){return e=w(o,e,n,r,t),C(e,u,m,t)}function h(o,e,m,n,u,r,t,i){return l(m&n|~m&u,e,m,r,t,i,o)}function g(o,e,m,n,u,r,t,i){return l(m&u|n&~u,e,m,r,t,i,o)}function A(o,e,m,n,u,r,t,i){return l(m^n^u,e,m,r,t,i,o)}function a(o,e,m,n,u,r,t,i){return l(n^(m|~u),e,m,r,t,i,o)}function U(o,e,m){typeof m>"u"&&(m=d);let n=o[0],u=o[1],r=o[2],t=o[3],i=h.bind(null,m);n=i(n,u,r,t,e[0],7,-680876936),t=i(t,n,u,r,e[1],12,-389564586),r=i(r,t,n,u,e[2],17,606105819),u=i(u,r,t,n,e[3],22,-1044525330),n=i(n,u,r,t,e[4],7,-176418897),t=i(t,n,u,r,e[5],12,1200080426),r=i(r,t,n,u,e[6],17,-1473231341),u=i(u,r,t,n,e[7],22,-45705983),n=i(n,u,r,t,e[8],7,1770035416),t=i(t,n,u,r,e[9],12,-1958414417),r=i(r,t,n,u,e[10],17,-42063),u=i(u,r,t,n,e[11],22,-1990404162),n=i(n,u,r,t,e[12],7,1804603682),t=i(t,n,u,r,e[13],12,-40341101),r=i(r,t,n,u,e[14],17,-1502002290),u=i(u,r,t,n,e[15],22,1236535329);let b=g.bind(null,m);n=b(n,u,r,t,e[1],5,-165796510),t=b(t,n,u,r,e[6],9,-1069501632),r=b(r,t,n,u,e[11],14,643717713),u=b(u,r,t,n,e[0],20,-373897302),n=b(n,u,r,t,e[5],5,-701558691),t=b(t,n,u,r,e[10],9,38016083),r=b(r,t,n,u,e[15],14,-660478335),u=b(u,r,t,n,e[4],20,-405537848),n=b(n,u,r,t,e[9],5,568446438),t=b(t,n,u,r,e[14],9,-1019803690),r=b(r,t,n,u,e[3],14,-187363961),u=b(u,r,t,n,e[8],20,1163531501),n=b(n,u,r,t,e[13],5,-1444681467),t=b(t,n,u,r,e[2],9,-51403784),r=b(r,t,n,u,e[7],14,1735328473),u=b(u,r,t,n,e[12],20,-1926607734);let f=A.bind(null,m);n=f(n,u,r,t,e[5],4,-378558),t=f(t,n,u,r,e[8],11,-2022574463),r=f(r,t,n,u,e[11],16,1839030562),u=f(u,r,t,n,e[14],23,-35309556),n=f(n,u,r,t,e[1],4,-1530992060),t=f(t,n,u,r,e[4],11,1272893353),r=f(r,t,n,u,e[7],16,-155497632),u=f(u,r,t,n,e[10],23,-1094730640),n=f(n,u,r,t,e[13],4,681279174),t=f(t,n,u,r,e[0],11,-358537222),r=f(r,t,n,u,e[3],16,-722521979),u=f(u,r,t,n,e[6],23,76029189),n=f(n,u,r,t,e[9],4,-640364487),t=f(t,n,u,r,e[12],11,-421815835),r=f(r,t,n,u,e[15],16,530742520),u=f(u,r,t,n,e[2],23,-995338651);let c=a.bind(null,m);n=c(n,u,r,t,e[0],6,-198630844),t=c(t,n,u,r,e[7],10,1126891415),r=c(r,t,n,u,e[14],15,-1416354905),u=c(u,r,t,n,e[5],21,-57434055),n=c(n,u,r,t,e[12],6,1700485571),t=c(t,n,u,r,e[3],10,-1894986606),r=c(r,t,n,u,e[10],15,-1051523),u=c(u,r,t,n,e[1],21,-2054922799),n=c(n,u,r,t,e[8],6,1873313359),t=c(t,n,u,r,e[15],10,-30611744),r=c(r,t,n,u,e[6],15,-1560198380),u=c(u,r,t,n,e[13],21,1309151649),n=c(n,u,r,t,e[4],6,-145523070),t=c(t,n,u,r,e[11],10,-1120210379),r=c(r,t,n,u,e[2],15,718787259),u=c(u,r,t,n,e[9],21,-343485551),o[0]=m(n,o[0]),o[1]=m(u,o[1]),o[2]=m(r,o[2]),o[3]=m(t,o[3]);}var s=U;function _(o){let e=[];for(let m=0;m<o.length;m++){let n=o.charCodeAt(m);if(n>=55296&&n<=56319&&m+1<o.length){let u=o.charCodeAt(m+1);u>=56320&&u<=57343&&(n=(n-55296<<10)+(u-56320)+65536,m++);}n<=127?e.push(n):n<=2047?(e.push(192|n>>6),e.push(128|n&63)):n<=65535?(e.push(224|n>>12),e.push(128|n>>6&63),e.push(128|n&63)):(e.push(240|n>>18),e.push(128|n>>12&63),e.push(128|n>>6&63),e.push(128|n&63));}return e}function B(o){let e=[];for(let m=0;m<16;m++)e[m]=o[m*4]+(o[m*4+1]<<8)+(o[m*4+2]<<16)+(o[m*4+3]<<24);return e}function N(o,e){let m=_(o),n=m.length,u=[1732584193,-271733879,-1732584194,271733878],r;for(r=64;r<=n;r+=64){let f=m.slice(r-64,r);s(u,B(f),e);}let t=m.slice(r-64),i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],b=t.length;for(r=0;r<b;r++)i[r>>2]|=t[r]<<(r%4<<3);if(i[r>>2]|=128<<(r%4<<3),r>55)for(s(u,i,e),r=16;r--;)i[r]=0;return i[14]=n*8,s(u,i,e),u}var y=N;function R(o){return p(y(o,d))}exports.md5=R;
package/dist/md5.js CHANGED
@@ -1 +1 @@
1
- var C="0123456789abcdef".split(""),h=C;function v(m){let u="";for(let o=0;o<4;o++)u+=h[m>>o*8+4&15]+h[m>>o*8&15];return u}function j(m){let u=m.length,o=new Array(u);for(let r=0;r<u;r++)o[r]=v(m[r]);return o.join("")}var s=j;function w(m,u){return m+u&4294967295}var f=w;function _(m,u,o,r,n){let e=n||f;return u=e(e(u,m),e(o,r)),u}function q(m,u,o,r){var e=(r||f)(m<<u|m>>>32-u,o);return e}function l(m,u,o,r,n,e,t){return u=_(m,u,r,e,t),q(u,n,o,t)}function g(m,u,o,r,n,e,t,b){return l(o&r|~o&n,u,o,e,t,b,m)}function a(m,u,o,r,n,e,t,b){return l(o&n|r&~n,u,o,e,t,b,m)}function A(m,u,o,r,n,e,t,b){return l(o^r^n,u,o,e,t,b,m)}function x(m,u,o,r,n,e,t,b){return l(r^(o|~n),u,o,e,t,b,m)}function z(m,u,o){typeof o>"u"&&(o=f);let r=m[0],n=m[1],e=m[2],t=m[3],b=g.bind(null,o);r=b(r,n,e,t,u[0],7,-680876936),t=b(t,r,n,e,u[1],12,-389564586),e=b(e,t,r,n,u[2],17,606105819),n=b(n,e,t,r,u[3],22,-1044525330),r=b(r,n,e,t,u[4],7,-176418897),t=b(t,r,n,e,u[5],12,1200080426),e=b(e,t,r,n,u[6],17,-1473231341),n=b(n,e,t,r,u[7],22,-45705983),r=b(r,n,e,t,u[8],7,1770035416),t=b(t,r,n,e,u[9],12,-1958414417),e=b(e,t,r,n,u[10],17,-42063),n=b(n,e,t,r,u[11],22,-1990404162),r=b(r,n,e,t,u[12],7,1804603682),t=b(t,r,n,e,u[13],12,-40341101),e=b(e,t,r,n,u[14],17,-1502002290),n=b(n,e,t,r,u[15],22,1236535329);let i=a.bind(null,o);r=i(r,n,e,t,u[1],5,-165796510),t=i(t,r,n,e,u[6],9,-1069501632),e=i(e,t,r,n,u[11],14,643717713),n=i(n,e,t,r,u[0],20,-373897302),r=i(r,n,e,t,u[5],5,-701558691),t=i(t,r,n,e,u[10],9,38016083),e=i(e,t,r,n,u[15],14,-660478335),n=i(n,e,t,r,u[4],20,-405537848),r=i(r,n,e,t,u[9],5,568446438),t=i(t,r,n,e,u[14],9,-1019803690),e=i(e,t,r,n,u[3],14,-187363961),n=i(n,e,t,r,u[8],20,1163531501),r=i(r,n,e,t,u[13],5,-1444681467),t=i(t,r,n,e,u[2],9,-51403784),e=i(e,t,r,n,u[7],14,1735328473),n=i(n,e,t,r,u[12],20,-1926607734);let d=A.bind(null,o);r=d(r,n,e,t,u[5],4,-378558),t=d(t,r,n,e,u[8],11,-2022574463),e=d(e,t,r,n,u[11],16,1839030562),n=d(n,e,t,r,u[14],23,-35309556),r=d(r,n,e,t,u[1],4,-1530992060),t=d(t,r,n,e,u[4],11,1272893353),e=d(e,t,r,n,u[7],16,-155497632),n=d(n,e,t,r,u[10],23,-1094730640),r=d(r,n,e,t,u[13],4,681279174),t=d(t,r,n,e,u[0],11,-358537222),e=d(e,t,r,n,u[3],16,-722521979),n=d(n,e,t,r,u[6],23,76029189),r=d(r,n,e,t,u[9],4,-640364487),t=d(t,r,n,e,u[12],11,-421815835),e=d(e,t,r,n,u[15],16,530742520),n=d(n,e,t,r,u[2],23,-995338651);let c=x.bind(null,o);r=c(r,n,e,t,u[0],6,-198630844),t=c(t,r,n,e,u[7],10,1126891415),e=c(e,t,r,n,u[14],15,-1416354905),n=c(n,e,t,r,u[5],21,-57434055),r=c(r,n,e,t,u[12],6,1700485571),t=c(t,r,n,e,u[3],10,-1894986606),e=c(e,t,r,n,u[10],15,-1051523),n=c(n,e,t,r,u[1],21,-2054922799),r=c(r,n,e,t,u[8],6,1873313359),t=c(t,r,n,e,u[15],10,-30611744),e=c(e,t,r,n,u[6],15,-1560198380),n=c(n,e,t,r,u[13],21,1309151649),r=c(r,n,e,t,u[4],6,-145523070),t=c(t,r,n,e,u[11],10,-1120210379),e=c(e,t,r,n,u[2],15,718787259),n=c(n,e,t,r,u[9],21,-343485551),m[0]=o(r,m[0]),m[1]=o(n,m[1]),m[2]=o(e,m[2]),m[3]=o(t,m[3]);}var p=z;function B(m){let u=[];for(let o=0;o<64;o+=4)u[o>>2]=(m.charCodeAt(o)||0)+((m.charCodeAt(o+1)||0)<<8)+((m.charCodeAt(o+2)||0)<<16)+((m.charCodeAt(o+3)||0)<<24);return u}var F=B;function D(m,u){let o=m.length,r=[1732584193,-271733879,-1732584194,271733878],n;for(n=64;n<=o;n+=64)p(r,F(m.substring(n-64,n)),u);m=m.substring(n-64);var e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=m.length;for(n=0;n<t;n++)e[n>>2]|=(m.charCodeAt(n)&255)<<(n%4<<3);if(e[n>>2]|=128<<(n%4<<3),n>55)for(p(r,e,u),n=16;n--;)e[n]=0;return e[14]=o*8,p(r,e,u),r}var y=D;function V(m){return s(y(m,f))}export{V as md5};
1
+ var F="0123456789abcdef".split(""),x=F;function T(o){let e="";for(let m=0;m<4;m++)e+=x[o>>m*8+4&15]+x[o>>m*8&15];return e}function j(o){let e=o.length,m=new Array(e);for(let n=0;n<e;n++)m[n]=T(o[n]);return m.join("")}var p=j;function v(o,e){return o+e&4294967295}var d=v;function w(o,e,m,n,u){let r=u||d;return e=r(r(e,o),r(m,n)),e}function C(o,e,m,n){var r=(n||d)(o<<e|o>>>32-e,m);return r}function l(o,e,m,n,u,r,t){return e=w(o,e,n,r,t),C(e,u,m,t)}function h(o,e,m,n,u,r,t,i){return l(m&n|~m&u,e,m,r,t,i,o)}function g(o,e,m,n,u,r,t,i){return l(m&u|n&~u,e,m,r,t,i,o)}function A(o,e,m,n,u,r,t,i){return l(m^n^u,e,m,r,t,i,o)}function a(o,e,m,n,u,r,t,i){return l(n^(m|~u),e,m,r,t,i,o)}function U(o,e,m){typeof m>"u"&&(m=d);let n=o[0],u=o[1],r=o[2],t=o[3],i=h.bind(null,m);n=i(n,u,r,t,e[0],7,-680876936),t=i(t,n,u,r,e[1],12,-389564586),r=i(r,t,n,u,e[2],17,606105819),u=i(u,r,t,n,e[3],22,-1044525330),n=i(n,u,r,t,e[4],7,-176418897),t=i(t,n,u,r,e[5],12,1200080426),r=i(r,t,n,u,e[6],17,-1473231341),u=i(u,r,t,n,e[7],22,-45705983),n=i(n,u,r,t,e[8],7,1770035416),t=i(t,n,u,r,e[9],12,-1958414417),r=i(r,t,n,u,e[10],17,-42063),u=i(u,r,t,n,e[11],22,-1990404162),n=i(n,u,r,t,e[12],7,1804603682),t=i(t,n,u,r,e[13],12,-40341101),r=i(r,t,n,u,e[14],17,-1502002290),u=i(u,r,t,n,e[15],22,1236535329);let b=g.bind(null,m);n=b(n,u,r,t,e[1],5,-165796510),t=b(t,n,u,r,e[6],9,-1069501632),r=b(r,t,n,u,e[11],14,643717713),u=b(u,r,t,n,e[0],20,-373897302),n=b(n,u,r,t,e[5],5,-701558691),t=b(t,n,u,r,e[10],9,38016083),r=b(r,t,n,u,e[15],14,-660478335),u=b(u,r,t,n,e[4],20,-405537848),n=b(n,u,r,t,e[9],5,568446438),t=b(t,n,u,r,e[14],9,-1019803690),r=b(r,t,n,u,e[3],14,-187363961),u=b(u,r,t,n,e[8],20,1163531501),n=b(n,u,r,t,e[13],5,-1444681467),t=b(t,n,u,r,e[2],9,-51403784),r=b(r,t,n,u,e[7],14,1735328473),u=b(u,r,t,n,e[12],20,-1926607734);let f=A.bind(null,m);n=f(n,u,r,t,e[5],4,-378558),t=f(t,n,u,r,e[8],11,-2022574463),r=f(r,t,n,u,e[11],16,1839030562),u=f(u,r,t,n,e[14],23,-35309556),n=f(n,u,r,t,e[1],4,-1530992060),t=f(t,n,u,r,e[4],11,1272893353),r=f(r,t,n,u,e[7],16,-155497632),u=f(u,r,t,n,e[10],23,-1094730640),n=f(n,u,r,t,e[13],4,681279174),t=f(t,n,u,r,e[0],11,-358537222),r=f(r,t,n,u,e[3],16,-722521979),u=f(u,r,t,n,e[6],23,76029189),n=f(n,u,r,t,e[9],4,-640364487),t=f(t,n,u,r,e[12],11,-421815835),r=f(r,t,n,u,e[15],16,530742520),u=f(u,r,t,n,e[2],23,-995338651);let c=a.bind(null,m);n=c(n,u,r,t,e[0],6,-198630844),t=c(t,n,u,r,e[7],10,1126891415),r=c(r,t,n,u,e[14],15,-1416354905),u=c(u,r,t,n,e[5],21,-57434055),n=c(n,u,r,t,e[12],6,1700485571),t=c(t,n,u,r,e[3],10,-1894986606),r=c(r,t,n,u,e[10],15,-1051523),u=c(u,r,t,n,e[1],21,-2054922799),n=c(n,u,r,t,e[8],6,1873313359),t=c(t,n,u,r,e[15],10,-30611744),r=c(r,t,n,u,e[6],15,-1560198380),u=c(u,r,t,n,e[13],21,1309151649),n=c(n,u,r,t,e[4],6,-145523070),t=c(t,n,u,r,e[11],10,-1120210379),r=c(r,t,n,u,e[2],15,718787259),u=c(u,r,t,n,e[9],21,-343485551),o[0]=m(n,o[0]),o[1]=m(u,o[1]),o[2]=m(r,o[2]),o[3]=m(t,o[3]);}var s=U;function _(o){let e=[];for(let m=0;m<o.length;m++){let n=o.charCodeAt(m);if(n>=55296&&n<=56319&&m+1<o.length){let u=o.charCodeAt(m+1);u>=56320&&u<=57343&&(n=(n-55296<<10)+(u-56320)+65536,m++);}n<=127?e.push(n):n<=2047?(e.push(192|n>>6),e.push(128|n&63)):n<=65535?(e.push(224|n>>12),e.push(128|n>>6&63),e.push(128|n&63)):(e.push(240|n>>18),e.push(128|n>>12&63),e.push(128|n>>6&63),e.push(128|n&63));}return e}function B(o){let e=[];for(let m=0;m<16;m++)e[m]=o[m*4]+(o[m*4+1]<<8)+(o[m*4+2]<<16)+(o[m*4+3]<<24);return e}function N(o,e){let m=_(o),n=m.length,u=[1732584193,-271733879,-1732584194,271733878],r;for(r=64;r<=n;r+=64){let f=m.slice(r-64,r);s(u,B(f),e);}let t=m.slice(r-64),i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],b=t.length;for(r=0;r<b;r++)i[r>>2]|=t[r]<<(r%4<<3);if(i[r>>2]|=128<<(r%4<<3),r>55)for(s(u,i,e),r=16;r--;)i[r]=0;return i[14]=n*8,s(u,i,e),u}var y=N;function R(o){return p(y(o,d))}export{R as md5};
@@ -1,3 +1,3 @@
1
- 'use strict';var stream=require('stream');var C=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(e,s)=>(typeof require<"u"?require:e)[s]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var N="0123456789abcdef".split(""),U=N;function F(a){let e="";for(let s=0;s<4;s++)e+=U[a>>s*8+4&15]+U[a>>s*8&15];return e}function L(a){let e=a.length,s=new Array(e);for(let r=0;r<e;r++)s[r]=F(a[r]);return s.join("")}var v=L;function I(a,e){return a+e&4294967295}var m=I;function H(a,e,s,r,t){let n=t||m;return e=n(n(e,a),n(s,r)),e}function _(a,e,s,r){var n=(r||m)(a<<e|a>>>32-e,s);return n}function x(a,e,s,r,t,n,i){return e=H(a,e,r,n,i),_(e,t,s,i)}function W(a,e,s,r,t,n,i,c){return x(s&r|~s&t,e,s,n,i,c,a)}function R(a,e,s,r,t,n,i,c){return x(s&t|r&~t,e,s,n,i,c,a)}function T(a,e,s,r,t,n,i,c){return x(s^r^t,e,s,n,i,c,a)}function E(a,e,s,r,t,n,i,c){return x(r^(s|~t),e,s,n,i,c,a)}function G(a,e,s){typeof s>"u"&&(s=m);let r=a[0],t=a[1],n=a[2],i=a[3],c=W.bind(null,s);r=c(r,t,n,i,e[0],7,-680876936),i=c(i,r,t,n,e[1],12,-389564586),n=c(n,i,r,t,e[2],17,606105819),t=c(t,n,i,r,e[3],22,-1044525330),r=c(r,t,n,i,e[4],7,-176418897),i=c(i,r,t,n,e[5],12,1200080426),n=c(n,i,r,t,e[6],17,-1473231341),t=c(t,n,i,r,e[7],22,-45705983),r=c(r,t,n,i,e[8],7,1770035416),i=c(i,r,t,n,e[9],12,-1958414417),n=c(n,i,r,t,e[10],17,-42063),t=c(t,n,i,r,e[11],22,-1990404162),r=c(r,t,n,i,e[12],7,1804603682),i=c(i,r,t,n,e[13],12,-40341101),n=c(n,i,r,t,e[14],17,-1502002290),t=c(t,n,i,r,e[15],22,1236535329);let o=R.bind(null,s);r=o(r,t,n,i,e[1],5,-165796510),i=o(i,r,t,n,e[6],9,-1069501632),n=o(n,i,r,t,e[11],14,643717713),t=o(t,n,i,r,e[0],20,-373897302),r=o(r,t,n,i,e[5],5,-701558691),i=o(i,r,t,n,e[10],9,38016083),n=o(n,i,r,t,e[15],14,-660478335),t=o(t,n,i,r,e[4],20,-405537848),r=o(r,t,n,i,e[9],5,568446438),i=o(i,r,t,n,e[14],9,-1019803690),n=o(n,i,r,t,e[3],14,-187363961),t=o(t,n,i,r,e[8],20,1163531501),r=o(r,t,n,i,e[13],5,-1444681467),i=o(i,r,t,n,e[2],9,-51403784),n=o(n,i,r,t,e[7],14,1735328473),t=o(t,n,i,r,e[12],20,-1926607734);let u=T.bind(null,s);r=u(r,t,n,i,e[5],4,-378558),i=u(i,r,t,n,e[8],11,-2022574463),n=u(n,i,r,t,e[11],16,1839030562),t=u(t,n,i,r,e[14],23,-35309556),r=u(r,t,n,i,e[1],4,-1530992060),i=u(i,r,t,n,e[4],11,1272893353),n=u(n,i,r,t,e[7],16,-155497632),t=u(t,n,i,r,e[10],23,-1094730640),r=u(r,t,n,i,e[13],4,681279174),i=u(i,r,t,n,e[0],11,-358537222),n=u(n,i,r,t,e[3],16,-722521979),t=u(t,n,i,r,e[6],23,76029189),r=u(r,t,n,i,e[9],4,-640364487),i=u(i,r,t,n,e[12],11,-421815835),n=u(n,i,r,t,e[15],16,530742520),t=u(t,n,i,r,e[2],23,-995338651);let f=E.bind(null,s);r=f(r,t,n,i,e[0],6,-198630844),i=f(i,r,t,n,e[7],10,1126891415),n=f(n,i,r,t,e[14],15,-1416354905),t=f(t,n,i,r,e[5],21,-57434055),r=f(r,t,n,i,e[12],6,1700485571),i=f(i,r,t,n,e[3],10,-1894986606),n=f(n,i,r,t,e[10],15,-1051523),t=f(t,n,i,r,e[1],21,-2054922799),r=f(r,t,n,i,e[8],6,1873313359),i=f(i,r,t,n,e[15],10,-30611744),n=f(n,i,r,t,e[6],15,-1560198380),t=f(t,n,i,r,e[13],21,1309151649),r=f(r,t,n,i,e[4],6,-145523070),i=f(i,r,t,n,e[11],10,-1120210379),n=f(n,i,r,t,e[2],15,718787259),t=f(t,n,i,r,e[9],21,-343485551),a[0]=s(r,a[0]),a[1]=s(t,a[1]),a[2]=s(n,a[2]),a[3]=s(i,a[3]);}var l=G;function $(a){let e=[];for(let s=0;s<64;s+=4)e[s>>2]=(a.charCodeAt(s)||0)+((a.charCodeAt(s+1)||0)<<8)+((a.charCodeAt(s+2)||0)<<16)+((a.charCodeAt(s+3)||0)<<24);return e}var O=$;function K(a,e){let s=a.length,r=[1732584193,-271733879,-1732584194,271733878],t;for(t=64;t<=s;t+=64)l(r,O(a.substring(t-64,t)),e);a=a.substring(t-64);var n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],i=a.length;for(t=0;t<i;t++)n[t>>2]|=(a.charCodeAt(t)&255)<<(t%4<<3);if(n[t>>2]|=128<<(t%4<<3),t>55)for(l(r,n,e),t=16;t--;)n[t]=0;return n[14]=s*8,l(r,n,e),r}var j=K;function y(a){return v(j(a,m))}var g=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(e){return y(e)}async hashBinary(e){let s=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return y(s)}update(e){throw new Error("Web Crypto API does not support streaming updates")}digest(e){throw new Error("Web Crypto API does not support streaming")}reset(){}};var w=class{constructor(){this.name="nodecrypto";this.version="1.0.0";}static isAvailable(){try{return typeof C("crypto").createHash=="function"}catch{return false}}hash(e){return C("crypto").createHash("md5").update(e).digest("hex")}async hashBinary(e){let s=C("crypto"),r=e instanceof Uint8Array?e:new Uint8Array(e);return s.createHash("md5").update(r).digest("hex")}update(e){}digest(e){throw new Error("Node crypto streaming not implemented")}reset(){}};var A=class{constructor(){this.name="ie11";this.version="1.0.0";}static isAvailable(){if(typeof window>"u")return false;let e=window;return typeof e.msCrypto<"u"&&typeof e.msCrypto.subtle<"u"&&typeof e.msCrypto.subtle.digest=="function"}async hash(e){let r=new TextEncoder().encode(e);return await this.hashBinary(r)}async hashBinary(e){let s=window,r=e instanceof Uint8Array?e.buffer:e,t=await s.msCrypto.subtle.digest("MD5",r);return this.bufferToHex(t)}bufferToHex(e){return Array.from(new Uint8Array(e)).map(s=>s.toString(16).padStart(2,"0")).join("")}update(e){throw new Error("msCrypto does not support streaming updates")}digest(e){throw new Error("msCrypto does not support streaming")}reset(){}};var P=class{constructor(){this.name="purejs";this.version="0.1.0";this.state={data:"",finished:false};}hash(e){return y(e)}async hashBinary(e){let s=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return y(s)}update(e){this.state.finished&&(this.state={data:"",finished:false}),e instanceof ArrayBuffer?this.state.data+=new TextDecoder().decode(e):e instanceof Uint8Array?this.state.data+=new TextDecoder().decode(e):this.state.data+=e;}digest(e){let s=y(this.state.data);return this.state.finished=true,e==="buffer"?this.hexToBuffer(s):s}reset(){this.state={data:"",finished:false};}static isAvailable(){return true}hexToBuffer(e){let s=[];for(let r=0;r<e.length;r+=2)s.push(parseInt(e.substring(r,r+2),16));return new Uint8Array(s)}};var B=class a extends stream.Transform{constructor(s){super({readableObjectMode:false,writableObjectMode:false});this.initialMD5State=[1732584193,-271733879,-1732584194,271733878];this.bufferCapacity=64;this.buffer=new Uint8Array(this.bufferCapacity);this.add32=s?.add32||m,this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer};}_transform(s,r,t){try{let n=s,i=n.length;if(i===0){t();return}if(this.state.bufferLength>0){let u=this.state.bufferLength,f=64-u,b=Math.min(i,f);for(let d=0;d<b;d++)this.buffer[u+d]=n[d];if(this.state.bufferLength+=b,this.state.bufferLength===64&&this._processBufferBlock(),b===i){t();return}let p=i-b;for(let d=0;d<p;d++)n[d]=n[b+d];let h=Buffer.alloc(p);for(let d=0;d<p;d++)h[d]=n[d];n=h;}let c=Math.floor(n.length/64);for(let u=0;u<c;u++){let f=u*64,b=[];for(let p=0;p<16;p++){let h=f+p*4;b[p]=n[h]+(n[h+1]<<8)+(n[h+2]<<16)+(n[h+3]<<24);}l(this.state.state,b,this.add32),this.state.bytesProcessed+=64;}let o=n.length%64;if(o>0){this.buffer.length<o&&(this.buffer=new Uint8Array(o),this.state.buffer=this.buffer);for(let u=0;u<o;u++)this.buffer[u]=n[c*64+u];this.state.bufferLength=o;}t();}catch(n){t(n);}}_processBufferBlock(){let s=this.state.buffer,r=[];for(let t=0;t<16;t++){let n=t*4;r[t]=s[n]+(s[n+1]<<8)+(s[n+2]<<16)+(s[n+3]<<24);}l(this.state.state,r,this.add32),this.state.bytesProcessed+=64,this.state.bufferLength=0;}_flush(s){try{let{state:r,bufferLength:t,buffer:n}=this.state,i=new Array(16).fill(0);for(let o=0;o<t;o++)i[o>>2]|=(n[o]&255)<<(o%4<<3);if(i[t>>2]|=128<<(t%4<<3),t>55){l(r,i,this.add32);for(let o=0;o<16;o++)i[o]=0;}i[14]=(this.state.bytesProcessed+t)*8,i[15]=0,l(r,i,this.add32);let c=v(r);this.emit("md5",{digest:c,bytesProcessed:this.state.bytesProcessed+t}),s();}catch(r){s(r);}}getCurrentState(){return {state:[...this.state.state],bytesProcessed:this.state.bytesProcessed+this.state.bufferLength}}getBytesProcessed(){return this.state.bytesProcessed+this.state.bufferLength}reset(){this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer},this.buffer=new Uint8Array(this.bufferCapacity),this.state.buffer=this.buffer,this.state.bufferLength=0;}static fromStream(s,r){let t=new a(r),n=z.call(t,s);return {stream:t,result:n}}};async function z(a){return new Promise((e,s)=>{let r=[];a.pipe(this).on("md5",t=>{r.push(t);}).on("error",s).on("finish",()=>{e(r[0]);});})}var D=class{constructor(){this.name="stream";this.version="0.1.0";this.state=null;}initNodeStream(e){this.state={stream:e,type:"node"};}initWhatWGStream(e){this.state={stream:e,type:"whatwg"};}async hash(e){let s=new B;return (await new Promise((t,n)=>{s.on("md5",i=>t(i)).on("error",n).end(e);})).digest}async hashBinary(e){let s=new B,r;return e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),(await new Promise((n,i)=>{s.on("md5",c=>n(c)).on("error",i).end(r);})).digest}update(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let s=this.state.stream,r;typeof e=="string"||e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),s.write(r);}}digest(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let s=this.state.stream;return s.end(),new Promise((r,t)=>{s.on("md5",n=>{if(e==="buffer"){let i=n.digest,c=[];for(let o=0;o<i.length;o+=2)c.push(parseInt(i.substring(o,o+2),16));r(Buffer.from(c));}else r(n.digest);}).on("error",t);})}else return this.state.stream.getResult().then(r=>r.digest)}reset(){this.state&&this.state.type==="node"&&this.state.stream.reset();}static isAvailable(){return true}};var J=(t=>(t.BROWSER="browser",t.NODE="node",t.WEBWORKER="webworker",t.UNKNOWN="unknown",t))(J||{});function Ne(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof importScripts<"u"?"webworker":typeof window<"u"&&window.document?"browser":"unknown"}function Fe(){return typeof process<"u"&&process.versions!==void 0&&"node"in process.versions}function Le(){return typeof window<"u"&&typeof document<"u"}function Ie(){return typeof importScripts<"u"}async function Y(a){switch(a){case "webcrypto":let e=g.isAvailable();return {backend:"webcrypto",available:e,reason:e?void 0:"Web Crypto API not available"};case "nodecrypto":let s=w.isAvailable();return {backend:"nodecrypto",available:s,reason:s?void 0:"Node.js crypto not available"};case "ie11":let r=A.isAvailable();return {backend:"ie11",available:r,reason:r?void 0:"IE11 msCrypto not available"};case "purejs":return {backend:"purejs",available:true,reason:"Always available"};case "stream":let t=typeof process<"u"&&process.versions&&"node"in process.versions,n=typeof window<"u";return {backend:"stream",available:t||n,reason:t||n?void 0:"Streams not available"};default:return {backend:a||"unknown",available:false,reason:"Unknown backend"}}}async function Q(){let a=["webcrypto","nodecrypto","ie11","purejs","stream"],e=[];for(let s of a){let{available:r}=await Y(s);r&&e.push(s);}return e}var V=[{name:"nodecrypto",priority:1,description:"Node.js native crypto (fastest)"},{name:"webcrypto",priority:2,description:"Web Crypto API (fast, hardware accelerated)"},{name:"ie11",priority:3,description:"IE11 msCrypto (legacy)"},{name:"stream",priority:4,description:"Streaming backend (for large files and memory efficiency)"},{name:"purejs",priority:5,description:"Pure JavaScript (always available, slower)"}];function X(a){let e=[...V].sort((s,r)=>s.priority-r.priority);for(let{name:s}of e)if(a.includes(s))return s;return "purejs"}var M=class a{constructor(){}static getInstance(){return a.instance||(a.instance=new a),a.instance}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new A;case "stream":return new D;default:return new P}}async createBackend(e){let s=e||X(await Q());return this.createBackendByName(s)}},He=M.getInstance(),S=class{constructor(e=["nodecrypto","webcrypto","stream","ie11","purejs"]){this.detector=M.getInstance(),this.fallbackOrder=e;}async execute(e){let s=[];for(let r of this.fallbackOrder)try{let t=await this.detector.createBackendByName(r),n=await e(t);return {success:!0,backend:r,data:n}}catch(t){if(s.push({backend:r,error:t}),r===this.fallbackOrder[this.fallbackOrder.length-1])return {success:false,backend:r,data:null,errors:s}}return {success:false,backend:"",data:null,errors:s}}async hash(e){return this.execute(async s=>s.hash(e))}async hashBinary(e){return this.execute(async s=>s.hashBinary(e))}async getBestBackend(){let e=await this.getAvailableBackends();return e.length===0?"purejs":e[0]}async getAvailableBackends(){let e=[];for(let s of this.fallbackOrder)try{await this.detector.createBackendByName(s),e.push(s);}catch{}return e}getMetrics(){return {}}},_e=new S;async function Ge(a,e={}){let s=new S;if(e.forceBackend)return (await s.detector.createBackendByName(e.forceBackend)).hash(a);if(e.fallback===false)return (await s.detector.createBackend()).hash(a);let r=await s.hash(a);if(r.success)return e.reportFallback&&r.backend!=="nodecrypto"&&r.backend!=="webcrypto"&&console.info(`MD5 used fallback backend: ${r.backend}`),r.data;let t=r.errors?r.errors.map(n=>`${n.backend}: ${n.error.message}`).join(", "):"All backends failed";throw new Error(`MD5 hash failed after all attempts: ${t}`)}var k=class{constructor(){this.metrics={nodecrypto:{success:0,fail:0},webcrypto:{success:0,fail:0},ie11:{success:0,fail:0},stream:{success:0,fail:0},purejs:{success:0,fail:0}};}recordSuccess(e){this.metrics[e]&&this.metrics[e].success++;}recordFail(e){this.metrics[e]&&this.metrics[e].fail++;}getMetrics(){return this.metrics}getSummary(){return `Total operations: ${Object.values(this.metrics).reduce((s,r)=>s+r.success+r.fail,0)}
1
+ 'use strict';var stream=require('stream');var U=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(e,s)=>(typeof require<"u"?require:e)[s]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var O="0123456789abcdef".split(""),C=O;function j(a){let e="";for(let s=0;s<4;s++)e+=C[a>>s*8+4&15]+C[a>>s*8&15];return e}function F(a){let e=a.length,s=new Array(e);for(let r=0;r<e;r++)s[r]=j(a[r]);return s.join("")}var x=F;function L(a,e){return a+e&4294967295}var m=L;function I(a,e,s,r,n){let t=n||m;return e=t(t(e,a),t(s,r)),e}function H(a,e,s,r){var t=(r||m)(a<<e|a>>>32-e,s);return t}function v(a,e,s,r,n,t,i){return e=I(a,e,r,t,i),H(e,n,s,i)}function W(a,e,s,r,n,t,i,o){return v(s&r|~s&n,e,s,t,i,o,a)}function T(a,e,s,r,n,t,i,o){return v(s&n|r&~n,e,s,t,i,o,a)}function R(a,e,s,r,n,t,i,o){return v(s^r^n,e,s,t,i,o,a)}function E(a,e,s,r,n,t,i,o){return v(r^(s|~n),e,s,t,i,o,a)}function _(a,e,s){typeof s>"u"&&(s=m);let r=a[0],n=a[1],t=a[2],i=a[3],o=W.bind(null,s);r=o(r,n,t,i,e[0],7,-680876936),i=o(i,r,n,t,e[1],12,-389564586),t=o(t,i,r,n,e[2],17,606105819),n=o(n,t,i,r,e[3],22,-1044525330),r=o(r,n,t,i,e[4],7,-176418897),i=o(i,r,n,t,e[5],12,1200080426),t=o(t,i,r,n,e[6],17,-1473231341),n=o(n,t,i,r,e[7],22,-45705983),r=o(r,n,t,i,e[8],7,1770035416),i=o(i,r,n,t,e[9],12,-1958414417),t=o(t,i,r,n,e[10],17,-42063),n=o(n,t,i,r,e[11],22,-1990404162),r=o(r,n,t,i,e[12],7,1804603682),i=o(i,r,n,t,e[13],12,-40341101),t=o(t,i,r,n,e[14],17,-1502002290),n=o(n,t,i,r,e[15],22,1236535329);let c=T.bind(null,s);r=c(r,n,t,i,e[1],5,-165796510),i=c(i,r,n,t,e[6],9,-1069501632),t=c(t,i,r,n,e[11],14,643717713),n=c(n,t,i,r,e[0],20,-373897302),r=c(r,n,t,i,e[5],5,-701558691),i=c(i,r,n,t,e[10],9,38016083),t=c(t,i,r,n,e[15],14,-660478335),n=c(n,t,i,r,e[4],20,-405537848),r=c(r,n,t,i,e[9],5,568446438),i=c(i,r,n,t,e[14],9,-1019803690),t=c(t,i,r,n,e[3],14,-187363961),n=c(n,t,i,r,e[8],20,1163531501),r=c(r,n,t,i,e[13],5,-1444681467),i=c(i,r,n,t,e[2],9,-51403784),t=c(t,i,r,n,e[7],14,1735328473),n=c(n,t,i,r,e[12],20,-1926607734);let f=R.bind(null,s);r=f(r,n,t,i,e[5],4,-378558),i=f(i,r,n,t,e[8],11,-2022574463),t=f(t,i,r,n,e[11],16,1839030562),n=f(n,t,i,r,e[14],23,-35309556),r=f(r,n,t,i,e[1],4,-1530992060),i=f(i,r,n,t,e[4],11,1272893353),t=f(t,i,r,n,e[7],16,-155497632),n=f(n,t,i,r,e[10],23,-1094730640),r=f(r,n,t,i,e[13],4,681279174),i=f(i,r,n,t,e[0],11,-358537222),t=f(t,i,r,n,e[3],16,-722521979),n=f(n,t,i,r,e[6],23,76029189),r=f(r,n,t,i,e[9],4,-640364487),i=f(i,r,n,t,e[12],11,-421815835),t=f(t,i,r,n,e[15],16,530742520),n=f(n,t,i,r,e[2],23,-995338651);let u=E.bind(null,s);r=u(r,n,t,i,e[0],6,-198630844),i=u(i,r,n,t,e[7],10,1126891415),t=u(t,i,r,n,e[14],15,-1416354905),n=u(n,t,i,r,e[5],21,-57434055),r=u(r,n,t,i,e[12],6,1700485571),i=u(i,r,n,t,e[3],10,-1894986606),t=u(t,i,r,n,e[10],15,-1051523),n=u(n,t,i,r,e[1],21,-2054922799),r=u(r,n,t,i,e[8],6,1873313359),i=u(i,r,n,t,e[15],10,-30611744),t=u(t,i,r,n,e[6],15,-1560198380),n=u(n,t,i,r,e[13],21,1309151649),r=u(r,n,t,i,e[4],6,-145523070),i=u(i,r,n,t,e[11],10,-1120210379),t=u(t,i,r,n,e[2],15,718787259),n=u(n,t,i,r,e[9],21,-343485551),a[0]=s(r,a[0]),a[1]=s(n,a[1]),a[2]=s(t,a[2]),a[3]=s(i,a[3]);}var l=_;function G(a){let e=[];for(let s=0;s<a.length;s++){let r=a.charCodeAt(s);if(r>=55296&&r<=56319&&s+1<a.length){let n=a.charCodeAt(s+1);n>=56320&&n<=57343&&(r=(r-55296<<10)+(n-56320)+65536,s++);}r<=127?e.push(r):r<=2047?(e.push(192|r>>6),e.push(128|r&63)):r<=65535?(e.push(224|r>>12),e.push(128|r>>6&63),e.push(128|r&63)):(e.push(240|r>>18),e.push(128|r>>12&63),e.push(128|r>>6&63),e.push(128|r&63));}return e}function $(a){let e=[];for(let s=0;s<16;s++)e[s]=a[s*4]+(a[s*4+1]<<8)+(a[s*4+2]<<16)+(a[s*4+3]<<24);return e}function K(a,e){let s=G(a),r=s.length,n=[1732584193,-271733879,-1732584194,271733878],t;for(t=64;t<=r;t+=64){let f=s.slice(t-64,t);l(n,$(f),e);}let i=s.slice(t-64),o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=i.length;for(t=0;t<c;t++)o[t>>2]|=i[t]<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(l(n,o,e),t=16;t--;)o[t]=0;return o[14]=r*8,l(n,o,e),n}var N=K;function y(a){return x(N(a,m))}var g=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(e){return y(e)}async hashBinary(e){let s=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return y(s)}update(e){throw new Error("Web Crypto API does not support streaming updates")}digest(e){throw new Error("Web Crypto API does not support streaming")}reset(){}};var w=class{constructor(){this.name="nodecrypto";this.version="1.0.0";}static isAvailable(){try{return typeof U("crypto").createHash=="function"}catch{return false}}hash(e){return U("crypto").createHash("md5").update(e).digest("hex")}async hashBinary(e){let s=U("crypto"),r=e instanceof Uint8Array?e:new Uint8Array(e);return s.createHash("md5").update(r).digest("hex")}update(e){}digest(e){throw new Error("Node crypto streaming not implemented")}reset(){}};var A=class{constructor(){this.name="ie11";this.version="1.0.0";}static isAvailable(){if(typeof window>"u")return false;let e=window;return typeof e.msCrypto<"u"&&typeof e.msCrypto.subtle<"u"&&typeof e.msCrypto.subtle.digest=="function"}async hash(e){let r=new TextEncoder().encode(e);return await this.hashBinary(r)}async hashBinary(e){let s=window,r=e instanceof Uint8Array?e.buffer:e,n=await s.msCrypto.subtle.digest("MD5",r);return this.bufferToHex(n)}bufferToHex(e){return Array.from(new Uint8Array(e)).map(s=>s.toString(16).padStart(2,"0")).join("")}update(e){throw new Error("msCrypto does not support streaming updates")}digest(e){throw new Error("msCrypto does not support streaming")}reset(){}};var P=class{constructor(){this.name="purejs";this.version="0.1.0";this.state={data:"",finished:false};}hash(e){return y(e)}async hashBinary(e){let s=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return y(s)}update(e){this.state.finished&&(this.state={data:"",finished:false}),e instanceof ArrayBuffer?this.state.data+=new TextDecoder().decode(e):e instanceof Uint8Array?this.state.data+=new TextDecoder().decode(e):this.state.data+=e;}digest(e){let s=y(this.state.data);return this.state.finished=true,e==="buffer"?this.hexToBuffer(s):s}reset(){this.state={data:"",finished:false};}static isAvailable(){return true}hexToBuffer(e){let s=[];for(let r=0;r<e.length;r+=2)s.push(parseInt(e.substring(r,r+2),16));return new Uint8Array(s)}};var B=class a extends stream.Transform{constructor(s){super({readableObjectMode:false,writableObjectMode:false});this.initialMD5State=[1732584193,-271733879,-1732584194,271733878];this.bufferCapacity=64;this.buffer=new Uint8Array(this.bufferCapacity);this.add32=s?.add32||m,this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer};}_transform(s,r,n){try{let t=s,i=t.length;if(i===0){n();return}if(this.state.bufferLength>0){let f=this.state.bufferLength,u=64-f,b=Math.min(i,u);for(let d=0;d<b;d++)this.buffer[f+d]=t[d];if(this.state.bufferLength+=b,this.state.bufferLength===64&&this._processBufferBlock(),b===i){n();return}let p=i-b;for(let d=0;d<p;d++)t[d]=t[b+d];let h=Buffer.alloc(p);for(let d=0;d<p;d++)h[d]=t[d];t=h;}let o=Math.floor(t.length/64);for(let f=0;f<o;f++){let u=f*64,b=[];for(let p=0;p<16;p++){let h=u+p*4;b[p]=t[h]+(t[h+1]<<8)+(t[h+2]<<16)+(t[h+3]<<24);}l(this.state.state,b,this.add32),this.state.bytesProcessed+=64;}let c=t.length%64;if(c>0){this.buffer.length<c&&(this.buffer=new Uint8Array(c),this.state.buffer=this.buffer);for(let f=0;f<c;f++)this.buffer[f]=t[o*64+f];this.state.bufferLength=c;}n();}catch(t){n(t);}}_processBufferBlock(){let s=this.state.buffer,r=[];for(let n=0;n<16;n++){let t=n*4;r[n]=s[t]+(s[t+1]<<8)+(s[t+2]<<16)+(s[t+3]<<24);}l(this.state.state,r,this.add32),this.state.bytesProcessed+=64,this.state.bufferLength=0;}_flush(s){try{let{state:r,bufferLength:n,buffer:t}=this.state,i=new Array(16).fill(0);for(let c=0;c<n;c++)i[c>>2]|=(t[c]&255)<<(c%4<<3);if(i[n>>2]|=128<<(n%4<<3),n>55){l(r,i,this.add32);for(let c=0;c<16;c++)i[c]=0;}i[14]=(this.state.bytesProcessed+n)*8,i[15]=0,l(r,i,this.add32);let o=x(r);this.emit("md5",{digest:o,bytesProcessed:this.state.bytesProcessed+n}),s();}catch(r){s(r);}}getCurrentState(){return {state:[...this.state.state],bytesProcessed:this.state.bytesProcessed+this.state.bufferLength}}getBytesProcessed(){return this.state.bytesProcessed+this.state.bufferLength}reset(){this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer},this.buffer=new Uint8Array(this.bufferCapacity),this.state.buffer=this.buffer,this.state.bufferLength=0;}static fromStream(s,r){let n=new a(r),t=z.call(n,s);return {stream:n,result:t}}};async function z(a){return new Promise((e,s)=>{let r=[];a.pipe(this).on("md5",n=>{r.push(n);}).on("error",s).on("finish",()=>{e(r[0]);});})}var D=class{constructor(){this.name="stream";this.version="0.1.0";this.state=null;}initNodeStream(e){this.state={stream:e,type:"node"};}initWhatWGStream(e){this.state={stream:e,type:"whatwg"};}async hash(e){let s=new B;return (await new Promise((n,t)=>{s.on("md5",i=>n(i)).on("error",t).end(e);})).digest}async hashBinary(e){let s=new B,r;return e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),(await new Promise((t,i)=>{s.on("md5",o=>t(o)).on("error",i).end(r);})).digest}update(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let s=this.state.stream,r;typeof e=="string"||e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),s.write(r);}}digest(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let s=this.state.stream;return s.end(),new Promise((r,n)=>{s.on("md5",t=>{if(e==="buffer"){let i=t.digest,o=[];for(let c=0;c<i.length;c+=2)o.push(parseInt(i.substring(c,c+2),16));r(Buffer.from(o));}else r(t.digest);}).on("error",n);})}else return this.state.stream.getResult().then(r=>r.digest)}reset(){this.state&&this.state.type==="node"&&this.state.stream.reset();}static isAvailable(){return true}};var J=(n=>(n.BROWSER="browser",n.NODE="node",n.WEBWORKER="webworker",n.UNKNOWN="unknown",n))(J||{});function Ne(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof importScripts<"u"?"webworker":typeof window<"u"&&window.document?"browser":"unknown"}function Oe(){return typeof process<"u"&&process.versions!==void 0&&"node"in process.versions}function je(){return typeof window<"u"&&typeof document<"u"}function Fe(){return typeof importScripts<"u"}async function Y(a){switch(a){case "webcrypto":let e=g.isAvailable();return {backend:"webcrypto",available:e,reason:e?void 0:"Web Crypto API not available"};case "nodecrypto":let s=w.isAvailable();return {backend:"nodecrypto",available:s,reason:s?void 0:"Node.js crypto not available"};case "ie11":let r=A.isAvailable();return {backend:"ie11",available:r,reason:r?void 0:"IE11 msCrypto not available"};case "purejs":return {backend:"purejs",available:true,reason:"Always available"};case "stream":let n=typeof process<"u"&&process.versions&&"node"in process.versions,t=typeof window<"u";return {backend:"stream",available:n||t,reason:n||t?void 0:"Streams not available"};default:return {backend:a||"unknown",available:false,reason:"Unknown backend"}}}async function Q(){let a=["webcrypto","nodecrypto","ie11","purejs","stream"],e=[];for(let s of a){let{available:r}=await Y(s);r&&e.push(s);}return e}var V=[{name:"nodecrypto",priority:1,description:"Node.js native crypto (fastest)"},{name:"webcrypto",priority:2,description:"Web Crypto API (fast, hardware accelerated)"},{name:"ie11",priority:3,description:"IE11 msCrypto (legacy)"},{name:"stream",priority:4,description:"Streaming backend (for large files and memory efficiency)"},{name:"purejs",priority:5,description:"Pure JavaScript (always available, slower)"}];function X(a){let e=[...V].sort((s,r)=>s.priority-r.priority);for(let{name:s}of e)if(a.includes(s))return s;return "purejs"}var M=class a{constructor(){}static getInstance(){return a.instance||(a.instance=new a),a.instance}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new A;case "stream":return new D;default:return new P}}async createBackend(e){let s=e||X(await Q());return this.createBackendByName(s)}},Le=M.getInstance(),S=class{constructor(e=["nodecrypto","webcrypto","stream","ie11","purejs"]){this.detector=M.getInstance(),this.fallbackOrder=e;}async execute(e){let s=[];for(let r of this.fallbackOrder)try{let n=await this.detector.createBackendByName(r),t=await e(n);return {success:!0,backend:r,data:t}}catch(n){if(s.push({backend:r,error:n}),r===this.fallbackOrder[this.fallbackOrder.length-1])return {success:false,backend:r,data:null,errors:s}}return {success:false,backend:"",data:null,errors:s}}async hash(e){return this.execute(async s=>s.hash(e))}async hashBinary(e){return this.execute(async s=>s.hashBinary(e))}async getBestBackend(){let e=await this.getAvailableBackends();return e.length===0?"purejs":e[0]}async getAvailableBackends(){let e=[];for(let s of this.fallbackOrder)try{await this.detector.createBackendByName(s),e.push(s);}catch{}return e}getMetrics(){return {}}},Ie=new S;async function He(a,e={}){let s=new S;if(e.forceBackend)return (await s.detector.createBackendByName(e.forceBackend)).hash(a);if(e.fallback===false)return (await s.detector.createBackend()).hash(a);let r=await s.hash(a);if(r.success)return e.reportFallback&&r.backend!=="nodecrypto"&&r.backend!=="webcrypto"&&console.info(`MD5 used fallback backend: ${r.backend}`),r.data;let n=r.errors?r.errors.map(t=>`${t.backend}: ${t.error.message}`).join(", "):"All backends failed";throw new Error(`MD5 hash failed after all attempts: ${n}`)}var k=class{constructor(){this.metrics={nodecrypto:{success:0,fail:0},webcrypto:{success:0,fail:0},ie11:{success:0,fail:0},stream:{success:0,fail:0},purejs:{success:0,fail:0}};}recordSuccess(e){this.metrics[e]&&this.metrics[e].success++;}recordFail(e){this.metrics[e]&&this.metrics[e].fail++;}getMetrics(){return this.metrics}getSummary(){return `Total operations: ${Object.values(this.metrics).reduce((s,r)=>s+r.success+r.fail,0)}
2
2
  `+Object.entries(this.metrics).map(([,s])=>`${s.success} success, ${s.fail} fail`).join(`
3
- `)}reset(){Object.keys(this.metrics).forEach(e=>{this.metrics[e]={success:0,fail:0};});}},$e=new k;exports.BACKEND_PRIORITY=V;exports.BackendDetector=M;exports.FallbackManager=S;exports.MetricsCollector=k;exports.RuntimeEnvironment=J;exports.checkBackendAvailability=Y;exports.detectEnvironment=Ne;exports.detector=He;exports.fallbackManager=_e;exports.getAllAvailableBackends=Q;exports.getBestAvailableBackend=X;exports.isBrowser=Le;exports.isNode=Fe;exports.isWebWorker=Ie;exports.metrics=$e;exports.robustHash=Ge;
3
+ `)}reset(){Object.keys(this.metrics).forEach(e=>{this.metrics[e]={success:0,fail:0};});}},_e=new k;exports.BACKEND_PRIORITY=V;exports.BackendDetector=M;exports.FallbackManager=S;exports.MetricsCollector=k;exports.RuntimeEnvironment=J;exports.checkBackendAvailability=Y;exports.detectEnvironment=Ne;exports.detector=Le;exports.fallbackManager=Ie;exports.getAllAvailableBackends=Q;exports.getBestAvailableBackend=X;exports.isBrowser=je;exports.isNode=Oe;exports.isWebWorker=Fe;exports.metrics=_e;exports.robustHash=He;
@@ -1,3 +1,3 @@
1
- import {Transform}from'stream';var C=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(e,s)=>(typeof require<"u"?require:e)[s]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var N="0123456789abcdef".split(""),U=N;function F(a){let e="";for(let s=0;s<4;s++)e+=U[a>>s*8+4&15]+U[a>>s*8&15];return e}function L(a){let e=a.length,s=new Array(e);for(let r=0;r<e;r++)s[r]=F(a[r]);return s.join("")}var v=L;function I(a,e){return a+e&4294967295}var m=I;function H(a,e,s,r,t){let n=t||m;return e=n(n(e,a),n(s,r)),e}function _(a,e,s,r){var n=(r||m)(a<<e|a>>>32-e,s);return n}function x(a,e,s,r,t,n,i){return e=H(a,e,r,n,i),_(e,t,s,i)}function W(a,e,s,r,t,n,i,c){return x(s&r|~s&t,e,s,n,i,c,a)}function R(a,e,s,r,t,n,i,c){return x(s&t|r&~t,e,s,n,i,c,a)}function T(a,e,s,r,t,n,i,c){return x(s^r^t,e,s,n,i,c,a)}function E(a,e,s,r,t,n,i,c){return x(r^(s|~t),e,s,n,i,c,a)}function G(a,e,s){typeof s>"u"&&(s=m);let r=a[0],t=a[1],n=a[2],i=a[3],c=W.bind(null,s);r=c(r,t,n,i,e[0],7,-680876936),i=c(i,r,t,n,e[1],12,-389564586),n=c(n,i,r,t,e[2],17,606105819),t=c(t,n,i,r,e[3],22,-1044525330),r=c(r,t,n,i,e[4],7,-176418897),i=c(i,r,t,n,e[5],12,1200080426),n=c(n,i,r,t,e[6],17,-1473231341),t=c(t,n,i,r,e[7],22,-45705983),r=c(r,t,n,i,e[8],7,1770035416),i=c(i,r,t,n,e[9],12,-1958414417),n=c(n,i,r,t,e[10],17,-42063),t=c(t,n,i,r,e[11],22,-1990404162),r=c(r,t,n,i,e[12],7,1804603682),i=c(i,r,t,n,e[13],12,-40341101),n=c(n,i,r,t,e[14],17,-1502002290),t=c(t,n,i,r,e[15],22,1236535329);let o=R.bind(null,s);r=o(r,t,n,i,e[1],5,-165796510),i=o(i,r,t,n,e[6],9,-1069501632),n=o(n,i,r,t,e[11],14,643717713),t=o(t,n,i,r,e[0],20,-373897302),r=o(r,t,n,i,e[5],5,-701558691),i=o(i,r,t,n,e[10],9,38016083),n=o(n,i,r,t,e[15],14,-660478335),t=o(t,n,i,r,e[4],20,-405537848),r=o(r,t,n,i,e[9],5,568446438),i=o(i,r,t,n,e[14],9,-1019803690),n=o(n,i,r,t,e[3],14,-187363961),t=o(t,n,i,r,e[8],20,1163531501),r=o(r,t,n,i,e[13],5,-1444681467),i=o(i,r,t,n,e[2],9,-51403784),n=o(n,i,r,t,e[7],14,1735328473),t=o(t,n,i,r,e[12],20,-1926607734);let u=T.bind(null,s);r=u(r,t,n,i,e[5],4,-378558),i=u(i,r,t,n,e[8],11,-2022574463),n=u(n,i,r,t,e[11],16,1839030562),t=u(t,n,i,r,e[14],23,-35309556),r=u(r,t,n,i,e[1],4,-1530992060),i=u(i,r,t,n,e[4],11,1272893353),n=u(n,i,r,t,e[7],16,-155497632),t=u(t,n,i,r,e[10],23,-1094730640),r=u(r,t,n,i,e[13],4,681279174),i=u(i,r,t,n,e[0],11,-358537222),n=u(n,i,r,t,e[3],16,-722521979),t=u(t,n,i,r,e[6],23,76029189),r=u(r,t,n,i,e[9],4,-640364487),i=u(i,r,t,n,e[12],11,-421815835),n=u(n,i,r,t,e[15],16,530742520),t=u(t,n,i,r,e[2],23,-995338651);let f=E.bind(null,s);r=f(r,t,n,i,e[0],6,-198630844),i=f(i,r,t,n,e[7],10,1126891415),n=f(n,i,r,t,e[14],15,-1416354905),t=f(t,n,i,r,e[5],21,-57434055),r=f(r,t,n,i,e[12],6,1700485571),i=f(i,r,t,n,e[3],10,-1894986606),n=f(n,i,r,t,e[10],15,-1051523),t=f(t,n,i,r,e[1],21,-2054922799),r=f(r,t,n,i,e[8],6,1873313359),i=f(i,r,t,n,e[15],10,-30611744),n=f(n,i,r,t,e[6],15,-1560198380),t=f(t,n,i,r,e[13],21,1309151649),r=f(r,t,n,i,e[4],6,-145523070),i=f(i,r,t,n,e[11],10,-1120210379),n=f(n,i,r,t,e[2],15,718787259),t=f(t,n,i,r,e[9],21,-343485551),a[0]=s(r,a[0]),a[1]=s(t,a[1]),a[2]=s(n,a[2]),a[3]=s(i,a[3]);}var l=G;function $(a){let e=[];for(let s=0;s<64;s+=4)e[s>>2]=(a.charCodeAt(s)||0)+((a.charCodeAt(s+1)||0)<<8)+((a.charCodeAt(s+2)||0)<<16)+((a.charCodeAt(s+3)||0)<<24);return e}var O=$;function K(a,e){let s=a.length,r=[1732584193,-271733879,-1732584194,271733878],t;for(t=64;t<=s;t+=64)l(r,O(a.substring(t-64,t)),e);a=a.substring(t-64);var n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],i=a.length;for(t=0;t<i;t++)n[t>>2]|=(a.charCodeAt(t)&255)<<(t%4<<3);if(n[t>>2]|=128<<(t%4<<3),t>55)for(l(r,n,e),t=16;t--;)n[t]=0;return n[14]=s*8,l(r,n,e),r}var j=K;function y(a){return v(j(a,m))}var g=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(e){return y(e)}async hashBinary(e){let s=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return y(s)}update(e){throw new Error("Web Crypto API does not support streaming updates")}digest(e){throw new Error("Web Crypto API does not support streaming")}reset(){}};var w=class{constructor(){this.name="nodecrypto";this.version="1.0.0";}static isAvailable(){try{return typeof C("crypto").createHash=="function"}catch{return false}}hash(e){return C("crypto").createHash("md5").update(e).digest("hex")}async hashBinary(e){let s=C("crypto"),r=e instanceof Uint8Array?e:new Uint8Array(e);return s.createHash("md5").update(r).digest("hex")}update(e){}digest(e){throw new Error("Node crypto streaming not implemented")}reset(){}};var A=class{constructor(){this.name="ie11";this.version="1.0.0";}static isAvailable(){if(typeof window>"u")return false;let e=window;return typeof e.msCrypto<"u"&&typeof e.msCrypto.subtle<"u"&&typeof e.msCrypto.subtle.digest=="function"}async hash(e){let r=new TextEncoder().encode(e);return await this.hashBinary(r)}async hashBinary(e){let s=window,r=e instanceof Uint8Array?e.buffer:e,t=await s.msCrypto.subtle.digest("MD5",r);return this.bufferToHex(t)}bufferToHex(e){return Array.from(new Uint8Array(e)).map(s=>s.toString(16).padStart(2,"0")).join("")}update(e){throw new Error("msCrypto does not support streaming updates")}digest(e){throw new Error("msCrypto does not support streaming")}reset(){}};var P=class{constructor(){this.name="purejs";this.version="0.1.0";this.state={data:"",finished:false};}hash(e){return y(e)}async hashBinary(e){let s=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return y(s)}update(e){this.state.finished&&(this.state={data:"",finished:false}),e instanceof ArrayBuffer?this.state.data+=new TextDecoder().decode(e):e instanceof Uint8Array?this.state.data+=new TextDecoder().decode(e):this.state.data+=e;}digest(e){let s=y(this.state.data);return this.state.finished=true,e==="buffer"?this.hexToBuffer(s):s}reset(){this.state={data:"",finished:false};}static isAvailable(){return true}hexToBuffer(e){let s=[];for(let r=0;r<e.length;r+=2)s.push(parseInt(e.substring(r,r+2),16));return new Uint8Array(s)}};var B=class a extends Transform{constructor(s){super({readableObjectMode:false,writableObjectMode:false});this.initialMD5State=[1732584193,-271733879,-1732584194,271733878];this.bufferCapacity=64;this.buffer=new Uint8Array(this.bufferCapacity);this.add32=s?.add32||m,this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer};}_transform(s,r,t){try{let n=s,i=n.length;if(i===0){t();return}if(this.state.bufferLength>0){let u=this.state.bufferLength,f=64-u,b=Math.min(i,f);for(let d=0;d<b;d++)this.buffer[u+d]=n[d];if(this.state.bufferLength+=b,this.state.bufferLength===64&&this._processBufferBlock(),b===i){t();return}let p=i-b;for(let d=0;d<p;d++)n[d]=n[b+d];let h=Buffer.alloc(p);for(let d=0;d<p;d++)h[d]=n[d];n=h;}let c=Math.floor(n.length/64);for(let u=0;u<c;u++){let f=u*64,b=[];for(let p=0;p<16;p++){let h=f+p*4;b[p]=n[h]+(n[h+1]<<8)+(n[h+2]<<16)+(n[h+3]<<24);}l(this.state.state,b,this.add32),this.state.bytesProcessed+=64;}let o=n.length%64;if(o>0){this.buffer.length<o&&(this.buffer=new Uint8Array(o),this.state.buffer=this.buffer);for(let u=0;u<o;u++)this.buffer[u]=n[c*64+u];this.state.bufferLength=o;}t();}catch(n){t(n);}}_processBufferBlock(){let s=this.state.buffer,r=[];for(let t=0;t<16;t++){let n=t*4;r[t]=s[n]+(s[n+1]<<8)+(s[n+2]<<16)+(s[n+3]<<24);}l(this.state.state,r,this.add32),this.state.bytesProcessed+=64,this.state.bufferLength=0;}_flush(s){try{let{state:r,bufferLength:t,buffer:n}=this.state,i=new Array(16).fill(0);for(let o=0;o<t;o++)i[o>>2]|=(n[o]&255)<<(o%4<<3);if(i[t>>2]|=128<<(t%4<<3),t>55){l(r,i,this.add32);for(let o=0;o<16;o++)i[o]=0;}i[14]=(this.state.bytesProcessed+t)*8,i[15]=0,l(r,i,this.add32);let c=v(r);this.emit("md5",{digest:c,bytesProcessed:this.state.bytesProcessed+t}),s();}catch(r){s(r);}}getCurrentState(){return {state:[...this.state.state],bytesProcessed:this.state.bytesProcessed+this.state.bufferLength}}getBytesProcessed(){return this.state.bytesProcessed+this.state.bufferLength}reset(){this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer},this.buffer=new Uint8Array(this.bufferCapacity),this.state.buffer=this.buffer,this.state.bufferLength=0;}static fromStream(s,r){let t=new a(r),n=z.call(t,s);return {stream:t,result:n}}};async function z(a){return new Promise((e,s)=>{let r=[];a.pipe(this).on("md5",t=>{r.push(t);}).on("error",s).on("finish",()=>{e(r[0]);});})}var D=class{constructor(){this.name="stream";this.version="0.1.0";this.state=null;}initNodeStream(e){this.state={stream:e,type:"node"};}initWhatWGStream(e){this.state={stream:e,type:"whatwg"};}async hash(e){let s=new B;return (await new Promise((t,n)=>{s.on("md5",i=>t(i)).on("error",n).end(e);})).digest}async hashBinary(e){let s=new B,r;return e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),(await new Promise((n,i)=>{s.on("md5",c=>n(c)).on("error",i).end(r);})).digest}update(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let s=this.state.stream,r;typeof e=="string"||e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),s.write(r);}}digest(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let s=this.state.stream;return s.end(),new Promise((r,t)=>{s.on("md5",n=>{if(e==="buffer"){let i=n.digest,c=[];for(let o=0;o<i.length;o+=2)c.push(parseInt(i.substring(o,o+2),16));r(Buffer.from(c));}else r(n.digest);}).on("error",t);})}else return this.state.stream.getResult().then(r=>r.digest)}reset(){this.state&&this.state.type==="node"&&this.state.stream.reset();}static isAvailable(){return true}};var J=(t=>(t.BROWSER="browser",t.NODE="node",t.WEBWORKER="webworker",t.UNKNOWN="unknown",t))(J||{});function Ne(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof importScripts<"u"?"webworker":typeof window<"u"&&window.document?"browser":"unknown"}function Fe(){return typeof process<"u"&&process.versions!==void 0&&"node"in process.versions}function Le(){return typeof window<"u"&&typeof document<"u"}function Ie(){return typeof importScripts<"u"}async function Y(a){switch(a){case "webcrypto":let e=g.isAvailable();return {backend:"webcrypto",available:e,reason:e?void 0:"Web Crypto API not available"};case "nodecrypto":let s=w.isAvailable();return {backend:"nodecrypto",available:s,reason:s?void 0:"Node.js crypto not available"};case "ie11":let r=A.isAvailable();return {backend:"ie11",available:r,reason:r?void 0:"IE11 msCrypto not available"};case "purejs":return {backend:"purejs",available:true,reason:"Always available"};case "stream":let t=typeof process<"u"&&process.versions&&"node"in process.versions,n=typeof window<"u";return {backend:"stream",available:t||n,reason:t||n?void 0:"Streams not available"};default:return {backend:a||"unknown",available:false,reason:"Unknown backend"}}}async function Q(){let a=["webcrypto","nodecrypto","ie11","purejs","stream"],e=[];for(let s of a){let{available:r}=await Y(s);r&&e.push(s);}return e}var V=[{name:"nodecrypto",priority:1,description:"Node.js native crypto (fastest)"},{name:"webcrypto",priority:2,description:"Web Crypto API (fast, hardware accelerated)"},{name:"ie11",priority:3,description:"IE11 msCrypto (legacy)"},{name:"stream",priority:4,description:"Streaming backend (for large files and memory efficiency)"},{name:"purejs",priority:5,description:"Pure JavaScript (always available, slower)"}];function X(a){let e=[...V].sort((s,r)=>s.priority-r.priority);for(let{name:s}of e)if(a.includes(s))return s;return "purejs"}var M=class a{constructor(){}static getInstance(){return a.instance||(a.instance=new a),a.instance}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new A;case "stream":return new D;default:return new P}}async createBackend(e){let s=e||X(await Q());return this.createBackendByName(s)}},He=M.getInstance(),S=class{constructor(e=["nodecrypto","webcrypto","stream","ie11","purejs"]){this.detector=M.getInstance(),this.fallbackOrder=e;}async execute(e){let s=[];for(let r of this.fallbackOrder)try{let t=await this.detector.createBackendByName(r),n=await e(t);return {success:!0,backend:r,data:n}}catch(t){if(s.push({backend:r,error:t}),r===this.fallbackOrder[this.fallbackOrder.length-1])return {success:false,backend:r,data:null,errors:s}}return {success:false,backend:"",data:null,errors:s}}async hash(e){return this.execute(async s=>s.hash(e))}async hashBinary(e){return this.execute(async s=>s.hashBinary(e))}async getBestBackend(){let e=await this.getAvailableBackends();return e.length===0?"purejs":e[0]}async getAvailableBackends(){let e=[];for(let s of this.fallbackOrder)try{await this.detector.createBackendByName(s),e.push(s);}catch{}return e}getMetrics(){return {}}},_e=new S;async function Ge(a,e={}){let s=new S;if(e.forceBackend)return (await s.detector.createBackendByName(e.forceBackend)).hash(a);if(e.fallback===false)return (await s.detector.createBackend()).hash(a);let r=await s.hash(a);if(r.success)return e.reportFallback&&r.backend!=="nodecrypto"&&r.backend!=="webcrypto"&&console.info(`MD5 used fallback backend: ${r.backend}`),r.data;let t=r.errors?r.errors.map(n=>`${n.backend}: ${n.error.message}`).join(", "):"All backends failed";throw new Error(`MD5 hash failed after all attempts: ${t}`)}var k=class{constructor(){this.metrics={nodecrypto:{success:0,fail:0},webcrypto:{success:0,fail:0},ie11:{success:0,fail:0},stream:{success:0,fail:0},purejs:{success:0,fail:0}};}recordSuccess(e){this.metrics[e]&&this.metrics[e].success++;}recordFail(e){this.metrics[e]&&this.metrics[e].fail++;}getMetrics(){return this.metrics}getSummary(){return `Total operations: ${Object.values(this.metrics).reduce((s,r)=>s+r.success+r.fail,0)}
1
+ import {Transform}from'stream';var U=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(e,s)=>(typeof require<"u"?require:e)[s]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var O="0123456789abcdef".split(""),C=O;function j(a){let e="";for(let s=0;s<4;s++)e+=C[a>>s*8+4&15]+C[a>>s*8&15];return e}function F(a){let e=a.length,s=new Array(e);for(let r=0;r<e;r++)s[r]=j(a[r]);return s.join("")}var x=F;function L(a,e){return a+e&4294967295}var m=L;function I(a,e,s,r,n){let t=n||m;return e=t(t(e,a),t(s,r)),e}function H(a,e,s,r){var t=(r||m)(a<<e|a>>>32-e,s);return t}function v(a,e,s,r,n,t,i){return e=I(a,e,r,t,i),H(e,n,s,i)}function W(a,e,s,r,n,t,i,o){return v(s&r|~s&n,e,s,t,i,o,a)}function T(a,e,s,r,n,t,i,o){return v(s&n|r&~n,e,s,t,i,o,a)}function R(a,e,s,r,n,t,i,o){return v(s^r^n,e,s,t,i,o,a)}function E(a,e,s,r,n,t,i,o){return v(r^(s|~n),e,s,t,i,o,a)}function _(a,e,s){typeof s>"u"&&(s=m);let r=a[0],n=a[1],t=a[2],i=a[3],o=W.bind(null,s);r=o(r,n,t,i,e[0],7,-680876936),i=o(i,r,n,t,e[1],12,-389564586),t=o(t,i,r,n,e[2],17,606105819),n=o(n,t,i,r,e[3],22,-1044525330),r=o(r,n,t,i,e[4],7,-176418897),i=o(i,r,n,t,e[5],12,1200080426),t=o(t,i,r,n,e[6],17,-1473231341),n=o(n,t,i,r,e[7],22,-45705983),r=o(r,n,t,i,e[8],7,1770035416),i=o(i,r,n,t,e[9],12,-1958414417),t=o(t,i,r,n,e[10],17,-42063),n=o(n,t,i,r,e[11],22,-1990404162),r=o(r,n,t,i,e[12],7,1804603682),i=o(i,r,n,t,e[13],12,-40341101),t=o(t,i,r,n,e[14],17,-1502002290),n=o(n,t,i,r,e[15],22,1236535329);let c=T.bind(null,s);r=c(r,n,t,i,e[1],5,-165796510),i=c(i,r,n,t,e[6],9,-1069501632),t=c(t,i,r,n,e[11],14,643717713),n=c(n,t,i,r,e[0],20,-373897302),r=c(r,n,t,i,e[5],5,-701558691),i=c(i,r,n,t,e[10],9,38016083),t=c(t,i,r,n,e[15],14,-660478335),n=c(n,t,i,r,e[4],20,-405537848),r=c(r,n,t,i,e[9],5,568446438),i=c(i,r,n,t,e[14],9,-1019803690),t=c(t,i,r,n,e[3],14,-187363961),n=c(n,t,i,r,e[8],20,1163531501),r=c(r,n,t,i,e[13],5,-1444681467),i=c(i,r,n,t,e[2],9,-51403784),t=c(t,i,r,n,e[7],14,1735328473),n=c(n,t,i,r,e[12],20,-1926607734);let f=R.bind(null,s);r=f(r,n,t,i,e[5],4,-378558),i=f(i,r,n,t,e[8],11,-2022574463),t=f(t,i,r,n,e[11],16,1839030562),n=f(n,t,i,r,e[14],23,-35309556),r=f(r,n,t,i,e[1],4,-1530992060),i=f(i,r,n,t,e[4],11,1272893353),t=f(t,i,r,n,e[7],16,-155497632),n=f(n,t,i,r,e[10],23,-1094730640),r=f(r,n,t,i,e[13],4,681279174),i=f(i,r,n,t,e[0],11,-358537222),t=f(t,i,r,n,e[3],16,-722521979),n=f(n,t,i,r,e[6],23,76029189),r=f(r,n,t,i,e[9],4,-640364487),i=f(i,r,n,t,e[12],11,-421815835),t=f(t,i,r,n,e[15],16,530742520),n=f(n,t,i,r,e[2],23,-995338651);let u=E.bind(null,s);r=u(r,n,t,i,e[0],6,-198630844),i=u(i,r,n,t,e[7],10,1126891415),t=u(t,i,r,n,e[14],15,-1416354905),n=u(n,t,i,r,e[5],21,-57434055),r=u(r,n,t,i,e[12],6,1700485571),i=u(i,r,n,t,e[3],10,-1894986606),t=u(t,i,r,n,e[10],15,-1051523),n=u(n,t,i,r,e[1],21,-2054922799),r=u(r,n,t,i,e[8],6,1873313359),i=u(i,r,n,t,e[15],10,-30611744),t=u(t,i,r,n,e[6],15,-1560198380),n=u(n,t,i,r,e[13],21,1309151649),r=u(r,n,t,i,e[4],6,-145523070),i=u(i,r,n,t,e[11],10,-1120210379),t=u(t,i,r,n,e[2],15,718787259),n=u(n,t,i,r,e[9],21,-343485551),a[0]=s(r,a[0]),a[1]=s(n,a[1]),a[2]=s(t,a[2]),a[3]=s(i,a[3]);}var l=_;function G(a){let e=[];for(let s=0;s<a.length;s++){let r=a.charCodeAt(s);if(r>=55296&&r<=56319&&s+1<a.length){let n=a.charCodeAt(s+1);n>=56320&&n<=57343&&(r=(r-55296<<10)+(n-56320)+65536,s++);}r<=127?e.push(r):r<=2047?(e.push(192|r>>6),e.push(128|r&63)):r<=65535?(e.push(224|r>>12),e.push(128|r>>6&63),e.push(128|r&63)):(e.push(240|r>>18),e.push(128|r>>12&63),e.push(128|r>>6&63),e.push(128|r&63));}return e}function $(a){let e=[];for(let s=0;s<16;s++)e[s]=a[s*4]+(a[s*4+1]<<8)+(a[s*4+2]<<16)+(a[s*4+3]<<24);return e}function K(a,e){let s=G(a),r=s.length,n=[1732584193,-271733879,-1732584194,271733878],t;for(t=64;t<=r;t+=64){let f=s.slice(t-64,t);l(n,$(f),e);}let i=s.slice(t-64),o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=i.length;for(t=0;t<c;t++)o[t>>2]|=i[t]<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(l(n,o,e),t=16;t--;)o[t]=0;return o[14]=r*8,l(n,o,e),n}var N=K;function y(a){return x(N(a,m))}var g=class{constructor(){this.name="webcrypto";this.version="1.0.0";}static isAvailable(){return typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function"}async hash(e){return y(e)}async hashBinary(e){let s=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return y(s)}update(e){throw new Error("Web Crypto API does not support streaming updates")}digest(e){throw new Error("Web Crypto API does not support streaming")}reset(){}};var w=class{constructor(){this.name="nodecrypto";this.version="1.0.0";}static isAvailable(){try{return typeof U("crypto").createHash=="function"}catch{return false}}hash(e){return U("crypto").createHash("md5").update(e).digest("hex")}async hashBinary(e){let s=U("crypto"),r=e instanceof Uint8Array?e:new Uint8Array(e);return s.createHash("md5").update(r).digest("hex")}update(e){}digest(e){throw new Error("Node crypto streaming not implemented")}reset(){}};var A=class{constructor(){this.name="ie11";this.version="1.0.0";}static isAvailable(){if(typeof window>"u")return false;let e=window;return typeof e.msCrypto<"u"&&typeof e.msCrypto.subtle<"u"&&typeof e.msCrypto.subtle.digest=="function"}async hash(e){let r=new TextEncoder().encode(e);return await this.hashBinary(r)}async hashBinary(e){let s=window,r=e instanceof Uint8Array?e.buffer:e,n=await s.msCrypto.subtle.digest("MD5",r);return this.bufferToHex(n)}bufferToHex(e){return Array.from(new Uint8Array(e)).map(s=>s.toString(16).padStart(2,"0")).join("")}update(e){throw new Error("msCrypto does not support streaming updates")}digest(e){throw new Error("msCrypto does not support streaming")}reset(){}};var P=class{constructor(){this.name="purejs";this.version="0.1.0";this.state={data:"",finished:false};}hash(e){return y(e)}async hashBinary(e){let s=e instanceof ArrayBuffer?new TextDecoder().decode(e):new TextDecoder().decode(e);return y(s)}update(e){this.state.finished&&(this.state={data:"",finished:false}),e instanceof ArrayBuffer?this.state.data+=new TextDecoder().decode(e):e instanceof Uint8Array?this.state.data+=new TextDecoder().decode(e):this.state.data+=e;}digest(e){let s=y(this.state.data);return this.state.finished=true,e==="buffer"?this.hexToBuffer(s):s}reset(){this.state={data:"",finished:false};}static isAvailable(){return true}hexToBuffer(e){let s=[];for(let r=0;r<e.length;r+=2)s.push(parseInt(e.substring(r,r+2),16));return new Uint8Array(s)}};var B=class a extends Transform{constructor(s){super({readableObjectMode:false,writableObjectMode:false});this.initialMD5State=[1732584193,-271733879,-1732584194,271733878];this.bufferCapacity=64;this.buffer=new Uint8Array(this.bufferCapacity);this.add32=s?.add32||m,this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer};}_transform(s,r,n){try{let t=s,i=t.length;if(i===0){n();return}if(this.state.bufferLength>0){let f=this.state.bufferLength,u=64-f,b=Math.min(i,u);for(let d=0;d<b;d++)this.buffer[f+d]=t[d];if(this.state.bufferLength+=b,this.state.bufferLength===64&&this._processBufferBlock(),b===i){n();return}let p=i-b;for(let d=0;d<p;d++)t[d]=t[b+d];let h=Buffer.alloc(p);for(let d=0;d<p;d++)h[d]=t[d];t=h;}let o=Math.floor(t.length/64);for(let f=0;f<o;f++){let u=f*64,b=[];for(let p=0;p<16;p++){let h=u+p*4;b[p]=t[h]+(t[h+1]<<8)+(t[h+2]<<16)+(t[h+3]<<24);}l(this.state.state,b,this.add32),this.state.bytesProcessed+=64;}let c=t.length%64;if(c>0){this.buffer.length<c&&(this.buffer=new Uint8Array(c),this.state.buffer=this.buffer);for(let f=0;f<c;f++)this.buffer[f]=t[o*64+f];this.state.bufferLength=c;}n();}catch(t){n(t);}}_processBufferBlock(){let s=this.state.buffer,r=[];for(let n=0;n<16;n++){let t=n*4;r[n]=s[t]+(s[t+1]<<8)+(s[t+2]<<16)+(s[t+3]<<24);}l(this.state.state,r,this.add32),this.state.bytesProcessed+=64,this.state.bufferLength=0;}_flush(s){try{let{state:r,bufferLength:n,buffer:t}=this.state,i=new Array(16).fill(0);for(let c=0;c<n;c++)i[c>>2]|=(t[c]&255)<<(c%4<<3);if(i[n>>2]|=128<<(n%4<<3),n>55){l(r,i,this.add32);for(let c=0;c<16;c++)i[c]=0;}i[14]=(this.state.bytesProcessed+n)*8,i[15]=0,l(r,i,this.add32);let o=x(r);this.emit("md5",{digest:o,bytesProcessed:this.state.bytesProcessed+n}),s();}catch(r){s(r);}}getCurrentState(){return {state:[...this.state.state],bytesProcessed:this.state.bytesProcessed+this.state.bufferLength}}getBytesProcessed(){return this.state.bytesProcessed+this.state.bufferLength}reset(){this.state={state:[...this.initialMD5State],bytesProcessed:0,bufferLength:0,buffer:this.buffer},this.buffer=new Uint8Array(this.bufferCapacity),this.state.buffer=this.buffer,this.state.bufferLength=0;}static fromStream(s,r){let n=new a(r),t=z.call(n,s);return {stream:n,result:t}}};async function z(a){return new Promise((e,s)=>{let r=[];a.pipe(this).on("md5",n=>{r.push(n);}).on("error",s).on("finish",()=>{e(r[0]);});})}var D=class{constructor(){this.name="stream";this.version="0.1.0";this.state=null;}initNodeStream(e){this.state={stream:e,type:"node"};}initWhatWGStream(e){this.state={stream:e,type:"whatwg"};}async hash(e){let s=new B;return (await new Promise((n,t)=>{s.on("md5",i=>n(i)).on("error",t).end(e);})).digest}async hashBinary(e){let s=new B,r;return e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),(await new Promise((t,i)=>{s.on("md5",o=>t(o)).on("error",i).end(r);})).digest}update(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let s=this.state.stream,r;typeof e=="string"||e instanceof Uint8Array?r=Buffer.from(e):e instanceof ArrayBuffer?r=Buffer.from(new Uint8Array(e)):r=Buffer.from(e),s.write(r);}}digest(e){if(!this.state)throw new Error("Stream backend not initialized. Call initNodeStream() or initWhatWGStream() first.");if(this.state.type==="node"){let s=this.state.stream;return s.end(),new Promise((r,n)=>{s.on("md5",t=>{if(e==="buffer"){let i=t.digest,o=[];for(let c=0;c<i.length;c+=2)o.push(parseInt(i.substring(c,c+2),16));r(Buffer.from(o));}else r(t.digest);}).on("error",n);})}else return this.state.stream.getResult().then(r=>r.digest)}reset(){this.state&&this.state.type==="node"&&this.state.stream.reset();}static isAvailable(){return true}};var J=(n=>(n.BROWSER="browser",n.NODE="node",n.WEBWORKER="webworker",n.UNKNOWN="unknown",n))(J||{});function Ne(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof importScripts<"u"?"webworker":typeof window<"u"&&window.document?"browser":"unknown"}function Oe(){return typeof process<"u"&&process.versions!==void 0&&"node"in process.versions}function je(){return typeof window<"u"&&typeof document<"u"}function Fe(){return typeof importScripts<"u"}async function Y(a){switch(a){case "webcrypto":let e=g.isAvailable();return {backend:"webcrypto",available:e,reason:e?void 0:"Web Crypto API not available"};case "nodecrypto":let s=w.isAvailable();return {backend:"nodecrypto",available:s,reason:s?void 0:"Node.js crypto not available"};case "ie11":let r=A.isAvailable();return {backend:"ie11",available:r,reason:r?void 0:"IE11 msCrypto not available"};case "purejs":return {backend:"purejs",available:true,reason:"Always available"};case "stream":let n=typeof process<"u"&&process.versions&&"node"in process.versions,t=typeof window<"u";return {backend:"stream",available:n||t,reason:n||t?void 0:"Streams not available"};default:return {backend:a||"unknown",available:false,reason:"Unknown backend"}}}async function Q(){let a=["webcrypto","nodecrypto","ie11","purejs","stream"],e=[];for(let s of a){let{available:r}=await Y(s);r&&e.push(s);}return e}var V=[{name:"nodecrypto",priority:1,description:"Node.js native crypto (fastest)"},{name:"webcrypto",priority:2,description:"Web Crypto API (fast, hardware accelerated)"},{name:"ie11",priority:3,description:"IE11 msCrypto (legacy)"},{name:"stream",priority:4,description:"Streaming backend (for large files and memory efficiency)"},{name:"purejs",priority:5,description:"Pure JavaScript (always available, slower)"}];function X(a){let e=[...V].sort((s,r)=>s.priority-r.priority);for(let{name:s}of e)if(a.includes(s))return s;return "purejs"}var M=class a{constructor(){}static getInstance(){return a.instance||(a.instance=new a),a.instance}async createBackendByName(e){switch(e){case "nodecrypto":return new w;case "webcrypto":return new g;case "ie11":return new A;case "stream":return new D;default:return new P}}async createBackend(e){let s=e||X(await Q());return this.createBackendByName(s)}},Le=M.getInstance(),S=class{constructor(e=["nodecrypto","webcrypto","stream","ie11","purejs"]){this.detector=M.getInstance(),this.fallbackOrder=e;}async execute(e){let s=[];for(let r of this.fallbackOrder)try{let n=await this.detector.createBackendByName(r),t=await e(n);return {success:!0,backend:r,data:t}}catch(n){if(s.push({backend:r,error:n}),r===this.fallbackOrder[this.fallbackOrder.length-1])return {success:false,backend:r,data:null,errors:s}}return {success:false,backend:"",data:null,errors:s}}async hash(e){return this.execute(async s=>s.hash(e))}async hashBinary(e){return this.execute(async s=>s.hashBinary(e))}async getBestBackend(){let e=await this.getAvailableBackends();return e.length===0?"purejs":e[0]}async getAvailableBackends(){let e=[];for(let s of this.fallbackOrder)try{await this.detector.createBackendByName(s),e.push(s);}catch{}return e}getMetrics(){return {}}},Ie=new S;async function He(a,e={}){let s=new S;if(e.forceBackend)return (await s.detector.createBackendByName(e.forceBackend)).hash(a);if(e.fallback===false)return (await s.detector.createBackend()).hash(a);let r=await s.hash(a);if(r.success)return e.reportFallback&&r.backend!=="nodecrypto"&&r.backend!=="webcrypto"&&console.info(`MD5 used fallback backend: ${r.backend}`),r.data;let n=r.errors?r.errors.map(t=>`${t.backend}: ${t.error.message}`).join(", "):"All backends failed";throw new Error(`MD5 hash failed after all attempts: ${n}`)}var k=class{constructor(){this.metrics={nodecrypto:{success:0,fail:0},webcrypto:{success:0,fail:0},ie11:{success:0,fail:0},stream:{success:0,fail:0},purejs:{success:0,fail:0}};}recordSuccess(e){this.metrics[e]&&this.metrics[e].success++;}recordFail(e){this.metrics[e]&&this.metrics[e].fail++;}getMetrics(){return this.metrics}getSummary(){return `Total operations: ${Object.values(this.metrics).reduce((s,r)=>s+r.success+r.fail,0)}
2
2
  `+Object.entries(this.metrics).map(([,s])=>`${s.success} success, ${s.fail} fail`).join(`
3
- `)}reset(){Object.keys(this.metrics).forEach(e=>{this.metrics[e]={success:0,fail:0};});}},$e=new k;export{V as BACKEND_PRIORITY,M as BackendDetector,S as FallbackManager,k as MetricsCollector,J as RuntimeEnvironment,Y as checkBackendAvailability,Ne as detectEnvironment,He as detector,_e as fallbackManager,Q as getAllAvailableBackends,X as getBestAvailableBackend,Le as isBrowser,Fe as isNode,Ie as isWebWorker,$e as metrics,Ge as robustHash};
3
+ `)}reset(){Object.keys(this.metrics).forEach(e=>{this.metrics[e]={success:0,fail:0};});}},_e=new k;export{V as BACKEND_PRIORITY,M as BackendDetector,S as FallbackManager,k as MetricsCollector,J as RuntimeEnvironment,Y as checkBackendAvailability,Ne as detectEnvironment,Le as detector,Ie as fallbackManager,Q as getAllAvailableBackends,X as getBestAvailableBackend,je as isBrowser,Oe as isNode,Fe as isWebWorker,_e as metrics,He as robustHash};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pure-md5",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "A lightweight JavaScript function for hashing messages by the MD5 algorithm",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",