All ArticlesSecurity & Privacy

Modern Cryptography for Web Developers: AES-GCM, Bcrypt, and Salt Security

DevStackTools Security
2026-02-14
8 min read

Try the Interactive Tool

Test and validate client-side with zero data uploads.

Open AES Encryption

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

  • **AES-CBC (Cipher Block Chaining):** Provides confidentiality only. It does NOT provide data integrity or authenticity. If an attacker modifies the ciphertext in transit, decryption will produce corrupted plaintext or expose padding oracle vulnerabilities (e.g. POODLE attack).
  • **AES-GCM (Authenticated Encryption):** Computes an authentication tag (Auth Tag) alongside ciphertext. Decryption fails immediately if a single bit of the ciphertext or initialization vector (IV) was tampered with.
  • typescript
    // 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)**:

  • Each increment of the work factor doubles the computational effort required to compute the hash.
  • Salt (random bits prepended to the password) prevents precomputed rainbow table lookups.
  • Test your password hashes and work factors client-side with our [Bcrypt Generator](/security/bcrypt-generator) and [Bcrypt Verifier](/security/bcrypt-verifier).

    Found this guide helpful?

    Explore our 50+ privacy-first developer utility tools.

    Explore Tools