@se-oss/apr1
v1.0.0
Published
Apache's APR1 MD5 password hashing for Node.js and browsers.
Maintainers
Readme
@se-oss/apr1 provides Apache's APR1 MD5 password hashing for Node.js and browsers, offering a lightweight and isomorphic solution for htpasswd-compatible authentication.
📦 Installation
npm install @se-oss/apr1pnpm
pnpm install @se-oss/apr1yarn
yarn add @se-oss/apr1📖 Usage
Generate Hash
Generate a secure APR1 hash for a password. If no salt is provided, a random 8-character salt is automatically generated.
import { generateApr1 } from '@se-oss/apr1';
// With automatic salt generation
const hash = generateApr1('my-password');
// $apr1$8x9z2p4n$L3...
// With specific salt
const saltedHash = generateApr1('my-password', 'Hl8aeGwd');
// $apr1$Hl8aeGwd$eu0KXh0r52OnPC/yzIzWF1Verify Hash
Verify if a plain-text password matches an existing APR1 hash using timing-safe comparison.
import { verifyApr1 } from '@se-oss/apr1';
const isValid = verifyApr1(
'my-password',
'$apr1$Hl8aeGwd$eu0KXh0r52OnPC/yzIzWF1'
);
console.log(isValid); // trueIsomorphic Support
This library works seamlessly in both Node.js and modern browsers using TextEncoder and standard Uint8Array operations.
📚 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.
