Last active
May 25, 2022 17:46
-
-
Save AlloVince/ecbc50d3ee09965813ead9e34ca292f1 to your computer and use it in GitHub Desktop.
Compatible sha256 file hash for python and node.js
This file contains hidden or 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
const crypto = require('crypto'); | |
const fs = require('fs') | |
const fileBuffer = fs.readFileSync(filePath); | |
const fsHash = crypto.createHash('sha256'); | |
fsHash.update(fileBuffer); | |
const hash = fsHash.digest('hex'); | |
console.log(hash); |
This file contains hidden or 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
import hashlib | |
with open(file_path, mode='rb') as file: | |
file_content = file.read() | |
hash = hashlib.sha256(file_content).hexdigest() | |
print(hash) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
THANK YOU!!!!