Checksum Utility for Node.js

1.0.0 · abandoned · verified Sun Apr 19

The `checksum` package by `dshaw` is a minimalistic utility for Node.js environments, designed to compute cryptographic hashes for strings and local files. It supports algorithms such as SHA1 (which is the default) and MD5, alongside others provided by Node.js's built-in `crypto` module. The package's current and only stable version, 1.0.0, was last published approximately five years ago (as of April 2026), indicating it is no longer under active maintenance or development. This makes it suitable primarily for legacy CommonJS Node.js projects. While it offers a straightforward API for both direct string hashing and asynchronous file hashing, as well as a command-line interface, developers should be aware of its unmaintained status and the use of older, less secure default hashing algorithms like SHA1 and MD5 for modern integrity verification needs. More contemporary Node.js projects often leverage the native `crypto` module directly or use newer, actively maintained third-party libraries that offer ESM support and stronger defaults.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to calculate checksums for both strings and files using the main `checksum` function and its `file` method, including cleanup.

const checksum = require('checksum');
const fs = require('fs');

// Calculate checksum for a string
const stringToHash = 'Hello, world!';
const stringChecksum = checksum(stringToHash);
console.log(`Checksum for '${stringToHash}': ${stringChecksum}`);

// Calculate checksum for a file
const filePath = 'example.txt';
fs.writeFileSync(filePath, 'This is a test file for checksum calculation.');

checksum.file(filePath, { algorithm: 'sha256' }, (err, sum) => {
  if (err) {
    console.error('Error calculating file checksum:', err);
    return;
  }
  console.log(`Checksum (SHA256) for '${filePath}': ${sum}`);
  fs.unlinkSync(filePath); // Clean up the test file
});

// Using the CLI tool (requires global install: npm install -g checksum)
// To run in terminal: echo -n 'dshaw' | checksum
// Or: checksum ./example.txt

view raw JSON →