Skip to content

often/csum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Calculate the checksum of a file using JavaScript.

API documentation

The file csum.js exports one function called csum that takes two arguments: file and algorithm (default: SHA-256)

You must pass a File object to the file argument, and regarding the algorithm argument, you must pass a supported algorithm.

Once called, if everything is ok, it returns a string (the calculated file hash hex). If everything is not ok, it throws an error.

Usage

<input type='file' />
import { csum } from 'https://often.github.io/csum/csum.js'

const input = document.querySelector('input')

input.addEventListener('change', async () => {
   const [file] = input.files
   console.log(file.name, await csum(file))
})

Installation

npm i csum

License

AGPL-3.0