@altrepo/hash
v0.1.0
Published
A lightweight multi-environment utility library for generating hashes and verifying checksums for text, bytes, and files.
Maintainers
Readme
altrepo-hash
AltRepo Hash is a lightweight Node.js utility library for generating hashes and verifying checksums for text, bytes, and files.
Features
- Straightforward API: Easily generate hashes or verify checksums with a clean, intuitive interface.
- Zero Dependencies: Built entirely on top of Node.js's standard
cryptoandfsmodules, ensuring a lightweight footprint with no external requirements. - Secure Verifications: Utilizes constant-time comparisons (
crypto.timingSafeEqual) to securely verify file and text hashes. - Broad Algorithm Support: Includes built-in support for all major hashing algorithms including
sha256,sha512,blake2b512,blake2s256,md5,sha1, and more. - Memory Efficient: Safely processes large files in chunks via
hashFilewithout loading the entire file into memory using standard readable streams.
Installation
npm install altrepo-hashExample API
import { hashText, hashFile, verifyFileHash } from "altrepo-hash";
async function run() {
console.log(hashText("hello", "sha256"));
console.log(await hashFile("download.zip", "sha256"));
console.log(
await verifyFileHash("download.zip", "abc123...", "sha256")
);
}
run();Browser Version
AltRepo Hash is the JS companion to the browser-based hash tools on AltRepo.
More hash tools: https://altrepo.net/hash/
