tinyhmacmd5 0.5.1-es2026 → 0.5.1
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 +17 -17
- package/browser.min.js +1 -1
- package/main.js +10 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ English | [中文](README-zh.md)
|
|
|
4
4
|
|
|
5
5
|
A tiny, efficient and reliable HMAC-MD5 implementation for JavaScript.
|
|
6
6
|
|
|
7
|
-
[`browser.min.js`](browser.min.js) is only **
|
|
7
|
+
[`browser.min.js`](browser.min.js) is only **955 bytes**.
|
|
8
8
|
|
|
9
9
|
- **Input type**: `string` (UTF‑8), `Uint8Array` or `Uint8ClampedArray`
|
|
10
10
|
- **Output type**: hex `string` or bytes `Uint8Array`
|
|
@@ -60,7 +60,7 @@ As a result, the final size is not the smallest theoretically achievable.
|
|
|
60
60
|
### npm
|
|
61
61
|
|
|
62
62
|
```
|
|
63
|
-
npm i tinyhmacmd5
|
|
63
|
+
npm i tinyhmacmd5
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
```js
|
|
@@ -76,7 +76,7 @@ You can also use other package managers (e.g. `pnpm` or `yarn`) in place of `npm
|
|
|
76
76
|
See https://www.jsdelivr.com/package/npm/tinyhmacmd5
|
|
77
77
|
|
|
78
78
|
```html
|
|
79
|
-
<script src="https://cdn.jsdelivr.net/npm/tinyhmacmd5
|
|
79
|
+
<script src="https://cdn.jsdelivr.net/npm/tinyhmacmd5"></script>
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
It will define the `md5` function using `var`.
|
|
@@ -84,7 +84,7 @@ It will define the `md5` function using `var`.
|
|
|
84
84
|
### UNPKG
|
|
85
85
|
|
|
86
86
|
```html
|
|
87
|
-
<script src="https://unpkg.com/tinyhmacmd5
|
|
87
|
+
<script src="https://unpkg.com/tinyhmacmd5"></script>
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
It will define the `md5` function using `var`.
|
|
@@ -177,22 +177,22 @@ md5(data)
|
|
|
177
177
|
|
|
178
178
|
## Runtime Environment
|
|
179
179
|
|
|
180
|
-
Environments that support [
|
|
180
|
+
Environments that support [Exponentiation (`**`)](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Exponentiation) and [`TextEncoder`](https://developer.mozilla.org/docs/Web/API/TextEncoder) :
|
|
181
181
|
|
|
182
182
|
- Desktop
|
|
183
|
-
- Chrome ≥
|
|
184
|
-
- Edge ≥
|
|
185
|
-
- Firefox ≥
|
|
186
|
-
- Opera ≥
|
|
187
|
-
- Safari ≥
|
|
183
|
+
- Chrome ≥ 52 (2016-07-20)
|
|
184
|
+
- Edge ≥ 79 (2020-01-15)
|
|
185
|
+
- Firefox ≥ 52 (2017-03-07)
|
|
186
|
+
- Opera ≥ 39 (2016-08-02)
|
|
187
|
+
- Safari ≥ 10.1 (2017-03-27)
|
|
188
188
|
- Mobile
|
|
189
|
-
- Chrome Android ≥
|
|
190
|
-
- Firefox for Android ≥
|
|
191
|
-
- Opera Android ≥
|
|
192
|
-
- Safari on iOS ≥
|
|
193
|
-
- Samsung Browser
|
|
194
|
-
- WebView Android ≥
|
|
195
|
-
- WebView on iOS ≥
|
|
189
|
+
- Chrome Android ≥ 52 (2016-07-27)
|
|
190
|
+
- Firefox for Android ≥ 52 (2017-03-07)
|
|
191
|
+
- Opera Android ≥ 41 (2016-10-25)
|
|
192
|
+
- Safari on iOS ≥ 10.3 (2017-03-27)
|
|
193
|
+
- Samsung Browser ≥ 6 (2017-08-23)
|
|
194
|
+
- WebView Android ≥ 51 (2016-06-08)
|
|
195
|
+
- WebView on iOS ≥ 10.3 (2017-03-27)
|
|
196
196
|
|
|
197
197
|
Not recommended for use in environments that support `node:crypto`, as `node:crypto` already provides HMAC-MD5.
|
|
198
198
|
|
package/browser.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{let e=Int32Array,r=Uint8Array,n=new e(64).map((e,r)=>2**32*Math.sin(++r%Math.PI)),t=(r,t,f=0,o=1732584193,a=271733878,l=e.of(o,~a,~o,a),w=r.length)=>{for(r[w-1]=t/2**29,r[(t-t%4)/4]|=128<<(r[w-2]=t<<3);f<w;f+=16){let{0:e,1:w,2:u,3:h}=l;for(t=o=0;t<16;t+=4)for(;o<4*t+16;w=0|((e+=n[o]+(u^(t>4?t>8?w|~h:w^h:t?h&(w^u):~w&(u^h)))+r[f+(o++*(29521>>t)+(1296>>t)&15)])<<a|e>>>32-a)+(e=h,h=u,u=w))a="',16%).4$+07&*/5".charCodeAt(3&o|t);l[0]+=e,l[1]+=w,l[2]+=u,l[3]+=h}return l},f=(t,f,o=("string"==typeof t?t=(new TextEncoder).encode(t):t).length,a=new e(f+18+(o-(o+8&63))/4),l=1&new r(n.buffer)[3]&&new r(a.buffer,4*f).set(t))=>{for(;l<o;3&++l||f++)a[f]|=t[l]<<8*l;return[a,o]};var md5=(n,o,a)=>{var l=16,w=null!=o,[u,h]=f(n,w*l),
|
|
1
|
+
{let e=Int32Array,r=Uint8Array,n=new e(64).map((e,r)=>2**32*Math.sin(++r%Math.PI)),t=(r,t,f=0,o=1732584193,a=271733878,l=e.of(o,~a,~o,a),w=r.length)=>{for(r[w-1]=t/2**29,r[(t-t%4)/4]|=128<<(r[w-2]=t<<3);f<w;f+=16){let{0:e,1:w,2:u,3:h}=l;for(t=o=0;t<16;t+=4)for(;o<4*t+16;w=0|((e+=n[o]+(u^(t>4?t>8?w|~h:w^h:t?h&(w^u):~w&(u^h)))+r[f+(o++*(29521>>t)+(1296>>t)&15)])<<a|e>>>32-a)+(e=h,h=u,u=w))a="',16%).4$+07&*/5".charCodeAt(3&o|t);l[0]+=e,l[1]+=w,l[2]+=u,l[3]+=h}return l},f=(t,f,o=("string"==typeof t?t=(new TextEncoder).encode(t):t).length,a=new e(f+18+(o-(o+8&63))/4),l=1&new r(n.buffer)[3]&&new r(a.buffer,4*f).set(t))=>{for(;l<o;3&++l||f++)a[f]|=t[l]<<8*l;return[a,o]};var md5=(n,o,a)=>{var l=16,w=null!=o,[u,h]=f(n,w*l),i=a?new r(l):"";if(w){let[r,n]=f(o,0),a=new e(32);for(n>64&&(r=t(r,n)),n=l;n;)a[--n]=1785358954^(u[n]=909522486^r[n]);a.set(t(u,64+h),l),u=a,h=80}for(u=t(u,h);l;a?i[l]=h:i=(h>>4&&"")+h.toString(16)+i)h=u[--l>>2]>>8*l&255;return i}}
|
package/main.js
CHANGED
|
@@ -119,7 +119,9 @@ let md5 = (data, key, raw) => {
|
|
|
119
119
|
var i = 16
|
|
120
120
|
, hasKey = key != null
|
|
121
121
|
, [bdata, temp] = inputToWords(data, /**@type {*}*/(hasKey) * i)
|
|
122
|
-
|
|
122
|
+
|
|
123
|
+
/** @type {*} */
|
|
124
|
+
var out = raw ? new $Uint8Array(i) : ''
|
|
123
125
|
|
|
124
126
|
if (hasKey) {
|
|
125
127
|
// HMAC
|
|
@@ -140,11 +142,15 @@ let md5 = (data, key, raw) => {
|
|
|
140
142
|
bdata = wordsMD5(bdata, temp)
|
|
141
143
|
|
|
142
144
|
// words to bytes or hex
|
|
143
|
-
for (; i;
|
|
144
|
-
|
|
145
|
+
for (; i;
|
|
146
|
+
raw
|
|
147
|
+
? out[i] = temp
|
|
148
|
+
: out = (temp >> 4 && '') + temp.toString(16) + out
|
|
149
|
+
) {
|
|
150
|
+
temp = bdata[--i >> 2] >> i * 8 & 0xff
|
|
145
151
|
}
|
|
146
152
|
|
|
147
|
-
return
|
|
153
|
+
return out
|
|
148
154
|
}
|
|
149
155
|
|
|
150
156
|
export default md5
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinyhmacmd5",
|
|
3
|
-
"version": "0.5.1
|
|
4
|
-
"description": "A tiny (
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "A tiny (955 Bytes), efficient and reliable HMAC-MD5 implementation for JavaScript.",
|
|
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
|
|
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",
|