Skip to content

Keystore.pbkdf2

Derives a key from a password using PBKDF2.

Imports

Named
import { Keystore } from 'ox'

Examples

import { Keystore } from 'ox'
 
const key = Keystore.pbkdf2({ password: 'testpassword' })

Definition

function pbkdf2(
  options: pbkdf2.Options,
): {
    readonly iv: Uint8Array | `0x${string}` | undefined;
    readonly key: () => string;
    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

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.

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