🔐

Cryptography Implementations

2024 — Security Fundamentals from Scratch

About

Pure Python implementations of classic cryptographic algorithms — no libraries, just math. Built to deeply understand how encryption, hashing, and security primitives work at the bit level. Try them live below!

🎮 Live Demos

🔤 Vigenère Cipher

Classical polyalphabetic substitution cipher

Encrypted:

ZINCSPGVNU

How it works

C[i] = (M[i] + K[i]) mod 26 — each letter shifts by the key letter's position

#️⃣ SHA-512 Hash

Cryptographic hash function (512-bit output)

SHA-512 Hash:

2c74fd17edafd80e8447b0d46741ee243b7eb74dd2149a0ab1b9246fb30382f27e853d8585719e0e67cbda0daa8f51671064615d645ae27acb15bfb1447f459b

How it works

80 rounds of compression using σ, Σ, Ch, Maj operations on 64-bit words. One-way function — can't reverse!

🔒 AES-128 Encryption

Industry-standard symmetric cipher (enter hex values)

Ciphertext:

29c3505f571420f6402299b31a02d73a

How it works

10 rounds of SubBytes (S-box), ShiftRows, MixColumns (GF(2⁸) math), and AddRoundKey with key expansion

Implementation Details

Vigenère Cipher

Polyalphabetic substitution where each letter is shifted by the corresponding key letter. Key repeats to match message length.

Symmetric Classical

AES-128

Block cipher with 128-bit key. Implements S-box substitution, row shifting, column mixing in GF(2⁸), and round key addition across 10 rounds.

10 Rounds S-Box GF(2⁸) Key Expansion

SHA-512

Cryptographic hash with 512-bit output. Uses message padding, 80-round compression with bitwise σ, Σ, Ch, Maj operations on 64-bit words.

80 Rounds 512-bit One-Way

What I Learned

  • • Bitwise operations and their role in security (XOR, rotations, shifts)
  • • Galois Field arithmetic (GF(2⁸)) for AES MixColumns
  • • Why padding schemes matter (length extension attacks)
  • • The difference between encryption (reversible) and hashing (one-way)
  • • How modern ciphers achieve confusion and diffusion