# pbkdf2-password

> Easy salt/password creation for Node.js, extracted from Mosca

Latest version **1.2.1** (published 2016-09-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install pbkdf2-password
pnpm add pbkdf2-password
yarn add pbkdf2-password
bun add pbkdf2-password
```

## 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 | 1.2.1 |
| Published | 2016-09-29 |
| First published | 2015-01-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 25 |
| Author | Matteo Collina |
| Maintainers | matteo.collina |
| Keywords | pbkdf2, authentication |

## Links

- npm: https://www.npmjs.com/package/pbkdf2-password
- Repository: https://github.com/mcollina/pbkdf2-password
- Issues: https://github.com/mcollina/pbkdf2-password/issues
- npm.io page: https://npm.io/package/pbkdf2-password

## Dependencies (1)

- [fastfall](https://npm.io/package/fastfall.md) ^1.2.3

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 1.2.1 (latest) — 2016-09-29
- 1.2.0 — 2016-09-29
- 1.1.0 — 2015-06-30
- 1.0.0 — 2015-01-29

## README

# pbkdf2-password&nbsp;[![Build Status](https://travis-ci.org/mcollina/pbkdf2-password.svg?branch=master)](https://travis-ci.org/mcollina/pbkdf2-password)

Easy salt/password creation for Node.js, extracted from
[Mosca](http://npm.im/mosca).

Usage
-----

```js
var bkfd2Password = require("pbkdf2-password");
var hasher = bkfd2Password();
var assert = require("assert");
var opts = {
  password: "helloworld"
};

hasher(opts, function(err, pass, salt, hash) {
  opts.salt = salt;
  hasher(opts, function(err, pass, salt, hash2) {
    assert.deepEqual(hash2, hash);

    // password mismatch
    opts.password = "aaa";
    hasher(opts, function(err, pass, salt, hash2) {
      assert.notDeepEqual(hash2, hash);
      console.log("OK");
    });
  });
});
```

API
---

* <a href="#build"><code>bkfd2Password<b></b></code></a>
* <a href="#hasher"><code><b>hasher()</b></code></a>

<a name="build">
### bkfd2Password(options)

Creates a new [hasher](#hasher) functions, with the specified options.

Options:

 * `saltLength`, the length of the random salt
 * `iterations`, number of pbkdf2 iterations
 * `keyLength`, the length of the generated keys
 * `digest`, the digest algorithm, default `'sha1'`

<a name="hasher">
### hasher(opts, function(err, pass, salt, hash))

Hash a password, using a hash and the pbkd2
crypto module.

Options:
 - `password`, the password to hash.
 - `salt`, the salt to use, as a base64 string.

If the `password` is left undefined, a new
10-bytes password will be generated, and converted
to base64.

If the `salt` is left undefined, a new salt is generated.

The callback will be called with the following arguments:
 - the error, if something when wrong.
 - the password.
 - the salt, encoded in base64.
 - the hash, encoded in base64.

License
-------

MIT

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