simple-hash-password
v0.1.1
Published
A TypeScript library for securely hashing passwords, verifying hashed passwords, and generating random passwords using various algorithms (SHA-1, SHA-256, SHA-384, SHA-512).
Downloads
131
Maintainers
Readme
simple-hash-password
A simple TypeScript library for hashing passwords, verifying hashed passwords, and generating random passwords. This package leverages the Web Crypto API to provide secure password hashing.
Features
- Hash passwords using various algorithms (SHA-1, SHA-256, SHA-384, SHA-512).
- Verify hashed passwords.
- Generate secure random passwords.
Installation
You can install the package via npm:
npm install simple-hash-password
Usage
import { hash, verify, generatePassword } from "simple-hash-password";
const password = "yourSecurePassword123";
const hashedPassword = await hash(password, { algorithm: "SHA-256" });
console.log(`Hashed Password: ${hashedPassword}`);
const isValid = await verify(password, hashedPassword, { algorithm: "SHA-256" });
console.log(`Password is valid: ${isValid}`);
const newPassword = generatePassword({ length: 18 }); // Length should be a multiple of 3
console.log(`Generated Password: ${newPassword}`);