Package Exports
- salt-password
- salt-password/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (salt-password) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
salt-password
salt-password is a lightweight npm package for securely salting, hashing, and verifying passwords in Node.js applications. It provides functions for generating random salts, hashing passwords using the SHA-256 algorithm, and verifying passwords against their hashed counterparts, enhancing the security of password storage and authentication processes.
Installation
You can install salt-password using npm:
npm install salt-passwordUsage
Generating a Salt
To generate a random salt, you can use the generateSalt function:
const saltPass = require('salt-password');
const salt = saltPass.generateSalt();
console.log('Generated Salt:', salt);Hashing a Password
To hash a password using a salt, you can use the hashPassword function:
// importing package
const saltPass = require('salt-password');
const password = 'YourPass';
const salt = saltPass.generateSalt(); // generating salt using SHA-256
const hashedPassword = saltPass.hashPassword(password, salt); //Generating Password
console.log('Password:', password); //Your Password
console.log('Salt:', salt); //Salt generated
console.log('Hashed Password:', hashedPassword); //Hashed PasswordVerifying a Password
//importing package
const saltPass = require('salt-password');
const password = 'Shushi'; //Your Password
const salt = saltPass.generateSalt(); //Generating Salt
const hashedPassword = saltPass.hashPassword(password, salt); //Generating Hashed Password
const inputpass = "Shushi"; //Password input by user
const isPassValid = saltPass.verifyPassword(inputpass,hashedPassword,salt); //Checking if the password are matching
console.log(isPassValid); Contributing
Contributions are welcome! If you encounter any bugs, have feature requests, or want to contribute enhancements or fixes, please feel free to open an issue or submit a pull request.