file-to-hash
v0.0.1
Published
Calculates a given hash of a given file. Single package for the browser and node.
Downloads
332
Maintainers
Readme
file-to-hash
Calculates a given hash of a given file
Install
Using yarn:
yarn add file-to-hash
or using npm:
npm install file-to-hash
Usage in the browser
import { blobToHash } from 'file-to-hash'
const hash = await blobToHash('sha256', fileInput.files[0])
Usage in node
For file paths
const { pathToHash } = require('file-to-hash')
const hash = await pathToHash('sha256', '/path/to/file')
For buffers or strings
const fs = require('fs')
const { dataToHash } = require('file-to-hash')
const buffer = fs.readFileSync('/path/to/file')
const hash = dataToHash('sha256', buffer)