phasher
v1.0.1
Published
A tiny, dependency-free password hashing utility for Node.js and the browser.
Maintainers
Readme
✨ phasher (Password Hasher)
A tiny, secure, dependency-free password hashing utility for both Node.js and the browser.
- ✉️ Lightweight: 100% core APIs
- ⚡ Asynchronous & secure (PBKDF2)
- ✨ Cross-platform: works in Node.js + modern browsers
- ⛓ Base64-encoded, versioned output
✨ Features
- Secure password hashing using PBKDF2
- Constant-time password comparison
- Salted and versioned format
- Tiny footprint and tree-shakable
- Zero dependencies
📂 Installation
npm install phasherbun add phasherpnpm install phasheryarn install phasheror just use via CDN:
<script src="https://unpkg.com/password-hasher/dist/password-hasher.umd.js"></script>🎓 Usage
Node.js
import { PasswordHasher } from "phasher";
const hasher = new PasswordHasher();
const hash = await hasher.hash("myPassword");
const isValid = await hasher.verify("myPassword", hash);Browser
<script>
const hasher = new PasswordHasher.PasswordHasher();
hasher.hashPassword("secure123!").then(console.log);
</script>🔐 Hash Format
v1$iterations$keyLength$digest$saltBase64$hashBase64🌐 API
new PasswordHasher(options?)
iterations: number of iterations (default: 100_000)saltLength: bytes of salt (default: 16)keyLength: key size in bytes (default: 32)digest: e.g.,SHA-256
hash(password: string): Promise<string>
Returns a versioned hash string.
verify(password: string, hash: string): Promise<boolean>
Verifies password against the stored hash.
🚀 Build
npm install
npm run build✉ License
MIT - see LICENSE file.
Made with ❤ by Mehedi Hasan
