Skip to content

Instantly share code, notes, and snippets.

0x2611a2A8489b104BE82d31f5dc4118a5Af1eAA69
@Katafalkas
Katafalkas / hashFileSha3_256.js
Created February 20, 2021 16:55
File hashing
const fs = require('fs').promises;
const { SHA3 } = require('sha3');
const imageHash = async (imageFilePath) => {
const fileContent = await fs.readFile(imageFilePath);
const base64FileContent = fileContent.toString('base64');
const hash = SHA3(256);
hash.update(base64FileContent);
return hash.digest({ buffer: Buffer.alloc(32), format: 'hex' });
};