# js-crypto-pbkdf

> Universal Module for Password-based Key Derivation Function (PBKDF) in JavaScript

Latest version **1.0.7** (published 2023-09-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install js-crypto-pbkdf
pnpm add js-crypto-pbkdf
yarn add js-crypto-pbkdf
bun add js-crypto-pbkdf
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2023-09-27 |
| First published | 2018-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 92.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 162 |
| Author | Jun Kurihara |
| Maintainers | kurihara |
| Keywords | crypto, pbdkf2, pbkdf1, pkcs#5, rfc8018 |

## Links

- npm: https://www.npmjs.com/package/js-crypto-pbkdf
- Repository: https://github.com/junkurihara/jscu
- Homepage: https://github.com/junkurihara/jscu/tree/master/packages/js-crypto-pbkdf#readme
- Issues: https://github.com/junkurihara/jscu/issues
- npm.io page: https://npm.io/package/js-crypto-pbkdf

## Dependencies (3)

- [js-crypto-hash](https://npm.io/package/js-crypto-hash.md) ^1.0.7
- [js-crypto-hmac](https://npm.io/package/js-crypto-hmac.md) ^1.0.7
- [js-encoding-utils](https://npm.io/package/js-encoding-utils.md) 0.7.3

## 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

- 1.0.7 (latest) — 2023-09-27
- 1.0.6 — 2023-09-02
- 1.0.5 — 2023-08-25
- 1.0.4 — 2022-02-04
- 1.0.3 — 2021-11-22
- 1.0.2 — 2021-03-13
- 1.0.1 — 2021-03-13
- 1.0.0 — 2020-09-30
- 0.5.3 — 2020-01-14
- 0.5.2 — 2019-12-08
- 0.5.1 — 2019-11-19
- 0.5.0 — 2019-11-19
- 0.4.3 — 2019-08-14
- 0.4.2 — 2019-07-19
- 0.4.1 — 2019-07-13
- … 18 more at https://npm.io/package/js-crypto-pbkdf/versions

## README

Universal Module for Password-based Key Derivation Function (PBKDF) in JavaScript
--
[![npm version](https://badge.fury.io/js/js-crypto-pbkdf.svg)](https://badge.fury.io/js/js-crypto-pbkdf)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

> **WARNING**: At this time this solution should be considered suitable for research and experimentation, further code and security review is needed before utilization in a production application.

# Introduction and Overview

This library is designed to 'universally' provide PBKDF (Password-based Key Derivation Function) functions, i.e., it works both on most modern browsers and on Node.js just by importing from NPM/source code. This key utility library provides both PBKDF1 and PBKDF2 specified in PKCS#5 v2.1 ([RFC8018](https://tools.ietf.org/html/rfc8018)).

# Installation

At your project directory, do either one of the following.

- From npm/yarn:
  ```shell
  $ npm install --save js-crypto-pbkdf // npm
  $ yarn add js-crypto-pbkdf // yarn
  ```
- From GitHub:
  ```shell
  $ git clone https://github.com/junkurihara/jscu.git
  $ cd js-crypto-utils/packages/js-crypto-pbkdf
  & yarn build
  ```

Then you should import the package as follows.

```shell
import pbkdf from 'js-crypto-pbkdf'; // for npm
import pbkdf from 'path/to/js-crypto-pbkdf/dist/index.js'; // for github
```

The bundled file is also given as `js-crypto-pbkdf/dist/jscpbkdf.bundle.js` for a use case where the module is imported as a `window.jscpbkdf` object via `script` tags.


# Usage

## PBKDF2

See [RFC8018 Section 5.2](https://tools.ietf.org/html/rfc8018#section-5.2) for detailed specification.

```javascript
const password = 'password'; // string or Uint8Array
const salt = ...; // Uint8Array
const iterationCount = 2048;
const derivedKeyLen = 32;
const hash = 'SHA-256'; // 'SHA-384', 'SHA-512', 'SHA-1', 'MD5', 'SHA3-512', 'SHA3-384', 'SHA3-256', or 'SHA3-224'

pbkdf.pbkdf2(
  password,
  salt,
  iterationCount,
  derivedKeyLen,
  hash
).then( (key) => {
  // now you get the derived key of intended length
});
```

## PBKDF1

See [RFC8018 Section 5.1](https://tools.ietf.org/html/rfc8018#section-5.1) for detailed specification.

```javascript
const password = 'password'; // string or Uint8Array
const salt = ...; // Uint8Array
const iterationCount = 2048;
const derivedKeyLen = 32;
const hash = 'SHA-256'; // 'SHA-384', 'SHA-512', 'SHA-1', 'MD5', 'SHA3-512', 'SHA3-384', 'SHA3-256', or 'SHA3-224'

pbkdf.pbkdf1(
  password,
  salt,
  iterationCount,
  derivedKeyLen,
  hash
).then( (key) => {
  // now you get the derived key of intended length
});
```

# License

Licensed under the MIT license, see `LICENSE` file.

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