0Pricing
Cryptology Academy · Lesson

PBKDF2 & Choosing the Right Algorithm

Compare PBKDF2 with bcrypt/Argon2 and select the best for your app.

PBKDF2 & Choosing the Right Algorithm is a free Cryptology Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cryptology Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Welcome

In this final beginner lesson, we study PBKDF2, compare it to bcrypt and Argon2, and create a decision framework for selecting the right password hashing algorithm.

PBKDF2 Overview

PBKDF2 (Password-Based Key Derivation Function 2) was published in RFC 2898 (2000). It applies a pseudorandom function (typically HMAC-SHA256) iteratively to the password + salt.

PBKDF2 Formula

PBKDF2(PRF, password, salt, iterations, keylen) Example: key = PBKDF2-HMAC-SHA256(password, salt, 600000, 32) OWASP recommends 600,000 iterations with SHA-256 as of 2023.

PBKDF2 in Python

import hashlib, os salt = os.urandom(16) key = hashlib.pbkdf2_hmac( 'sha256', password.encode(), salt, 600000, dklen=32 ) # Or using cryptography library: from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC

PBKDF2 Strengths

FIPS 140-2/3 compliant. Built into Python, Java, .NET standard libraries. Widely deployed in enterprise and government environments. Simple to implement correctly.

PBKDF2 Weaknesses

Not memory-hard. GPU-friendly: billions of SHA-256 iterations/sec. At 600K iterations, GPU still achieves ~1M passwords/sec. bcrypt and especially Argon2 are significantly harder to brute-force.

Algorithm Comparison Table

Algorithm | Memory-Hard | FIPS | Speed (GPU) | Recommendation bcrypt | No | No | 50K/s | Acceptable PBKDF2 | No | Yes | 1M/s | Regulated envs Argon2id | Yes | No | 100/s | Best choice

Decision Framework

Use Argon2id: for new applications without compliance constraints. Use bcrypt: when Argon2 is unavailable, legacy systems. Use PBKDF2-SHA256: FIPS/government compliance required. Never: MD5, SHA-1, SHA-256 without iteration, unsalted anything.

Compliance Notes

PCI-DSS: does not specify algorithm, but requires 'strong' hashing. bcrypt/Argon2 qualify. NIST SP 800-132: approves PBKDF2. Some strict FedRAMP systems mandate PBKDF2 with FIPS-approved PRF.

Iteration Count Evolution

OWASP PBKDF2-SHA256 iterations: 2010: 1000, 2016: 100000, 2023: 600000. Hardware gets faster — revisit and increase every 2 years. bcrypt cost: 2010: 10, 2023: 12, 2025 target: 13.

Secure Password Reset Flow

1. Generate cryptographically random token: secrets.token_urlsafe(32) 2. Hash with SHA-256 (not bcrypt — just for storage) 3. Store hash, send token in email 4. On reset: hash submitted token, compare, expire immediately after use

Quick Check

In which environment is PBKDF2 preferred over Argon2id despite being weaker against GPU attacks?

Recap

You've completed the Beginner Cryptology track! You understand hashes, symmetric/asymmetric encryption, signatures, PKI, and password hashing. Next: intermediate topics — block cipher modes, stream ciphers, and key exchange.

Frequently asked questions

Is the “PBKDF2 & Choosing the Right Algorithm” lesson free?

Yes — the full text of “PBKDF2 & Choosing the Right Algorithm” is free to read here on the web, and the Cryptology Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cryptology Academy course, upgrade to CoddyKit PRO.

What will I learn in “PBKDF2 & Choosing the Right Algorithm”?

Compare PBKDF2 with bcrypt/Argon2 and select the best for your app. You practise Cryptology Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Cryptology Academy?

No prior experience is required. Cryptology Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “PBKDF2 & Choosing the Right Algorithm” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Cryptology Academy lesson?

Yes. Every Cryptology Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Why Plain SHA-256 Fails for Passwords
  2. bcrypt: Algorithm & Cost Factor
  3. Argon2: Memory-Hard Password Hashing
  4. PBKDF2 & Choosing the Right Algorithm
← Back to Cryptology Academy