@kdf/salt
v1.0.1 kdf salt crypt passwords hashing password crypto
kdf-salt
🎲 Crypto secure salt generator
Coded with ❤️ by Simone Primarosa.
Install
npm install --save @kdf/salt
Usage
const gensalt = require('@kdf/salt');
gensalt(16).then(salt => {
console.log(salt);
// => <Buffer 70 2c 6e 1c c1 07 2e 26 dc 82 52 4e 1b cf 1d 23>
console.log(salt.toString('base64'));
// => cCxuHMEHLibcglJOG88dIw==
console.log(salt.toString('hex'));
// => 702c6e1cc1072e26dc82524e1bcf1d23
})
API
gensalt(length) ⇒ Promise.<Buffer>
Generates a cryptographically secure random string to be used as a password salt , using Node's built-in crypto.randomBytes() function.
Kind: global function
Returns: Promise.<Buffer>
- The salt as a Buffer.
Access: public
Param | Type | Description |
---|---|---|
length | number |
The length of the salt to be generated. Must be an integer within the range (0 <= length <= 2^31-1 ). |
Contributing
Contributions are REALLY welcome and if you find a security flaw in this code, PLEASE report it.
Authors
- Simone Primarosa - Github (@simonepri) • Twitter (@simoneprimarosa)
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the license file for details.
npm i @kdf/[email protected]
Metadata
- MIT
- >=4
- Simone Primarosa
- released 7/12/2018