Cryptographic hash functions transform any input into a deterministic fixed-length digest. When the right algorithm is matched to the right task, you gain tamper detection, faster comparisons, and stronger authentication. When the wrong algorithm is chosen, you inherit collision attacks, leaked credentials, and costly remediation. This guide explains how to evaluate the four algorithms WordPress and modern web apps rely on most. For a deeper dive into salting strategy, bookmark our Salt Key Generation Guide once you settle on an algorithm.
Security Properties
- • Deterministic output for identical inputs
- • Avalanche effect after minimal input changes
- • Pre-image and collision resistance at modern key lengths
- • Efficient computation for scalable verification flows
When Hashing Falls Short
- • Fast algorithms expose passwords to brute force
- • Unsalted hashes collapse under rainbow tables
- • Deprecated functions (MD5, SHA-1) enable collisions
- • GPU optimised cracking shreds weak cost factors
MD5: Retire the Legacy
DeprecatedMD5 outputs 128-bit hashes and was once the default for checksums. Collision attacks announced in 2004 made it unsuitable for cryptographic use. Today MD5 belongs strictly in legacy checksum workflows—never in password storage or TLS certificate signing.
# MD5 collision demonstration (Python)
import hashlib
def md5(data):
return hashlib.md5(data).hexdigest()
print(md5(b"4d657373616765"))
print(md5(b"4d657373616765!"))
# Practically identical inputs, drastically different digests
Risks
- • Easily forged collisions
- • Public rainbow tables
- • Deprecated by NIST and browser vendors
- • No built-in salting support
Safer Alternatives
- • Use SHA-256 for integrity checks
- • Choose bcrypt or Argon2 for credentials
- • Apply HMACs for tamper resistant checksums
- • Leverage unique salts and peppering
SHA-256: Integrity Powerhouse
High IntegritySHA-256 is part of the SHA-2 family and produces a 256-bit digest. It powers TLS certificates, blockchain ledgers, Git versioning, and API signatures. While it is collision resistant, SHA-256 is intentionally fast, so pair it with salts and key stretching (PBKDF2, bcrypt, Argon2) before touching credential workflows.
# Python SHA-256 checksum
import hashlib, pathlib
FILE_PATH = pathlib.Path("backup.zip")
with FILE_PATH.open('rb') as fh:
checksum = hashlib.sha256(fh.read()).hexdigest()
print(f"SHA-256: {checksum}")
Ideal Use Cases
- • File integrity validation
- • API request signing
- • Blockchain merkle trees
- • Digital signatures with HMAC
Implementation Notes
- • Combine with random salt for passwords
- • Add iteration count via PBKDF2
- • Monitor quantum computing developments
- • Audit libraries for timing attack mitigations
bcrypt: Proven Password Workhorse
High Securitybcrypt is purpose-built for password storage. It bundles per-user salts, adaptive cost factors, and Blowfish-derived cryptography to keep cracking costs high. Adjust the cost each year to slow attackers without slowing sign-ins excessively.
# Node.js bcrypt workflow
import bcrypt from 'bcrypt';
const cost = 12;
const password = 'SuperSecret#2025';
const hash = await bcrypt.hash(password, cost);
const isValid = await bcrypt.compare(password, hash);
console.log(isValid); // true
Configuration Checklist
- • Set cost to 12–14 for public sites
- • Rotate cost annually based on benchmarks
- • Store only the bcrypt hash string
- • Protect secrets with application-level peppering
When bcrypt Excels
- • WordPress login hardening
- • Customer portals and SaaS platforms
- • Line-of-business apps with regulated data
- • Projects needing mature library support
Argon2: Modern Zero-Trust Default
Very High SecurityArgon2, winner of the Password Hashing Competition, delivers memory-hard password hashing that frustrates GPU and ASIC cracking rigs. Argon2id—the hybrid mode—is recommended for most web applications thanks to its defense against both side-channel attacks and brute force.
Argon2d
GPU-resistant and fast, ideal for key derivation in controlled environments.
Argon2i
Side-channel resistant; reads memory in a password-independent pattern.
Argon2id
Hybrid approach blending Argon2i + Argon2d for balanced security—recommended default.
# PHP Argon2id example (requires PHP 7.2+)
$password = 'MyStrongP@ssw0rd';
$options = [
'memory_cost' => 1<<17, // 128 MB
'time_cost' => 4,
'threads' => 2,
];
$hash = password_hash($password, PASSWORD_ARGON2ID, $options);
$verified = password_verify($password, $hash);
Deployment Guidance
- • Allocate at least 64–128 MB memory per hash on production hardware
- • Set time cost 3–5 for public WordPress sites, higher for admin portals
- • Monitor latency under load testing to balance UX and security
- • Document rotation plans in your password policy playbook
Algorithm Comparison Matrix
Quickly weigh performance, security posture, and recommended use cases.
MD5
Speed: 1x (very fast)
Security: Deprecated
Use: Legacy checksums only
SHA-256
Speed: 1.7x
Security: High for integrity
Use: Signatures, file validation
bcrypt
Speed: Adjustable (cost)
Security: High for passwords
Use: User credential storage
Argon2id
Speed: Tunable with memory + time
Security: Very high
Use: Passwords, zero-trust apps
Decision Tree
- Need fast integrity checks? Use SHA-256 with optional HMAC.
- Migrating away from MD5? Run both algorithms during transition then deprecate MD5.
- Securing WordPress logins? Choose bcrypt (cost ≥ 12) or Argon2id for modern PHP builds.
- Protecting admin or API credentials? Argon2id with high memory cost and peppering is ideal.
Implementation Patterns You Can Trust
Migration Checklist
- Inventory current hashing algorithm and salt strategy.
- Create dual verification that accepts old + new hashes.
- Force rehash on next login or scheduled rotation.
- Store algorithm metadata alongside hash for future proofing.
- Document steps inside your Password Hash governance plan.
WordPress Integration Tips
- • Use
password_hash()
andpassword_verify()
for PHP 7.2+ - • Enable SSL everywhere to protect hashes in transit
- • Combine with application firewalls and rate limiting
- • Monitor `/wp-login.php` with anomaly detection
- • Regularly rotate salts (step-by-step instructions)
Hardening Checklist
- ☑ Enable MFA for privileged logins
- ☑ Enforce 12+ character passphrases
- ☑ Store application pepper outside codebase
- ☑ Log and alert on repeated hash verification failures
- ☑ Run quarterly penetration tests
- ☑ Document incident response for compromised hashes
- ☑ Benchmark hashing cost during capacity planning
- ☑ Update sitemap after adding new security resources
FAQ: Hashing Algorithm Decisions
Can I mix hashing algorithms?
Yes—store hashes with algorithm identifiers. During migrations, accept the legacy format and rehash with bcrypt or Argon2id once the user authenticates successfully.
Is SHA-256 enough for WordPress passwords?
Not by itself. Combine it with salting and a slow key-derivation function. WordPress core already uses password_hash()
which defaults to bcrypt—stick with that or upgrade to Argon2id where supported.
When should I pick Argon2 over bcrypt?
Choose Argon2id when you control the hosting environment and can dedicate memory to hashing. For shared hosting or legacy PHP, bcrypt remains a solid choice.
Key Takeaways
- • MD5 is only suitable for legacy checksum verification—never for storing credentials.
- • SHA-256 secures integrity workflows but requires extra hardening for password storage.
- • bcrypt and Argon2id are the only practical options for production WordPress passwords in 2025.
- • Cost factors, salts, peppers, and monitoring complete your defensive posture.