Skip to content

encryption-p is a lightweight password encryption and decryption library using Node.js crypto and SHA256. It provides secure password hashing with salt and easy password comparison, similar to bcrypt.

Notifications You must be signed in to change notification settings

ayanhasnain03/encryption-p

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

encryption-p

encryption-p is a lightweight password hashing library written in TypeScript, similar to bcrypt. It provides simple utilities for securely hashing and comparing passwords using Node.js' crypto module.

Features

  • Secure password hashing using pbkdf2Sync.
  • Customizable salt rounds.
  • Easy-to-use API for hashing and comparing passwords.

Installation

Install the package using npm:

npm install encryption-p

Usage

Hashing a Password

import { MyBcrypt } from "encryption-p";

const password = "mysecretpassword";
const hashedPassword = MyBcrypt.hash(password);

console.log(hashedPassword); // Outputs hashed password with salt

Comparing a Password

import { MyBcrypt } from "encryption-p";

const password = "mysecretpassword";
const hashedPassword = "stored_hashed_password";

const isMatch = MyBcrypt.compare(password, hashedPassword);

if (isMatch) {
  console.log("Password matches!");
} else {
  console.log("Invalid password.");
}

API

MyBcrypt.hash(password: string, saltRounds?: number): string

Hashes the provided password using the given number of salt rounds (default is 10). Returns the hashed password along with the salt.

  • password - The plain text password to be hashed.
  • saltRounds - (Optional) Number of salt rounds to apply.

MyBcrypt.compare(password: string, hash: string): boolean

Compares a plain text password with a previously hashed password. Returns true if the password matches, otherwise false.

  • password - The plain text password to compare.
  • hash - The hashed password to compare against.

License

This project is licensed under the MIT License.

Author

<<<<<<< HEAD

Ayan Hasnain

=======

Ayan Hasnain

>>>>>>> 09dce16c01c8dfa617e30f55c85bf8315a9b1dfe

About

encryption-p is a lightweight password encryption and decryption library using Node.js crypto and SHA256. It provides secure password hashing with salt and easy password comparison, similar to bcrypt.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published