@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.
npm install @se-oss/sha1Install using your favorite package manager
pnpm
pnpm install @se-oss/sha1yarn
yarn add @se-oss/sha1Calculate 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, ... ]Support for Uint8Array or Buffer as input.
import { sha1 } from '@se-oss/sha1';
const data = new TextEncoder().encode('hello world');
const hash = sha1(data);The library detects the environment and switches implementations automatically:
- Node.js: Uses
node:cryptofor hardware-accelerated performance. - Browsers/Edge: Uses a pure JavaScript implementation.
For all configuration options, please see the API docs.
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! π
MIT Β© Shahrad Elahi and contributors.