No recently used tools
Loading categories...
Derive cryptographic keys from passwords using PBKDF2 (Password-Based Key Derivation Function 2). Supports HMAC-SHA1, SHA256, SHA384, SHA512 with configurable iterations and key length. RFC 2898 / PKCS#5 compliant. No passwords stored.
PBKDF2 derives a cryptographic key from a password by applying a pseudorandom function (typically HMAC) with a salt, repeating the process many times to increase the computational cost of brute-force attacks.
DK = PBKDF2(PRF, Password, Salt, c, dkLen)
| Algorithm | Memory-Hard | GPU Resistant | Standard | Recommendation |
|---|---|---|---|---|
| PBKDF2 | No | Low | RFC 2898 | Legacy / FIPS compliance |
| BCrypt | 4KB | Medium | De facto | Still acceptable |
| Scrypt | Yes | High | RFC 7914 | Good choice |
| Argon2id | Yes (configurable) | High | RFC 9106 | Best for new apps |
| Algorithm | Min Iterations | Notes |
|---|---|---|
| PBKDF2-HMAC-SHA1 | 1,300,000 | Legacy, avoid for new apps |
| PBKDF2-HMAC-SHA256 | 600,000 | Recommended default |
| PBKDF2-HMAC-SHA512 | 210,000 | Faster on 64-bit systems |
# Generate random salt
salt = os.urandom(16)
# Derive key using PBKDF2-HMAC-SHA256
password = b"secret"
key = hashlib.pbkdf2_hmac(
'sha256', password, salt,
iterations=600000, dklen=32
)
print(f"Key: {key.hex()}")
print(f"Salt: {salt.hex()}")// Generate salt
byte[] salt = new byte[16];
new SecureRandom().nextBytes(salt);
// Derive key
PBEKeySpec spec = new PBEKeySpec(
"password".toCharArray(), salt, 600000, 256
);
SecretKeyFactory f = SecretKeyFactory
.getInstance("PBKDF2WithHmacSHA256");
byte[] key = f.generateSecret(spec).getEncoded();'crypto');
// Generate salt
const salt = crypto.randomBytes(16);
// Derive key (async)
crypto.pbkdf2(
'password', salt, 600000, 32, 'sha256',
(err, key) => {
console.log(`Key: ${key.toString('hex')}`);
}
);
// Synchronous version
const key = crypto.pbkdf2Sync(
'password', salt, 600000, 32, 'sha256'
);"crypto/sha256"
"golang.org/x/crypto/pbkdf2"
"crypto/rand"
)
// Generate salt
salt := make([]byte, 16)
rand.Read(salt)
// Derive 32-byte key
key := pbkdf2.Key(
[]byte("password"), salt,
600000, 32, sha256.New,
)# Derive 256-bit key using PBKDF2-HMAC-SHA256 (OpenSSL 3.0+)
openssl kdf -keylen 32 \
-kdfopt digest:SHA256 \
-kdfopt pass:password \
-kdfopt salt:hex:0102030405060708 \
-kdfopt iter:600000 PBKDF2
# Using enc command (older OpenSSL)
openssl enc -aes-256-cbc -pbkdf2 -iter 600000 \
-salt -in plain.txt -out encrypted.binhashlib module: import hashlib, os; password = b'secret'; salt = os.urandom(16); key = hashlib.pbkdf2_hmac('sha256', password, salt, iterations=600000, dklen=32). The derived key is 32 bytes suitable for AES-256 encryption.