@se-oss/sha1
v1.0.0
Published
Isomorphic SHA-1 hashing library for Node.js and browsers.
Maintainers
Readme
@se-oss/sha1 is an isomorphic SHA-1 hashing library that automatically leverages native performance in Node.js while providing a robust pure-JS fallback for browsers.
📦 Installation
npm install @se-oss/sha1pnpm
pnpm install @se-oss/sha1yarn
yarn add @se-oss/sha1📖 Usage
Basic Usage
Calculate the SHA-1 hash of a string. Returns a Uint8Array.
import { sha1 } from '@se-oss/sha1';
const hash = sha1('password');
// Uint8Array(20) [ 91, 170, 97, 228, ... ]Buffer Input
Support for Uint8Array or Buffer as input.
import { sha1 } from '@se-oss/sha1';
const data = new TextEncoder().encode('hello world');
const hash = sha1(data);Isomorphic Behavior
The library detects the environment and switches implementations automatically:
- Node.js: Uses
node:cryptofor hardware-accelerated performance. - Browsers/Edge: Uses a pure JavaScript implementation.
📚 Documentation
For all configuration options, please see the API docs.
🤝 Contributing
Want to contribute? Awesome! To show your support is to star the project, or to raise issues on GitHub.
Thanks again for your support, it is much appreciated! 🙏
License
MIT © Shahrad Elahi and contributors.
