# Keystore.pbkdf2

Derives a key from a password using [PBKDF2](https://en.wikipedia.org/wiki/PBKDF2).

## Imports

:::code-group
```ts [Named]
import { Keystore } from 'ox'
```

```ts [Entrypoint]
import * as Keystore from 'ox/Keystore'
```
:::

## Examples

```ts twoslash
import { Keystore } from 'ox'

const [key, opts] = Keystore.pbkdf2({
  password: 'testpassword'
})
```

## Definition

```ts
function pbkdf2(
  options: pbkdf2.Options,
): [() => `0x${string}`, {
    readonly iv: `0x${string}` | Uint8Array | undefined;
    readonly kdfparams: {
        readonly c: number;
        readonly dklen: 32;
        readonly prf: "hmac-sha256";
        readonly salt: string;
    };
    readonly kdf: "pbkdf2";
} & {
    iv: Bytes.Bytes;
}]
```

**Source:** [src/core/Keystore.ts](https://github.com/wevm/ox/blob/main/src/core/Keystore.ts#L580)

## Parameters

### options

* **Type:** `pbkdf2.Options`

PBKDF2 options.

#### options.iterations

* **Type:** `number`
* **Optional**

The number of iterations to use.

#### options.iv

* **Type:** `0x${string} | Uint8Array`
* **Optional**

The counter to use for the AES-CTR encryption.

#### options.password

* **Type:** `string`

Password to derive key from.

#### options.salt

* **Type:** `0x${string} | Uint8Array`
* **Optional**

Salt to use for key derivation.

## Return Type

PBKDF2 key.

`[() => `0x${string}`, {
    readonly iv: `0x${string}` | Uint8Array | undefined;
    readonly kdfparams: {
        readonly c: number;
        readonly dklen: 32;
        readonly prf: "hmac-sha256";
        readonly salt: string;
    };
    readonly kdf: "pbkdf2";
} & {
    iv: Bytes.Bytes;
}]`
