sha.js is a JavaScript library providing various Secure Hash Algorithm (SHA) implementations in pure JavaScript, primarily intended for Node.js environments but also usable in browsers via tools like Browserify. It offers implementations for SHA-0 (legacy), SHA-1 (legacy), SHA-224, SHA-256, SHA-384, and SHA-512. The package is currently at version 2.4.12, with its last publish being 9 months ago as of July 2025. While it presents a stream-like interface with `update()` and `digest()`, it's important to note it does not implement a true Node.js `stream.Writable` interface, though it allows incremental processing for large inputs without consuming excessive RAM. Its main differentiator is being a pure JavaScript implementation, making it suitable for environments where native crypto modules are unavailable or undesirable. Given its version history and the nature of cryptographic libraries, it likely follows a stable maintenance release cadence, with updates primarily for security patches or critical bug fixes rather than frequent feature additions.
npm install sha.jsVerified import paths — ran on the pinned version, not inferred.
Demonstrates both the factory function and direct constructor methods for SHA hashing, including incremental updates for large data.
Migrate to stronger algorithms like SHA-256 or SHA-512 for all cryptographic operations. For existing data, consider re-hashing with secure algorithms and updating references.
Immediately update to `sha.js` version 2.4.12 or newer. Conduct thorough security assessments of systems that may have been exposed to malicious hash manipulation attempts.
If integrating with Node.js streams, wrap `sha.js` instances in a custom `stream.Writable` or `stream.Transform` implementation to bridge the interfaces.
For performance-critical applications in Node.js, prefer the built-in `crypto` module (e.g., `crypto.createHash('sha256')`). Use `sha.js` primarily for browser environments or specific contexts where pure JavaScript is a strict requirement.Use `const shajs = require('sha.js')` for CommonJS. If you want a specific hash, use the factory `shajs('sha256')` or the specific constructor `new shajs.sha256()`.Ensure the hash function name matches one of the supported strings exactly: 'sha', 'sha1', 'sha224', 'sha256', 'sha384', or 'sha512'. Note that `sha-256` (with hyphen) is not supported by this library, use `sha256` (without hyphen).
No dependency data recorded yet.