Last active
April 10, 2019 20:54
-
-
Save miguelmota/d10e7ac5238acc4e97053b9f8b6a27b9 to your computer and use it in GitHub Desktop.
Node.js Keccak256 (SHA-3) hash of file
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
const fs = require('fs') | |
const {sha3} = require('ethereumjs-util') | |
const crypto = require('crypto') | |
const file = fs.readFileSync(__dirname + '/file.png') | |
const keccak256hash = sha3(file).toString('hex') | |
console.log(keccak256hash) | |
const sha256hash = crypto.createHash('sha256').update(file).digest().toString('hex') | |
console.log(sha256hash) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is cool and works but should be updated to use
keccak256
instead ofsha3
as per the latest naming convention.