tinyhmacmd5 0.5.0-es2026 → 0.5.0

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/README.md CHANGED
@@ -4,7 +4,7 @@ English | [中文](README-zh.md)
4
4
 
5
5
  A tiny and reliable HMAC-MD5 implementation for JavaScript:
6
6
 
7
- [`browser.min.js`](browser.min.js) is only **947 bytes**.
7
+ [`browser.min.js`](browser.min.js) is only **979 bytes**.
8
8
 
9
9
  - **Input type**: `string` (UTF‑8), `Uint8Array` or `Uint8ClampedArray`
10
10
  - **Output type**: hex `string` or bytes `Uint8Array`
@@ -62,7 +62,7 @@ As a result, the final size is not the smallest theoretically achievable.
62
62
  ### npm
63
63
 
64
64
  ```
65
- npm i tinyhmacmd5@es2026
65
+ npm i tinyhmacmd5
66
66
  ```
67
67
 
68
68
  ```js
@@ -78,7 +78,7 @@ You can also use other package managers (e.g. `pnpm` or `yarn`) in place of `npm
78
78
  See https://www.jsdelivr.com/package/npm/tinyhmacmd5
79
79
 
80
80
  ```html
81
- <script src="https://cdn.jsdelivr.net/npm/tinyhmacmd5@es2026"></script>
81
+ <script src="https://cdn.jsdelivr.net/npm/tinyhmacmd5"></script>
82
82
  ```
83
83
 
84
84
  It will define the `md5` function using `var`.
@@ -86,7 +86,7 @@ It will define the `md5` function using `var`.
86
86
  ### UNPKG
87
87
 
88
88
  ```html
89
- <script src="https://unpkg.com/tinyhmacmd5@es2026"></script>
89
+ <script src="https://unpkg.com/tinyhmacmd5"></script>
90
90
  ```
91
91
 
92
92
  It will define the `md5` function using `var`.
@@ -173,22 +173,22 @@ md5(data)
173
173
 
174
174
  ## Runtime Environment
175
175
 
176
- Environments that support [`Uint8Array.prototype.toHex()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/toHex) :
176
+ Environments that support [Exponentiation (`**`)](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Exponentiation) and [`TextEncoder`](https://developer.mozilla.org/docs/Web/API/TextEncoder) :
177
177
 
178
178
  - Desktop
179
- - Chrome ≥ 140 (2025-09-02)
180
- - Edge ≥ 140 (2025-09-05)
181
- - Firefox ≥ 133 (2024-11-26)
182
- - Opera ≥ 124 (2025-11-13)
183
- - Safari ≥ 18.2 (2024-12-11)
179
+ - Chrome ≥ 52 (2016-07-20)
180
+ - Edge ≥ 79 (2020-01-15)
181
+ - Firefox ≥ 52 (2017-03-07)
182
+ - Opera ≥ 39 (2016-08-02)
183
+ - Safari ≥ 10.1 (2017-03-27)
184
184
  - Mobile
185
- - Chrome Android ≥ 140 (2025-09-02)
186
- - Firefox for Android ≥ 133 (2024-11-26)
187
- - Opera Android ≥ 92 (2025-10-08)
188
- - Safari on iOS ≥ 18.2 (2024-12-11)
189
- - Samsung Browser ×
190
- - WebView Android ≥ 140 (2025-09-02)
191
- - WebView on iOS ≥ 18.2 (2024-12-11)
185
+ - Chrome Android ≥ 52 (2016-07-27)
186
+ - Firefox for Android ≥ 52 (2017-03-07)
187
+ - Opera Android ≥ 41 (2016-10-25)
188
+ - Safari on iOS ≥ 10.3 (2017-03-27)
189
+ - Samsung Browser ≥ 6 (2017-08-23)
190
+ - WebView Android ≥ 51 (2016-06-08)
191
+ - WebView on iOS ≥ 10.3 (2017-03-27)
192
192
 
193
193
  Not recommended for use in environments that support `node:crypto`, as `node:crypto` already provides HMAC-MD5.
194
194
 
package/browser.min.js CHANGED
@@ -1 +1 @@
1
- {let e=Int32Array,r=Uint8Array,n=new e(64).map((e,r)=>2**32*Math.abs(Math.sin(r+1))),t=1&new r(n.buffer)[3],f=(r,t,f=0,o,a=1732584193,w=271733878,l,u,h=r.length,s=e.of(a,~w,~a,w),d=new e(s))=>{for(r[h-1]=t/2**29,r[(t-t%4)/4]|=128<<(r[h-2]=t<<3);f<h;f+=16){for(t=o=0;t<16;t+=4)for(;o<4*t+16;)s[u&=3]=((w=s[u]+n[o]+(a=s[3&++u],w=s[3&++u],l=s[3&++u],w^(t>4?t>8?a|~l:a^l:t?l&(a^w):~a&(w^l)))+r[f+(o*(29521>>t)+(1296>>t)&15)])<<(l="',16%).4$+07&*/5".charCodeAt(3&o++|t))|w>>>32-l)+a;for(;u;)d[--u]=s[u]+=d[u]}return s},o=(n,f,o=("string"==typeof n?n=(new TextEncoder).encode(n):n).length,a=new e(f+18+(o-(o+8&63))/4),w=t&&new r(a.buffer,4*f).set(n))=>{for(;w<o;3&++w||f++)a[f]|=n[w]<<8*w;return[a,o]};var md5=(n,t,a)=>{var w=16,l=null!=t,[u,h]=o(n,l*w),s=new r(w);if(l){let[r,n]=o(t,0),a=new e(32);for(n>64&&(r=f(r,n)),n=w;n;)a[--n]=1785358954^(u[n]=909522486^r[n]);a.set(f(u,64+h),w),u=a,h=80}for(u=f(u,h);w;)s[--w]=u[w>>2]>>8*w;return a?s:s.toHex()}}
1
+ {let e=Int32Array,r=Uint8Array,n=new e(64).map((e,r)=>2**32*Math.abs(Math.sin(r+1))),t=1&new r(n.buffer)[3],f=(r,t,f=0,o,a=1732584193,w=271733878,l,u,h=r.length,i=e.of(a,~w,~a,w),s=new e(i))=>{for(r[h-1]=t/2**29,r[(t-t%4)/4]|=128<<(r[h-2]=t<<3);f<h;f+=16){for(t=o=0;t<16;t+=4)for(;o<4*t+16;)i[u&=3]=((w=i[u]+n[o]+(a=i[3&++u],w=i[3&++u],l=i[3&++u],w^(t>4?t>8?a|~l:a^l:t?l&(a^w):~a&(w^l)))+r[f+(o*(29521>>t)+(1296>>t)&15)])<<(l="',16%).4$+07&*/5".charCodeAt(3&o++|t))|w>>>32-l)+a;for(;u;)s[--u]=i[u]+=s[u]}return i},o=(n,f,o=("string"==typeof n?n=(new TextEncoder).encode(n):n).length,a=new e(f+18+(o-(o+8&63))/4),w=t&&new r(a.buffer,4*f).set(n))=>{for(;w<o;3&++w||f++)a[f]|=n[w]<<8*w;return[a,o]};var md5=(n,t,a)=>{var w=16,l=null!=t,[u,h]=o(n,l*w),i=a?new r(w):"";if(l){let[r,n]=o(t,0),a=new e(32);for(n>64&&(r=f(r,n)),n=w;n;)a[--n]=1785358954^(u[n]=909522486^r[n]);a.set(f(u,64+h),w),u=a,h=80}for(u=f(u,h);w;a?i[w]=h:i=(h>>4&&"")+h.toString(16)+i)h=u[--w>>2]>>8*w&255;return i}}
package/main.js CHANGED
@@ -125,7 +125,9 @@ let md5 = (data, key, raw) => {
125
125
  var i = 16
126
126
  , hasKey = key != null
127
127
  , [bdata, temp] = inputToWords(data, /**@type {*}*/(hasKey) * i)
128
- , out = new $Uint8Array(i)
128
+
129
+ /** @type {*} */
130
+ var out = raw ? new $Uint8Array(i) : ''
129
131
 
130
132
  if (hasKey) {
131
133
  // HMAC
@@ -146,11 +148,15 @@ let md5 = (data, key, raw) => {
146
148
  bdata = wordsMD5(bdata, temp)
147
149
 
148
150
  // words to bytes or hex
149
- for (; i;) {
150
- out[--i] = bdata[i >> 2] >> i * 8
151
+ for (; i;
152
+ raw
153
+ ? out[i] = temp
154
+ : out = (temp >> 4 && '') + temp.toString(16) + out
155
+ ) {
156
+ temp = bdata[--i >> 2] >> i * 8 & 0xff
151
157
  }
152
158
 
153
- return raw ? out : out.toHex()
159
+ return out
154
160
  }
155
161
 
156
162
  export default md5
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tinyhmacmd5",
3
- "version": "0.5.0-es2026",
4
- "description": "A tiny and reliable HMAC-MD5 implementation for JavaScript: browser.min.js is only 947 bytes.",
3
+ "version": "0.5.0",
4
+ "description": "A tiny and reliable HMAC-MD5 implementation for JavaScript: browser.min.js is only 979 bytes.",
5
5
  "author": "bddjr",
6
6
  "license": "Unlicense",
7
7
  "type": "module",
@@ -63,7 +63,7 @@
63
63
  "typescript": "^7.0.2"
64
64
  },
65
65
  "scripts": {
66
- "build": "tsc && node scripts/build.mjs && es-check es2026 --module --checkFeatures main.js browser.min.js",
66
+ "build": "tsc && node scripts/build.mjs && es-check es2016 --module --checkFeatures main.js browser.min.js",
67
67
  "build:unchanged": "node scripts/build-unchanged.mjs",
68
68
  "test": "pnpm build && pnpm test:only",
69
69
  "test:only": "node scripts/test.mjs && node scripts/test-513MiB.mjs",