Modern Cryptography for Web Developers: AES-GCM, Bcrypt, and Salt Security
Try the Interactive Tool
Test and validate client-side with zero data uploads.
Security misconfigurations and deprecated cryptographic algorithms remain prominent vulnerabilities in web applications. Developers frequently confuse encryption (reversible with a key) with hashing (irreversible one-way transformation) or implement flawed padding schemes.
1. Symmetric Encryption: Why AES-GCM is the Modern Standard
When encrypting sensitive data at rest or in transit (e.g. database credentials, customer secrets), **AES-256-GCM (Galois/Counter Mode)** is the recommended standard.
The Danger of AES-CBC vs AES-GCM
// Using standard Web Crypto API for AES-GCM encryption
async function encryptPayload(plaintext: string, rawKey: CryptoKey): Promise<{ ciphertext: ArrayBuffer; iv: Uint8Array }> {
const iv = crypto.getRandomValues(new Uint8Array(12)); // 96-bit IV recommended for GCM
const encoder = new TextEncoder();
const ciphertext = await crypto.subtle.encrypt(
{ name: 'AES-GCM', iv },
rawKey,
encoder.encode(plaintext)
);
return { ciphertext, iv };
}2. Password Hashing: Why SHA-256 is Broken for Passwords
Never use fast cryptographic hash functions like MD5, SHA-1, or plain SHA-256 for passwords. Modern GPUs can calculate over 10 billion SHA-256 hashes per second, making offline dictionary attacks instantaneous.
The Solution: Adaptive Key Derivation (Bcrypt, Argon2)
Adaptive hashing functions introduce a **Work Factor (Cost Parameter)**:
Test your password hashes and work factors client-side with our [Bcrypt Generator](/security/bcrypt-generator) and [Bcrypt Verifier](/security/bcrypt-verifier).