Skip to content

Commit 2c7cfac

Browse files
authoredFeb 19, 2025··
use hash-wasm to calculate checksum (#103)
1 parent 6e3a276 commit 2c7cfac

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed
 

‎bun.lockb

16 Bytes
Binary file not shown.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@fontsource-variable/inter": "^5.0.18",
1919
"@fontsource-variable/jetbrains-mono": "^5.0.21",
2020
"comlink": "^4.4.1",
21-
"jssha": "^3.3.1",
21+
"hash-wasm": "^4.12.0",
2222
"react": "^18.3.1",
2323
"react-dom": "^18.3.1",
2424
"xz-decompress": "^0.2.1"

‎src/workers/image.worker.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as Comlink from 'comlink'
22

3-
import jsSHA from 'jssha'
3+
import { createSHA256 } from 'hash-wasm'
44
import { XzReadableStream } from 'xz-decompress'
55

66
/**
@@ -133,7 +133,7 @@ const imageWorker = {
133133
}
134134
}
135135

136-
const shaObj = new jsSHA('SHA-256', 'UINT8ARRAY')
136+
const shaObj = await createSHA256()
137137
let complete
138138
try {
139139
let stream = archiveFile.stream()
@@ -166,7 +166,7 @@ const imageWorker = {
166166
throw `Error closing file handle: ${e}`
167167
}
168168

169-
const checksum = shaObj.getHash('HEX')
169+
const checksum = shaObj.digest()
170170
if (checksum !== expectedChecksum) {
171171
throw `Checksum mismatch: got ${checksum}, expected ${expectedChecksum}`
172172
}

0 commit comments

Comments
 (0)
Please sign in to comment.