Section 1: Introduction to Cryptography
Welcome. Before you can break a Vigenère cipher, factor an RSA modulus, or understand why your bank trusts a padlock icon, you need the foundations. This section defines what cryptography actually is, walks through four thousand years of codemaking and codebreaking, and arms you with the vocabulary you will use for the rest of this course.
What is cryptography?
Cryptography is the science of protecting information by transforming it into a form that adversaries cannot read, forge, or tamper with — while legitimate parties, who hold the right keys, can. The word comes from the Greek kryptós (hidden) and graphein (to write): literally, "hidden writing". Its counterpart is cryptanalysis, the art of defeating those protections. Together they form cryptology, and their perpetual duel is the engine that has driven the field for millennia.
A common misconception is that cryptography is only about secrecy. Modern cryptography actually pursues four distinct goals, and most real systems need several of them at once:
- Confidentiality — keeping data secret from anyone who is not authorized to read it. When you send a message over Signal, an eavesdropper on the Wi-Fi sees only ciphertext: a stream of bytes that is computationally indistinguishable from random noise. Encryption algorithms like AES provide this.
- Integrity — guaranteeing data has not been altered, accidentally or maliciously, in transit or in storage. If an attacker flips a single bit of a wire-transfer instruction ("send $100" becomes "send $900"), the recipient must be able to detect it. Cryptographic hash functions and message authentication codes (MACs) provide this.
- Authentication — proving that a message really comes from who it claims to come from, or that a party on the other end of a connection really is your bank and not an impostor. Passwords, MACs, digital certificates, and challenge-response protocols provide this.
- Non-repudiation — preventing the sender from later denying they sent a message. If you digitally sign a contract, you cannot plausibly claim someone else did it, because only your private key could have produced that signature. Digital signatures (RSA, ECDSA, Ed25519) provide this. Note the subtle difference from authentication: a shared-key MAC convinces you the message came from your partner, but it cannot convince a judge, because you could have forged it yourself — you both hold the same key.
| Goal | Question it answers | Example mechanism |
|---|---|---|
| Confidentiality | Can anyone else read this? | AES encryption, TLS |
| Integrity | Was this modified in transit? | SHA-256 hash, HMAC |
| Authentication | Am I really talking to who I think? | Certificates, HMAC, passwords |
| Non-repudiation | Can the sender deny sending it? | Digital signatures (RSA, ECDSA) |
A brief history: four thousand years of secrets
Cryptography is as old as writing itself, and its history is best read as an arms race. Every time codemakers invented a stronger cipher, codebreakers eventually found a crack; every crack forced a stronger design. For most of history the codebreakers held the upper hand — nearly every cipher devised before the twentieth century was eventually broken, often with dramatic consequences for empires and wars. Only in the modern era, with mathematics rather than cleverness as the foundation, did the defenders finally pull ahead.
- ~1900 BC An Egyptian scribe in the town of Menet Khufu carves non-standard hieroglyphs into a nobleman’s tomb — the earliest known deliberate transformation of writing, likely more for dignity and mystery than secrecy, but substitution nonetheless.
- ~500 BC Spartan generals use the scytale: a strip of leather wound around a rod of specific diameter. Written along the rod and unwound, the letters scramble — an early transposition cipher. Only a rod of matching diameter restores the message.
- ~58 BC Julius Caesar shifts every letter of his military dispatches three places down the alphabet. The Caesar cipher is trivially weak today, but in a world where most enemies could not read at all, it worked.
- 9th century The Arab polymath Al-Kindi writes the first known description of frequency analysis: in any language, some letters appear far more often than others, and a simple substitution cipher preserves those statistics. This single insight breaks every monoalphabetic cipher and stands as the birth of scientific cryptanalysis.
- 1553 Giovan Battista Bellaso publishes the polyalphabetic cipher later misattributed to Blaise de Vigenère. By cycling through multiple shift alphabets under a keyword, the Vigenère cipher flattens letter frequencies and earns the nickname le chiffre indéchiffrable — the indecipherable cipher. It resists attack for three centuries until Kasiski and Babbage crack it in the 1800s.
- 1840s–1900s The telegraph makes long-distance communication instant — and instantly interceptable, since messages pass through the hands of operators and over tappable wires. Commercial codes and cipher machines proliferate; cryptography stops being purely a military art.
- 1917 British codebreakers in Room 40 decrypt the Zimmermann telegram, in which Germany secretly offers Mexico an alliance against the United States. Its publication helps propel America into World War I — perhaps the single most consequential decryption in history.
- 1939–1945 Germany trusts the electromechanical Enigma machine, with its rotors and plugboard offering some 1020 settings. Building on Polish breakthroughs by Marian Rejewski, Alan Turing and the codebreakers of Bletchley Park mechanize the attack with the Bombe. Historians estimate the intelligence shortened the war in Europe by two or more years — and the effort helped invent the computer itself.
- 1949 Claude Shannon publishes Communication Theory of Secrecy Systems, turning cryptography from craft into mathematics. He proves the one-time pad is unbreakable, defines perfect secrecy, and introduces the concepts of confusion and diffusion that guide cipher design to this day.
- 1976 Whitfield Diffie and Martin Hellman publish New Directions in Cryptography, showing two strangers can agree on a shared secret over a public channel — public-key cryptography is born, solving the ancient key-distribution problem.
- 1977 Two milestones: the US standardizes DES, the first public, government-blessed cipher, giving academia a common target to study; and Rivest, Shamir, and Adleman publish RSA, the first practical public-key encryption and signature system, resting on the difficulty of factoring large numbers.
- 2001 After an open worldwide competition, NIST standardizes Rijndael as AES, the Advanced Encryption Standard. Two decades later it still protects everything from Wi-Fi to state secrets, unbroken.
- 2009 The pseudonymous Satoshi Nakamoto launches Bitcoin, assembling hash functions, digital signatures, and proof-of-work into the first decentralized digital currency — cryptography as the foundation of money itself.
- 2024 NIST publishes its first post-quantum cryptography standards (ML-KEM and ML-DSA, from the Kyber and Dilithium designs), beginning the global migration to algorithms that resist attack by future quantum computers running Shor’s algorithm.
Notice the pattern: the scytale fell to anyone with a set of rods; Caesar fell to literacy; simple substitution fell to Al-Kindi’s statistics; Vigenère fell to Kasiski; Enigma fell to mathematics plus machinery plus German operator mistakes. Each generation of codemakers believed their cipher unbreakable, and each was eventually wrong. Modern cryptography breaks this cycle by doing something new: instead of hoping a scheme is strong, it reduces security to well-studied mathematical problems and invites the entire world to attack the designs in the open, for decades, before trusting them.
Why cryptography matters today
You used cryptography dozens of times today without noticing. That invisibility is the point — but it is worth seeing where it hides:
- HTTPS and online banking. Every padlocked connection runs TLS: an ephemeral Diffie-Hellman key exchange, certificate-based authentication of the server, then AES encryption of everything you send. Without it, your passwords and card numbers would cross the network in the clear, readable by every router in between.
- Secure messaging. Signal and WhatsApp use end-to-end encryption (the Signal protocol): messages are encrypted on your phone and decrypted only on the recipient’s. Not even the service operator can read them, and forward secrecy means stealing a key today does not expose yesterday’s conversations.
- Disk and device encryption. BitLocker, FileVault, and LUKS encrypt your storage with AES so a stolen laptop is a brick of random bytes rather than your entire life. Your smartphone does the same by default.
- Software signing. When your OS installs an update, it verifies a digital signature first. Without that check, anyone who could intercept the download could hand you malware wearing the update’s clothes — exactly the supply-chain attack signatures exist to stop.
- Blockchain and cryptocurrency. Bitcoin and Ethereum are cryptography end to end: ECDSA signatures prove you own coins, SHA-256 hashes chain the blocks together, and Merkle trees let anyone verify a transaction is included without downloading everything.
- Passports and smartcards. The chip in your e-passport signs its data so borders can detect forgeries; your bank card performs a challenge-response protocol at every terminal so cloning the magnetic stripe is no longer enough.
In short: modern commerce, privacy, journalism, medicine, and government all sit on a cryptographic foundation. When it fails — through weak algorithms, bad implementations, or stolen keys — the consequences are measured in breached hospitals, drained accounts, and endangered lives.
Kerckhoffs’s principle: no security through obscurity
A cryptosystem must remain secure even if everything about it except the key falls into enemy hands. In Auguste Kerckhoffs’s words, the system "must not require secrecy, and it must be able to fall into the hands of the enemy without inconvenience." Claude Shannon later restated it bluntly: "the enemy knows the system."
Why insist on this? Because algorithms are hard to keep secret — they get reverse-engineered, leaked by insiders, or captured (the Allies pulled Enigma machines out of sinking U-boats). A key, by contrast, is small, easy to change, and easy to replace if compromised. History has repeatedly punished designers who relied on secret algorithms: proprietary ciphers in DVDs (CSS), GSM phones (A5/1), and contactless cards (MIFARE Crypto-1) were all reverse-engineered and broken. Every algorithm you will meet in this course — AES, SHA-256, RSA — is fully public, studied by thousands of researchers, and secure anyway. That open scrutiny is precisely why we trust them.
Essential terminology
These terms recur throughout the course. Skim them now, and come back whenever you need a refresher.
- plaintext
- The original, readable message before encryption. Also called cleartext.
- ciphertext
- The scrambled output of encryption — unintelligible without the key.
- cipher
- An algorithm (a pair of procedures) for encrypting and decrypting data.
- key
- The secret parameter that controls a cipher. Same algorithm, different key, completely different output. Security lives here, per Kerckhoffs.
- keyspace
- The set of all possible keys. A Caesar cipher has a keyspace of 25; AES-128 has 2128 ≈ 3.4 × 1038. Bigger keyspace means brute force takes longer.
- encryption
- Transforming plaintext into ciphertext under a key.
- decryption
- The reverse: recovering plaintext from ciphertext using the key.
- hash
- A fixed-size "fingerprint" of arbitrary data, computed by a one-way function such as SHA-256. Easy to compute, infeasible to invert or to find two inputs with the same output.
- symmetric cryptography
- Schemes where the same key encrypts and decrypts (AES, ChaCha20). Fast, but both parties must somehow share the key first.
- asymmetric cryptography
- Schemes with a key pair: a public key anyone may see and a private key only the owner holds (RSA, elliptic curves). Solves key distribution and enables digital signatures.
- nonce
- A "number used once" — a value that must never repeat under the same key, used to make each encryption unique. Reusing a nonce can be catastrophic.
- IV (initialization vector)
- A starting value fed into a cipher mode so that encrypting the same plaintext twice yields different ciphertexts. Closely related to a nonce; usually random or unique per message.
- salt
- A random value mixed into password hashing so identical passwords produce different hashes, defeating precomputed rainbow-table attacks.
- cryptanalysis
- The study of breaking cryptographic systems — recovering plaintext or keys without authorization. The codebreaker’s half of cryptology.
- brute force
- The attack of last resort: trying every key in the keyspace until one works. Defeated by making the keyspace astronomically large.
- protocol
- A precisely defined sequence of messages and computations between parties — such as TLS or Signal — that combines cryptographic primitives to achieve security goals. Most real-world failures happen at the protocol level, not inside the primitives.
Your first encryption
Enough theory — encrypt something. The widget below implements the Caesar cipher: every letter slides a fixed number of positions down the alphabet, wrapping from Z back to A. Type a message and drag the slider. Watch what happens at shift 0 and shift 13, and ask yourself: if an attacker knows this is a Caesar cipher, how many guesses do they need at most? (You will formalize the answer — and break this cipher automatically — in Section 3.)
Check your understanding
Where to learn more
These are the resources this course draws on most, and the ones worth your time first. All are free except the books.
Next up: Section 2 — Mathematical Foundations, where you will pick up the modular arithmetic that powers everything from Caesar to RSA.