tinyhmacmd5 0.3.1 → 0.3.2

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
@@ -2,7 +2,7 @@ English | [中文](README-zh.md)
2
2
 
3
3
  # Tiny HMAC MD5
4
4
 
5
- A tiny and reliable HMAC-MD5 implementation for JavaScript: [`browser.min.js`](browser.min.js) is only **985 bytes**.
5
+ A tiny and reliable HMAC-MD5 implementation for JavaScript: [`browser.min.js`](browser.min.js) is only **984 bytes**.
6
6
 
7
7
  - **Input type**: `string` (UTF‑8), `Uint8Array` or `Uint8ClampedArray`
8
8
  - **Output type**: hex `string` or bytes `Uint8Array`
@@ -205,7 +205,7 @@ During the adaptation, I discovered that `blueimp-md5` did not correctly handle
205
205
 
206
206
  I also found that using `Array` to process inputs over 512 MiB could throw a `RangeError`, so I replaced it with `Int32Array`.
207
207
 
208
- I demonstrated in practice that HMAC-MD5 can be implemented in an extremely small footprint (985 bytes) while also improving reliability.
208
+ I demonstrated in practice that HMAC-MD5 can be implemented in an extremely small footprint (984 bytes) while also improving reliability.
209
209
 
210
210
  Maybe not many people care about saving just a few KB, but `tinyhmacmd5` exists precisely to "explore the unknown".
211
211
 
package/browser.min.js CHANGED
@@ -1 +1 @@
1
- /*! npmjs.com/tinyhmacmd5 */{let r=Math,e=r.floor,n=Int32Array,t=new n(64).map((e,n)=>2**32*r.abs(r.sin(n+1))),o=(r,o,f=0,a,l=1732584193,w=271733878,i,d,g=r.length,h=n.of(l,~w,~l,w),s=new n(h))=>{for(r[g-1]=o/2**29,r[e(o/4)]|=128<<(r[g-2]=o<<3);f<g;f+=16){for(o=0;o<16;o+=4)for(a=0;a<16;)h[d&=3]=((w=h[d]+t[4*o|a]+(l=h[3&++d],w=h[3&++d],i=h[3&++d],o?o>4?o>8?w^(l|~i):l^w^i:l&i|w&~i:l&w|~l&i)+r[f+(a*(29521>>o)+(1296>>o)&15)])<<(i="',16%).4$+07&*/5".charCodeAt(3&a++|o))|w>>>64-i)+l;for(;d;)s[--d]=h[d]+=s[d]}return h},f=(r,t,o=("string"==typeof r?r=(new TextEncoder).encode(r):r).length,f=new n(16*e((4*t+o+72)/64)),a=0)=>{for(;a<o;)f[t++]=r[a++]|r[a++]<<8|r[a++]<<16|r[a++]<<24;return[f,o]};var md5=(r,e,t)=>{var a=16,l=null!=e,[w,i]=f(r,l*a),d=t?new Uint8Array(a):"";if(l){let[r,t]=f(e,0),l=new n(32);for(t>64&&(r=o(r,t)),t=a;t;)l[--t]=1785358954^(w[t]=909522486^r[t]);l.set(o(w,64+i),16),w=l,i=80}for(w=o(w,i);a;t?d[a]=i:d=(i>>4&&"")+i.toString(16)+d)i=w[--a>>2]>>8*a&255;return d}}
1
+ /*! npmjs.com/tinyhmacmd5 */{let r=Math,e=r.floor,n=Int32Array,t=new n(64).map((e,n)=>2**32*r.abs(r.sin(n+1))),o=(r,o,f=0,a,l=1732584193,w=271733878,i,d,g=r.length,h=n.of(l,~w,~l,w),s=new n(h))=>{for(r[g-1]=o/2**29,r[e(o/4)]|=128<<(r[g-2]=o<<3);f<g;f+=16){for(o=0;o<16;o+=4)for(a=0;a<16;)h[d&=3]=((w=h[d]+t[4*o|a]+(l=h[3&++d],w=h[3&++d],i=h[3&++d],o?o>4?o>8?w^(l|~i):l^w^i:l&i|w&~i:l&w|~l&i)+r[f+(a*(29521>>o)+(1296>>o)&15)])<<(i="',16%).4$+07&*/5".charCodeAt(3&a++|o))|w>>>64-i)+l;for(;d;)s[--d]=h[d]+=s[d]}return h},f=(r,t,o=("string"==typeof r?r=(new TextEncoder).encode(r):r).length,f=new n(16*e((4*t+o+72)/64)),a=0)=>{for(;a<o;)f[t++]=r[a++]|r[a++]<<8|r[a++]<<16|r[a++]<<24;return[f,o]};var md5=(r,e,t)=>{var a=16,l=null!=e,[w,i]=f(r,l*a),d=t?new Uint8Array(a):"";if(l){let[r,t]=f(e,0),l=new n(32);for(t>64&&(r=o(r,t)),t=a;t;)l[--t]=1785358954^(w[t]=909522486^r[t]);l.set(o(w,64+i),a),w=l,i=80}for(w=o(w,i);a;t?d[a]=i:d=(i>>4&&"")+i.toString(16)+d)i=w[--a>>2]>>8*a&255;return d}}
package/main.js CHANGED
@@ -140,7 +140,7 @@ var md5 = (data, key, raw) => {
140
140
  // (0x36363636 ^ 0x5c5c5c5c) == 0x6a6a6a6a
141
141
  opad[--j] = 0x6a6a6a6a ^ (bdata[j] = 0x36363636 ^ bkey[j])
142
142
  }
143
- opad.set(wordsMD5(bdata, 64 + temp), 16)
143
+ opad.set(wordsMD5(bdata, 64 + temp), i)
144
144
  bdata = opad
145
145
  temp = 80
146
146
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tinyhmacmd5",
3
- "version": "0.3.1",
4
- "description": "A tiny and reliable HMAC-MD5 implementation for JavaScript: browser.min.js is only 985 bytes.",
3
+ "version": "0.3.2",
4
+ "description": "A tiny and reliable HMAC-MD5 implementation for JavaScript: browser.min.js is only 984 bytes.",
5
5
  "author": "bddjr",
6
6
  "license": "MIT",
7
7
  "type": "module",