A tiny isomorphic hashing module using the native crypto API in Node.js and browsers.
crypto-hash is a lightweight JavaScript library that provides a unified API for cryptographic hashing in both Node.js and browser environments. It abstracts the native crypto APIs (`node:crypto` and `window.crypto.subtle`) to deliver consistent hash functions like SHA-256, ensuring developers don't need to write environment-specific code.
JavaScript developers building applications that require consistent hashing across server-side (Node.js) and client-side (browser) contexts, such as isomorphic web apps, PWAs, or tools needing cryptographic integrity checks.
It eliminates the complexity of managing different crypto implementations per environment with an extremely small footprint, offering a simple, promise-based interface that just works everywhere without heavy dependencies.
Tiny hashing module that uses the native crypto API in Node.js and the browser
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides identical function signatures in Node.js and browsers by leveraging native crypto APIs, eliminating the need for environment-specific code, as demonstrated in the consistent usage examples.
The browser version is only ~300 bytes minified and gzipped, minimizing frontend performance impact, a key selling point highlighted in the README.
In Node.js, hashing operations are offloaded to a worker thread to avoid blocking the main thread, enhancing application responsiveness, as noted in the API documentation.
Supports both hex strings and ArrayBuffer outputs via the outputFormat option, catering to diverse use cases without additional conversion steps, as specified in the options.
Only includes SHA-1, SHA-256, SHA-384, and SHA-512, missing other common hashes like MD5 or SHA-3, which may be required for compatibility with legacy systems or specific standards.
Requires a secure context (HTTPS) in browsers and explicitly does not support Internet Explorer, restricting deployment in HTTP environments or older applications.
All functions return promises, which can complicate code in scenarios where synchronous operations are preferred for simplicity or in non-async contexts.