Initial commit
Some checks failed
CI-integ-test-full / caching-integ-tests (push) Failing after 32s
CI-integ-test-full / other-integ-tests (push) Failing after 29m15s
Update Wrapper checksums file / Update checksums (push) Failing after 3m7s
CI-codeql / Analyze (javascript-typescript) (push) Failing after 10m7s
Some checks failed
CI-integ-test-full / caching-integ-tests (push) Failing after 32s
CI-integ-test-full / other-integ-tests (push) Failing after 29m15s
Update Wrapper checksums file / Update checksums (push) Failing after 3m7s
CI-codeql / Analyze (javascript-typescript) (push) Failing after 10m7s
This commit is contained in:
18
sources/src/wrapper-validation/hash.ts
Normal file
18
sources/src/wrapper-validation/hash.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import * as crypto from 'crypto'
|
||||
import * as fs from 'fs'
|
||||
|
||||
export async function sha256File(path: string): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const hash = crypto.createHash('sha256')
|
||||
const stream = fs.createReadStream(path)
|
||||
stream.on('data', data => hash.update(data))
|
||||
stream.on('end', () => {
|
||||
stream.destroy()
|
||||
resolve(hash.digest('hex'))
|
||||
})
|
||||
stream.on('error', error => {
|
||||
stream.destroy()
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user