https://github.com/simonepri/kdf-salt
🎲 Crypto secure salt generator
https://github.com/simonepri/kdf-salt
crypto nodejs salt
Last synced: 6 months ago
JSON representation
🎲 Crypto secure salt generator
- Host: GitHub
- URL: https://github.com/simonepri/kdf-salt
- Owner: simonepri
- License: mit
- Created: 2018-07-12T20:50:36.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-29T19:09:58.000Z (over 4 years ago)
- Last Synced: 2025-02-04T18:23:14.718Z (8 months ago)
- Topics: crypto, nodejs, salt
- Language: JavaScript
- Size: 7.81 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
kdf-salt
🎲 Crypto secure salt generator
Coded with ❤️ by Simone Primarosa.
## Install
```bash
npm install --save @kdf/salt
```## Usage
```js
const gensalt = require('@kdf/salt');gensalt(16).then(salt => {
console.log(salt);
// =>
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][new issue].## Authors
- **Simone Primarosa** - *Github* ([@simonepri][github:simonepri]) • *Twitter* ([@simoneprimarosa][twitter:simoneprimarosa])See also the list of [contributors][contributors] who participated in this project.
## License
This project is licensed under the MIT License - see the [license][license] file for details.[new issue]: https://github.com/simonepri/kdf-salt/issues/new
[contributors]: https://github.com/simonepri/kdf-salt/contributors[license]: https://github.com/simonepri/kdf-salt/tree/master/license
[github:simonepri]: https://github.com/simonepri
[twitter:simoneprimarosa]: http://twitter.com/intent/user?screen_name=simoneprimarosa