0.0.1 • Published 5 years ago
file-to-hash v0.0.1
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)
0.0.1
5 years ago