mirror of
https://github.com/emn178/js-md5.git
synced 2026-08-13 04:51:44 +08:00
## v0.8.0 / 2023-09-27
### Added - TypeScript interfaces. - HMAC feature. ### Fixed - deprecated `new Buffer`, replace with `Buffer.from`. - dependencies and security issues. - don't modify global Array and ArrayBuffer prototypes. - refactor: simplify formatMessage internal logic. ### Changed - remove `eval` and use `require` directly. - throw error by Error oject. - throw error if update after finalize - use unsigned right shift.
This commit is contained in:
+12
-3
@@ -96,8 +96,8 @@
|
||||
|
||||
if (typeof BUFFER === 'boolean' && BUFFER) {
|
||||
testCases['Buffer'] = {
|
||||
'd41d8cd98f00b204e9800998ecf8427e': new Buffer(0),
|
||||
'9e107d9d372bb6826bd81d3542a419d6': new Buffer(new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103]))
|
||||
'd41d8cd98f00b204e9800998ecf8427e': Buffer.from([]),
|
||||
'9e107d9d372bb6826bd81d3542a419d6': Buffer.from(new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103]))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,6 @@
|
||||
call: function (message) {
|
||||
var hash = md5.update(message);
|
||||
hash.hex();
|
||||
hash.update(message);
|
||||
return hash.hex();
|
||||
}
|
||||
}
|
||||
@@ -242,6 +241,16 @@
|
||||
});
|
||||
});
|
||||
|
||||
context('when update after finalize', function () {
|
||||
it('should throw error', function () {
|
||||
expect(function () {
|
||||
var hash = md5.update('any');
|
||||
hash.hex();
|
||||
hash.update('any');
|
||||
}).to.throwError(/finalize already called/);
|
||||
});
|
||||
});
|
||||
|
||||
context('when large size', function () {
|
||||
var hash = md5.create();
|
||||
hash.bytes = 4294967295;
|
||||
|
||||
Reference in New Issue
Block a user