0.0.1 • Published 6 years ago

file-to-sha1 v0.0.1

Weekly downloads
9
License
MIT
Repository
github
Last release
6 years ago

file-to-sha1

Calculates a SHA-1 of a given file

Install

Using yarn:

yarn add file-to-sha1

or using npm:

npm install file-to-sha1

Usage in the browser

import { blobToSHA1 } from 'file-to-sha1'

const hash = await blobToSHA1(fileInput.files[0])

Usage in node

For file paths

const { pathToSHA1 } = require('file-to-sha1')

const hash = await pathToSHA1('/path/to/file')

For buffers or strings

const fs = require('fs')
const { dataToSHA1 } = require('file-to-sha1')

const buffer = fs.readFileSync('/path/to/file')

const hash = dataToSHA1(buffer)