Created
July 1, 2019 00:45
-
-
Save dashawk/ada103da348519f2ad9973fde9d2ee4e to your computer and use it in GitHub Desktop.
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
// reference https://gist.github.com/GuillermoPena/9233069#gistcomment-2636187 | |
// sha-cli.js | |
const filename = process.argv[2]; | |
const crypto = require('crypto'); | |
const fs = require('fs'); | |
const hash = crypto.createHash('sha256'); | |
const input = fs.createReadStream(filename); | |
input.on('readable', () => { | |
const data = input.read(); | |
if (data) | |
hash.update(data); | |
else { | |
console.log(`${hash.digest('hex')} ${filename}`); | |
} | |
}); | |
// Example usage if you saved that code in sha-cli.js file would be: | |
// node sha-cli.js example-input-file.zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment