often / csum

Calculate the checksum of a file using JavaScript.

Home Page:https://often.github.io/csum/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Calculate the checksum of a file using JavaScript.

https://often.github.io/csum/

License:GNU Affero General Public License v3.0


Languages

Language:HTML 80.9%Language:JavaScript 19.1%