Key Derivation Functions

cryptographer.js provides comprehensive key derivation and password hashing functions.

Overview

Key Derivation Functions (KDF) are used for:

  • Password hashing and verification

  • Key stretching

  • Salt generation and management

  • Secure key derivation from passwords

  • Password-based authentication systems

Supported Algorithms

Algorithm
Standard
Status
Use Case
Security Level

Argon2id

RFC 9106

✅ Recommended

Password hashing

Very High

Argon2i

RFC 9106

✅ Recommended

Password hashing

Very High

Argon2d

RFC 9106

⚠️ Use with caution

Password hashing

High

bcrypt

-

✅ Recommended

Password hashing

High

PBKDF2

RFC 2898

✅ Recommended

Key derivation

Medium

Basic Usage

bcrypt

PBKDF2

Advanced Usage

Password Management System

Secure Key Derivation

Multi-Factor Authentication

Security Best Practices

Parameter Selection

Salt Management

Timing-Safe Comparison

Algorithm Selection

Performance (Linux x64 / Node 20)

Algorithm
Parameters
ops/s
vs crypto-js/bcryptjs
Notes

Argon2id

t=3, m=64MB, p=1

~7

N/A

Password hashing (recommended)

Argon2i

t=3, m=64MB, p=1

~7

N/A

Side-channel resistance

PBKDF2-SHA256

100k iterations

~28

~28× vs crypto-js (≈1)

Key derivation

bcrypt

rounds=12

~4

N/A

Legacy compatibility

Error Handling

TypeScript Support

API Reference

Function Signatures

Types

Available Functions

  • crypto.kdf.argon2(password, options)

  • crypto.kdf.bcrypt.hash(password, options?)

  • crypto.kdf.bcrypt.verify(password, hash)

  • crypto.kdf.pbkdf2(password, options)

Parameter Recommendations

Argon2

  • timeCost: 3 (minimum), 4-5 for higher security

  • memoryCost: 65536 (64MB minimum), 131072 (128MB) for higher security

  • parallelism: 4 (good balance), 1-8 depending on hardware

  • variant: 'id' (recommended), 'i' for side-channel resistance, 'd' for speed

bcrypt

  • rounds: 12 (minimum), 14-16 for higher security

PBKDF2

  • iterations: 100000 (minimum), 200000+ for higher security

  • hash: 'sha256' (recommended), 'sha512' for higher security

Last updated