{"library":"sha.js","title":"SHA.js Hashing Library","description":"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.","language":"javascript","status":"maintenance","last_verified":"Sun Apr 19","install":{"commands":["npm install sha.js"],"cli":null},"imports":["const shajs = require('sha.js')","const hash = shajs('sha256');","const hash = new shajs.sha256();"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const shajs = require('sha.js');\n\n// Using the factory function style\nconsole.log('SHA-256 (factory function):');\nconst hashFactory = shajs('sha256');\nhashFactory.update('Hello, World!');\nconsole.log(hashFactory.digest('hex'));\n\n// Using the constructor style\nconsole.log('\\nSHA-512 (constructor):');\nconst hashConstructor = new shajs.sha512();\nhashConstructor.update('Hello, World!');\nconsole.log(hashConstructor.digest('hex'));\n\n// Example with a stream-like interface (though not a true Node.js stream)\nconsole.log('\\nSHA-256 (stream-like update/read):');\nconst sha256stream = shajs('sha256');\nsha256stream.write('Part 1'); // Use write for incremental updates\nsha256stream.end(' of Part 2'); // Final chunk via end\nconsole.log(sha256stream.read().toString('hex')); // Get the final hash as a Buffer and convert","lang":"javascript","description":"Demonstrates both the factory function and direct constructor methods for SHA hashing, including incremental updates for large data.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}