# @kdf/salt

> Crypto secure salt generator

Latest version **2.0.1** (published 2020-07-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @kdf/salt
pnpm add @kdf/salt
yarn add @kdf/salt
bun add @kdf/salt
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2020-07-05 |
| First published | 2018-07-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 8.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Simone Primarosa |
| Maintainers | simonepri |
| Keywords | kdf, salt, crypt, passwords, hashing, password, crypto |

## Links

- npm: https://www.npmjs.com/package/@kdf/salt
- Repository: https://github.com/simonepri/node-kdf
- Homepage: https://github.com/simonepri/node-kdf/tree/master/packages/salt#readme
- Issues: https://github.com/simonepri/node-kdf/issues
- npm.io page: https://npm.io/package/@kdf/salt

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2020-07-05
- 2.0.0 — 2020-07-05
- 1.0.1 — 2018-07-12

## README

<h1 align="center">
  <b>kdf-salt</b>
</h1>
<p align="center">
  <!-- Version - npm -->
  <a href="https://www.npmjs.com/package/@kdf/salt">
    <img src="https://img.shields.io/npm/v/@kdf/salt.svg" alt="Latest version on npm" />
  </a>
  <!-- Downloads - npm -->
  <a href="https://npm-stat.com/charts.html?package=@kdf/salt">
    <img src="https://img.shields.io/npm/dt/@kdf/salt.svg" alt="Downloads on npm" />
  </a>
  <!-- License - MIT -->
  <a href="https://github.com/simonepri/node-kdf/blob/master/packages/salt/license">
    <img src="https://img.shields.io/github/license/simonepri/node-kdf.svg" alt="Project license" />
  </a>

  <br/>

  <!-- Lint -->
  <a href="https://github.com/simonepri/node-kdf/actions?query=workflow:salt-lint+branch:master">
    <img src="https://github.com/simonepri/node-kdf/workflows/salt-lint/badge.svg?branch=master" alt="Lint status" />
  </a>
  <!-- Test - macOS -->
  <a href="https://github.com/simonepri/node-kdf/actions?query=workflow:salt-test-macos+branch:master">
    <img src="https://github.com/simonepri/node-kdf/workflows/salt-test-macos/badge.svg?branch=master" alt="Test macOS status" />
  </a>
  <!-- Test - Ubuntu -->
  <a href="https://github.com/simonepri/node-kdf/actions?query=workflow:salt-test-ubuntu+branch:master">
    <img src="https://github.com/simonepri/node-kdf/workflows/salt-test-ubuntu/badge.svg?branch=master" alt="Test Ubuntu status" />
  </a>
  <!-- Test - Windows -->
  <a href="https://github.com/simonepri/node-kdf/actions?query=workflow:salt-test-windows+branch:master">
    <img src="https://github.com/simonepri/node-kdf/workflows/salt-test-windows/badge.svg?branch=master" alt="Test Windows status" />
  </a>

  <br/>

  <!-- Coverage - Codecov -->
  <a href="https://codecov.io/gh/simonepri/node-kdf/tree/master/packages/salt">
    <img src="https://codecov.io/gh/simonepri/node-kdf/branch/master/graph/badge.svg?flag=salt" alt="Codecov Coverage report" />
  </a>
  <!-- DM - Snyk -->
  <a href="https://snyk.io/test/github/simonepri/node-kdf?targetFile=packages/salt/package.json">
    <img src="https://snyk.io/test/github/simonepri/node-kdf/badge.svg?targetFile=packages/salt/package.json" alt="Known Vulnerabilities" />
  </a>
  <!-- DM - David -->
  <a href="https://david-dm.org/simonepri/node-kdf?path=packages/salt">
    <img src="https://david-dm.org/simonepri/node-kdf/status.svg?path=packages/salt" alt="Dependency Status" />
  </a>

  <br/>

  <!-- Code Style - XO-Prettier -->
  <a href="https://github.com/xojs/xo">
    <img src="https://img.shields.io/badge/code_style-XO+Prettier-5ed9c7.svg" alt="XO Code Style used" />
  </a>
  <!-- Test Runner - AVA -->
  <a href="https://github.com/avajs/ava">
    <img src="https://img.shields.io/badge/test_runner-AVA-fb3170.svg" alt="AVA Test Runner used" />
  </a>
  <!-- Test Coverage - Istanbul -->
  <a href="https://github.com/istanbuljs/nyc">
    <img src="https://img.shields.io/badge/test_coverage-NYC-fec606.svg" alt="Istanbul Test Coverage used" />
  </a>
  <!-- Init - ni -->
  <a href="https://github.com/simonepri/ni">
    <img src="https://img.shields.io/badge/initialized_with-ni-e74c3c.svg" alt="NI Scaffolding System used" />
  </a>
  <!-- Release - np -->
  <a href="https://github.com/sindresorhus/np">
    <img src="https://img.shields.io/badge/released_with-np-6c8784.svg" alt="NP Release System used" />
  </a>
</p>
<p align="center">
  🎲 Crypto secure salt generator

  <br/>

  <sub>
    Coded with ❤️ by <a href="#authors">Simone Primarosa</a>.
  </sub>
</p>

## Install

```bash
npm install --save @kdf/salt
```

## Usage

```js
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

<a name="gensalt"></a>

### gensalt(length) ⇒ <code>Promise.&lt;Buffer&gt;</code>
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**: <code>Promise.&lt;Buffer&gt;</code> - The salt as a Buffer.  
**Access**: public  

| Param | Type | Description |
| --- | --- | --- |
| length | <code>number</code> | 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.


<!-- Links -->
[new issue]: https://github.com/simonepri/node-kdf/issues/new
[contributors]: https://github.com/simonepri/node-kdf/contributors

[license]: https://github.com/simonepri/node-kdf/blob/master/packages/salt/license

[github:simonepri]: https://github.com/simonepri
[twitter:simoneprimarosa]: http://twitter.com/intent/user?screen_name=simoneprimarosa

---
_Source: https://npm.io/package/@kdf/salt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
