mirror of
https://github.com/emn178/js-md5.git
synced 2026-11-18 16:08:52 +08:00
### Fixed
- Incorrect hash for `DataView` input. - Throws `ArrayBuffer is not defined` in browsers without `ArrayBuffer`. ### Changed - Multi-byte typed arrays such as `Uint16Array`, `Uint32Array` and `Float32Array` are now hashed by their underlying bytes, the same as Node.js `crypto` and Web Crypto. Previously each element was treated as one byte. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c2a7870840
commit
66db5dbd99
@@ -57,4 +57,14 @@ expect(browserLite.base64).to.be(undefined);
|
||||
expect(browserLite.buffer).to.be(undefined);
|
||||
expect(browserLite.hmac).to.be(undefined);
|
||||
|
||||
// legacy builds load in browsers without ArrayBuffer
|
||||
['build/md5.js', 'build/md5.min.js'].forEach(function (file) {
|
||||
var context = vm.createContext({});
|
||||
vm.runInContext('var window = this; delete ArrayBuffer; delete Uint8Array; delete Uint32Array; delete DataView;', context);
|
||||
vm.runInContext(fs.readFileSync(file, 'utf8'), context);
|
||||
expect(context.md5('abc')).to.be(EXPECTED_MD5);
|
||||
expect(context.md5.create().update('a').update([98, 99]).hex()).to.be(EXPECTED_MD5);
|
||||
expect(context.md5.hmac('key', 'abc')).to.be(EXPECTED_HMAC);
|
||||
});
|
||||
|
||||
console.log('Build variants: PASS');
|
||||
|
||||
Reference in New Issue
Block a user