What is cryptography?
Cryptography comes from the Greek kryptós (hidden) and graphein (to write). It is the practice of protecting information so that only the intended people can read it or trust it. Three related terms come up often:
- Cryptography: designing systems that protect information.
- Cryptanalysis: breaking or finding weaknesses in those systems.
- Cryptology: the field that covers both.
The basic idea hasn't changed in 2,500 years. Readable plaintext goes through an algorithm that is controlled by a secret key, and comes out as unreadable ciphertext. Anyone with the right key can reverse the process. Anyone without it should learn nothing.
What cryptography gives us
Security people often say "CIA": Confidentiality, Integrity and Availability. Cryptography covers the first two directly and adds two more of its own: authentication and non-repudiation. It does very little for availability.
| Goal | Question it answers | Typical tool |
|---|---|---|
| Confidentiality | Can anyone else read this? | Encryption (AES, ChaCha20) |
| Integrity | Has this been changed? | Hashes, MACs (SHA-256, HMAC) |
| Authentication | Who am I talking to? Did this come from them? | MACs, digital signatures, certificates |
| Non-repudiation | Can the sender deny sending it? | Digital signatures (only the private-key holder could have signed it) |
Kerckhoffs's principle
In 1883 Auguste Kerckhoffs set out a rule that still shapes all serious cryptography:
So the algorithm is public and only the key is secret. That's why AES, RSA and TLS are published standards that anyone can study and attack. An algorithm that has survived decades of public cryptanalysis earns far more trust than a secret one. Keeping the design secret, known as security through obscurity, tends to fall apart as soon as someone reverse-engineers the product. The MIFARE Classic transport cards and the GSM A5/1 cipher are well-known examples.
A practical consequence is never roll your own crypto. Use well-reviewed libraries and standard protocols.
The three families
🔑 Symmetric
One shared secret key is used to encrypt and decrypt. It's fast and suited to bulk data. The hard part is getting the key to the other person safely.
Examples: AES, ChaCha20, (3)DES
🔑🔑 Asymmetric (public-key)
Each person has a key pair: a public key that can be shared with anyone and a private key they keep. It solves key distribution and enables signatures, but it's slow.
Examples: RSA, Diffie-Hellman, ECC, ML-KEM
#️⃣ Hashing
A one-way function that turns any input into a fixed-size fingerprint. There's no key and no way back to the input. It's used for integrity and password storage.
Examples: SHA-256, SHA-3, (MD5, SHA-1, both broken)
Real systems use all three together. This is called a hybrid cryptosystem. Asymmetric crypto agrees or exchanges a symmetric key, symmetric crypto encrypts the actual data, and hashes or MACs protect integrity. Every TLS connection, and so every HTTPS web page, works this way.
For n people who all want to talk privately, symmetric crypto needs n(n−1)/2 keys. With 1,000 users that's 499,500 keys. Asymmetric crypto needs just 2n (2,000). This is a popular exam question.
Encoding vs encryption vs hashing
People often confuse these three. Type something below and click Run a few times to see how each one behaves.
Encoding (Base64): no key, anyone can reverse it
Encryption (AES-256-GCM, fresh random key and IV each time)
Reversible only with the key:
Hashing (SHA-256): same input always gives the same output, and it can't be reversed
| Purpose | Key? | Reversible? | |
|---|---|---|---|
| Encoding | Format data for transport (email, URLs) | No | Yes, by anyone |
| Encryption | Confidentiality | Yes | Yes, with the key |
| Hashing | Integrity, fingerprints, password storage | No (a MAC adds one) | No |
How attackers approach crypto
Cryptanalysts group attacks by what the attacker has to work with:
- Brute force: try every key. You defeat it with a big enough key space (Chapter 02).
- Ciphertext-only: the attacker has only ciphertext. Frequency analysis against classical ciphers is the classic example.
- Known-plaintext: the attacker has some plaintext and ciphertext pairs. Bletchley's "cribs" against Enigma worked this way.
- Chosen-plaintext / chosen-ciphertext: the attacker can get chosen messages encrypted or decrypted. Padding-oracle attacks are an example.
- Side-channel: the attacker measures timing, power draw, electromagnetic leakage or cache behaviour instead of attacking the maths.
- Implementation and protocol attacks: bugs and downgrades such as Heartbleed, POODLE and KRACK. Most real-world breaks fall into this group.
- Rubber-hose cryptanalysis: coercing the key-holder. People are usually the weakest link.