mirror of
https://github.com/emn178/js-sha1.git
synced 2026-11-18 22:58:42 +08:00
### Fixed
- Incorrect hash for `DataView` input, and for `Int8Array` with negative values in browsers. - 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
9e1e7d1397
commit
4ad1b7a3b2
@@ -89,7 +89,7 @@ sha1('中文'); // 7be2d2d20c106eee0836c9bc2b939890a78e8fb3
|
||||
// Unpaired surrogates are encoded as U+FFFD, the same as TextEncoder
|
||||
sha1('\ud800'); // 9bdb77276c1852e1fb067820472812fcf6084024
|
||||
|
||||
// It also supports byte `Array`, `Uint8Array`, `ArrayBuffer`
|
||||
// It also supports byte `Array`, `Uint8Array`, `ArrayBuffer` and other `ArrayBuffer` views (their underlying bytes are hashed)
|
||||
sha1([]); // da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||
sha1(new Uint8Array([])); // da39a3ee5e6b4b0d3255bfef95601890afd80709
|
||||
|
||||
|
||||
Reference in New Issue
Block a user