Home

hasha

Hasha is an open-source JavaScript library for Node.js that provides a simple interface to compute hash digests and file checksums. It was created by Sindre Sorhus and published on the npm registry to aid developers in verifying data integrity during software development and deployment. Hasha is designed to be a lightweight wrapper around the Node.js crypto module, supporting a variety of input sources and output formats.

Key features include support for multiple hash algorithms (such as md5, sha1, sha256, sha512, and others), the

Common usage patterns involve hashing a file or a buffer with a promise-based API or a synchronous

const hasha = require('hasha');

hasha.fromFile('path/to/file', { algorithm: 'sha256' }).then(hash => {

console.log(hash);

});

For synchronous usage:

const hashSync = hasha.fromFileSync('path/to/file', { algorithm: 'sha256' });

console.log(hashSync);

Hasha is widely adopted in Node.js projects to streamline integrity checks and reproducible builds, offering a

ability
to
compute
several
digests
in
a
single
pass,
and
both
asynchronous
and
synchronous
APIs.
Hasha
can
calculate
hashes
from
a
file
path,
a
buffer,
or
a
stream,
making
it
versatile
for
use
in
build
pipelines,
tests,
and
runtime
checks.
Outputs
can
be
produced
in
different
encodings,
typically
hex
or
base64,
depending
on
the
options
chosen.
variant.
For
example,
hashing
a
file
with
sha256:
straightforward
approach
to
obtaining
hash
digests
across
multiple
algorithms
with
minimal
boilerplate.