-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #339 from ooni/release-3.9.7
Release v3.9.7
- Loading branch information
Showing
3 changed files
with
38 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// copied from https://stackoverflow.com/a/60208623 | ||
const path = require('path') | ||
const fs = require('fs') | ||
const crypto = require('crypto') | ||
|
||
const YOUR_FILE_PATH = './dist/OONI Probe Setup 3.9.7-rc.1.exe' | ||
|
||
function hashFile(file, algorithm = 'sha512', encoding = 'base64', options) { | ||
return new Promise((resolve, reject) => { | ||
const hash = crypto.createHash(algorithm) | ||
hash.on('error', reject).setEncoding(encoding) | ||
fs.createReadStream( | ||
file, | ||
Object.assign({}, options, { | ||
highWaterMark: 1024 * 1024, | ||
/* better to use more memory but hash faster */ | ||
}) | ||
) | ||
.on('error', reject) | ||
.on('end', () => { | ||
hash.end() | ||
console.log('hash done') | ||
console.log(hash.read()) | ||
resolve(hash.read()) | ||
}) | ||
.pipe(hash, { | ||
end: false, | ||
}) | ||
}) | ||
} | ||
|
||
const installerPath = path.resolve(__dirname, YOUR_FILE_PATH) | ||
|
||
hashFile(installerPath) |