file-to-sha1
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

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)

Package Sidebar

Install

npm i file-to-sha1

Weekly Downloads

6

Version

0.0.1

License

MIT

Unpacked Size

2.84 kB

Total Files

6

Last publish

Collaborators

  • dimitarnestorov