Encryption Algorithms

Introduction to Encryption

Encryption is the process of converting plaintext into ciphertext to protect data confidentiality. Encryption algorithms are fundamental to modern cybersecurity, enabling secure communication, data protection, and privacy. Understanding encryption algorithms is crucial for anyone working with secure systems, cryptography, or data protection.

This chapter covers popular cryptographic algorithms, each serving different purposes:

  • Symmetric Encryption: AES, DES — same key for encryption and decryption
  • Asymmetric Encryption: RSA — different keys for encryption and decryption
  • Hash Functions: SHA, MD5 — one-way functions for integrity and fingerprinting

A note on terminology: hash functions are not encryption. Encryption is reversible and takes a key; hashing is neither. They are grouped here because they are cryptographic primitives you will use together, not because hashing is a kind of encryption. Confusing the two leads directly to the mistake of "encrypting" passwords, or expecting to recover data from a hash.

Encryption Algorithms

1. AES (Advanced Encryption Standard)

A symmetric encryption algorithm that is the current standard for encrypting data. It's fast, secure, and widely used in modern applications.

  • Type: Symmetric Block Cipher
  • Key Sizes: 128, 192, 256 bits
  • Block Size: 128 bits
  • Best For: General-purpose encryption, data protection

2. RSA (Rivest-Shamir-Adleman)

An asymmetric algorithm whose security rests on the difficulty of factoring a large composite number back into its two prime factors. Used for digital signatures and certificates.

  • Type: Asymmetric Public-Key
  • Key Sizes: 2048 minimum, 3072+ preferred (1024 is disallowed)
  • Security: Based on integer factorization — broken by Shor's algorithm
  • Best For: Digital signatures and certificates (not key exchange — see below)

3. DES (Data Encryption Standard)

A symmetric encryption algorithm that was the standard for many years but is now considered obsolete due to its small key size. Still studied for historical and educational purposes.

  • Type: Symmetric Block Cipher
  • Key Size: 56 bits (now insecure)
  • Block Size: 64 bits
  • Status: Deprecated, replaced by AES

4. SHA (Secure Hash Algorithm)

A family of cryptographic hash functions that produce fixed-size digests. Used for integrity verification, digital signatures, and key derivation.

  • Type: Cryptographic Hash Function
  • Variants: SHA-1 (retired), SHA-2 family, SHA-3 family, SHAKE
  • Output Size: 160–512 bits, or extendable (SHAKE)
  • Best For: Data integrity, digital signatures, HMAC. Not password storage — use Argon2id.

5. MD5 (Message Digest 5)

A widely-used hash function that produces a 128-bit hash value. While fast, it's now considered cryptographically broken and should not be used for security purposes.

  • Type: Cryptographic Hash Function
  • Output Size: 128 bits
  • Status: Cryptographically broken
  • Use: Non-security applications, checksums

Algorithm Comparison

Algorithm Type Key/Hash Size Security Level Use Case
AES Symmetric 128-256 bits High Data encryption
RSA Asymmetric 2048+ bits High (classical only) Signatures, certificates
DES Symmetric 56 bits Low (deprecated) Historical/educational
SHA Hash Function 256-512 bits High Data integrity, signatures, HMAC
MD5 Hash Function 128 bits Broken Non-security checksums

Primitives This Chapter Does Not Cover

The five algorithms above are the classics, but a working system in 2026 needs several primitives that are not among them. They are listed here so you know what to go and read about:

  • Elliptic-curve cryptography (ECC): ECDSA and Ed25519 for signatures, ECDH/X25519 for key agreement. Far smaller keys than RSA for equivalent security — a 256-bit curve matches 3072-bit RSA — and much faster.
  • Diffie-Hellman key agreement: how two parties derive a shared secret over a public channel. Ephemeral DH (DHE/ECDHE) is what gives modern TLS its forward secrecy.
  • ChaCha20-Poly1305: an AEAD stream cipher, faster than AES on hardware without AES-NI. Widely used in TLS and in WireGuard.
  • HMAC: the correct way to authenticate a message with a shared secret and a hash function. Never hand-roll H(secret || message).
  • Key derivation functions: HKDF for deriving keys from existing key material; Argon2id, scrypt or bcrypt for deriving keys from passwords. These are not interchangeable.

Post-Quantum Cryptography

Every asymmetric algorithm on this page — RSA, and the elliptic-curve schemes above — rests on a problem that a sufficiently large quantum computer solves efficiently. Shor's algorithm factors integers and computes discrete logarithms in polynomial time, which breaks RSA, DH, ECDH and ECDSA at every key size. Increasing the key length does not help.

Symmetric cryptography is far less affected. Grover's algorithm gives only a quadratic speedup on brute-force search, so it notionally halves effective key length: AES-256 retains about 128 bits of security, and SHA-256 remains sound. This is the main reason AES-256 is now preferred over AES-128 for long-lived data.

The threat is not purely future-tense. Harvest-now-decrypt-later means an adversary can record encrypted traffic today and decrypt it once quantum hardware arrives — so anything that must stay confidential for a decade or more is already at risk.

The standards

NIST finalized its first post-quantum standards in August 2024, after an eight-year public competition:

Standard Algorithm Purpose Based On
FIPS 203 ML-KEM (formerly Kyber) Key encapsulation — replaces ECDH/RSA key transport Module lattices
FIPS 204 ML-DSA (formerly Dilithium) Digital signatures — the general-purpose choice Module lattices
FIPS 205 SLH-DSA (formerly SPHINCS+) Digital signatures — conservative, hash-based backup Hash functions only
Draft HQC Backup KEM, selected March 2025 Error-correcting codes

Two standards for signatures is deliberate. ML-DSA is efficient but lattice-based, like ML-KEM; if lattice assumptions were ever broken, SLH-DSA depends only on hash functions and would survive.

What this means in practice

  • It has already started. Chrome and Firefox have defaulted to the hybrid key-exchange group X25519MLKEM768 since 2024–25. "Hybrid" means classical X25519 and post-quantum ML-KEM are both run and their secrets combined, so the connection is safe unless both are broken. Your browser is very likely negotiating this right now.
  • Timelines are set. NIST IR 8547 (draft) proposes deprecating RSA-2048 and 256-bit ECC after 2030 and disallowing them after 2035. NSA's CNSA 2.0 suite requires post-quantum algorithms for national security systems on a similar schedule.
  • Key exchange first, signatures later. Key exchange is urgent because of harvest-now-decrypt-later. Signatures are less urgent — a signature forged in 2040 cannot retroactively compromise a 2026 session — but certificate chains take years to migrate.
  • Do not roll your own. Use your TLS library's PQ support rather than implementing lattice cryptography.

Algorithm Selection Guide

For encrypting data:

  • Use AES-256-GCM, or ChaCha20-Poly1305 where AES hardware acceleration is unavailable. Both are AEAD modes — they authenticate as well as encrypt.
  • To encrypt something larger than a few hundred bytes with a public key, use hybrid encryption: encrypt the data with AES and encrypt only the AES key asymmetrically.

For key exchange:

  • Use ECDHE / X25519, ideally the hybrid post-quantum group X25519MLKEM768.
  • Do not use RSA key transport. TLS 1.3 removed it because it provides no forward secrecy: one compromised private key exposes every recorded past session.

For digital signatures:

  • Ed25519 for new designs; RSA-PSS (3072-bit or larger) where RSA is required for interoperability.
  • Plan a migration path to ML-DSA.

For hashing and integrity:

  • Use SHA-256 or SHA-3. Use HMAC, not a bare hash, whenever a secret key is involved.
  • Avoid MD5 and SHA-1 for anything an adversary can influence.

For passwords:

  • Use Argon2id, scrypt, or bcrypt. Never SHA-256, salted or otherwise — general-purpose hashes are far too fast for this job.

For legacy systems:

  • DES and 3DES are disallowed and should only ever be decrypted, never used to encrypt new data.

What's Next?

Now that you understand encryption algorithms, explore related topics: