Free online courseInteractive · No sign-up · Works offline once loaded

CTF crypto for beginners

Your first steps in the crypto category of Capture the Flag. Interactive lessons show how text becomes bytes, how to spot and peel layers of encoding, how to break classical ciphers and how XOR keys give themselves away.

  • Beginner
  • 7 chapters
  • 17 interactive lessons
  • About 30 minutes
  • English
  • Updated November 2026
Start the course 17 lessons · about 30 min · free
What a CTF is Lesson 1 of 17

Chapter 1: What a CTF is

Lesson 1.1 · What a CTF is

Find the flag

A CTF challenge hides a secret string, the flag. It has a fixed format, like flag{…}, CTF{…} or picoCTF{…}.

You find it, paste it into the scoreboard and get points. In crypto challenges the flag is often wrapped in several layers you have to peel off, one after another.

NzM3OTZlNzQ3YjYzNzI3Mjc5NWY3MjY5Nz… 73796e747b637272795f726972… synt{crry_rirel_ynlre} flag{peel_every_layer}
Lesson 1.2 · What a CTF is

Five kinds of challenges

Most beginner events are Jeopardy style: a board of challenges sorted by category, with more points for harder ones.

This course is about crypto. It's the friendliest start, because the easy ones need no setup: a string, a browser and some patience.

  • CryptoEncodings, old ciphers, XOR, and later real cryptography with math.
  • WebFind the flag in a website: hidden pages, cookies, form inputs.
  • ForensicsDig through files, images, network captures and disk images.
  • ReversingRead a program and find out what input it wants.
  • PwnMake a program do something it was not meant to do.
  • Misc & OSINTPuzzles, and facts that can be found in public sources.
Lesson 1.3 · What a CTF is

Stay in scope

A CTF is a game with rules. The challenges are built to be attacked, everything else is off limits: the scoreboard, the organizers' servers, other teams.

Read the rules page before you start. When in doubt, ask the organizers.

What would you do?

While solving a challenge you notice the scoreboard seems to have a bug that would let you add points.

Chapter 2: Text is just bytes

Lesson 2.1 · Text is just bytes

Every character is a number

In ASCII, f is 102, l is 108, a is 97. The same number can be written in different bases: 102 is 66 in hex and 01100110 in binary.

So hex, binary and decimal “encodings” are just the bytes of the text, written out.

Try itType something. Each character appears as decimal, hex and binary.

Hex
Binary
Lesson 2.2 · Text is just bytes

How Base64 works

Base64 takes 3 bytes (24 bits) and cuts them into 4 groups of 6 bits. Each group is a number from 0 to 63 and picks one character from A–Z a–z 0–9 + /.

Not a multiple of three? Then = fills the gap. That's why Base64 often ends in = or ==.

Try itType one, two or three characters and watch the bits regroup.

Lesson 2.3 · Text is just bytes

Which encoding is it?

Each encoding has a look. Pairs of 0–9 and a–f: hex. Only 0 and 1: binary. Capitals and 2–7 with lots of =: Base32. Mixed case with = at the end: Base64. %7B: URL encoding.

And letters in the shape of a flag, but scrambled? Probably ROT13.

Try itSix samples. Name the encoding.

Sample 1 of 6

Chapter 3: Peeling layers

Lesson 3.1 · Peeling layers

Layers like an onion

Challenge authors love to stack layers: ROT13, then hex, then Base64. You go backwards: decode Base64, look at the result, decode the next layer, look again.

After every step ask: does this look like another format, a flag with scrambled letters, or unreadable bytes?

flag{…} Base64 Hex ROT13
Lesson 3.2 · Peeling layers

Peel it yourself

Your turn. This string hides a flag under three layers. Look at it, decide which layer you see, and peel it.

Tip: after each step, look at which characters are left. Only 0–9 and a–f? Mixed case with =? Brackets with scrambled letters?

Try itPick the layer you think comes next. A wrong guess doesn’t fit and is rejected.

    Lesson 3.3 · Peeling layers

    What comes next?

    Sometimes the result already has the shape of a flag, but with the wrong letters. Brackets and underscores survive ROT13 and Caesar, only letters move.

    The chain decoder spots these cases for you. But knowing what to look for makes you faster than any tool.

    You decoded Base64 and got

    synt{nyzbfg_gurer}

    Chapter 4: Classical ciphers

    Lesson 4.1 · Classical ciphers

    Caesar: only 25 keys

    Caesar moves every letter by the same number. Only 25 shifts are possible, so try them all. That's called brute force.

    In a CTF it's even quicker: you know the flag starts with flag. The distance from f to the first letter of the ciphertext is the shift.

    Try itMove the slider until the flag appears.

    Ciphertext

    mshn{jhlzhy_dhz_olyl}

    Result

    mshn{jhlzhy_dhz_olyl}

    Lesson 4.2 · Classical ciphers

    Count the letters

    Longer text gives itself away. In English, E is the most common letter, then T and A. A shift moves the whole pattern, but keeps its shape.

    Line up the blue bars of the ciphertext with the dashed English ones and the text decodes. This works for any cipher that uses one alphabet.

    Try itShift the bars until the peaks match English. Then read the text.

    Lesson 4.3 · Classical ciphers

    Vigenère: a key word

    Vigenère shifts each letter by the matching letter of a keyword: A = 0, B = 1, C = 2 … The key repeats. With CTF the shifts are 2, 19, 5, 2, 19, 5 …

    To break it, find the key length first, then solve every n-th letter like a Caesar cipher. The cipher tab does that automatically.

    Try itType the key CTF and watch each letter shift by its own amount.

    Chapter 5: XOR

    Lesson 5.1 · XOR

    Flip the bits

    XOR compares two bits: 1 if they differ, 0 if they're the same. Every 1 in the key flips the bit above it.

    The magic: XOR with the same key twice gives back the original. (m ⊕ k) ⊕ k = m.

    Try itClick the key bits. Then apply the key a second time.

    Data
    Key
    Data ⊕ key
    ⊕ key again
    Lesson 5.2 · XOR

    One byte, 255 keys

    If every byte is XORed with the same single byte, there are only 255 keys to try. The right one turns noise into readable text.

    Tools rank all 255 results by how much they look like English, so you don't have to look at each one.

    Try itMove the slider. Somewhere one key turns the bytes into the flag.

    Ciphertext (hex)

    3c363b3d2135343f0538232e3f05313f2327

    Result

    Lesson 5.3 · XOR

    The flag gives the key away

    A longer key repeats: keykeykey…. Too many to try. But you know how the plaintext starts: flag{.

    Since c ⊕ m = k, XOR the first five bytes with flag{ and the key appears. If it repeats, you have all of it. That's a known-plaintext attack.

    Try itType flag{ into the box. The key appears under the bytes.

    Ciphertext bytes

    Chapter 6: Knowing when to stop

    Lesson 6.1 · Knowing when to stop

    Not everything is a layer

    Some strings can't be peeled. A hash is a one-way fingerprint, and real encryption like AES needs its key.

    When decoding stops making progress, look at the rest of the challenge again: the description, the files, the source code. The key, or the real flag, is usually there.

    After two layers you get

    5d41402abc4b2a76b9719d911017c592

    Chapter 7: Final check

    Lesson 7.1 · Final check

    Ready for your first CTF?

    Eight questions on everything you learned. Try as often as you like.

    Question 1 of 80 correct

    Course complete

    Almost there

    You have seen 0 of 17 lessons.

    Put your name on the certificate, then print it or save it as a PDF. Your name stays in this browser.

    encode-decode Academy

    Certificate of completion

    Your name

    has completed the free online course

    CTF crypto for beginners

    7 chapters · 17 interactive lessons · about 30 minutes

    encode-decode.com/academy/ctf-crypto/

    Course notes

    The course as text

    Everything from the lessons in 7 short chapters, to read or to look something up later.

    Chapter 1

    What a CTF is

    A Capture the Flag competition, CTF for short, is a security game. The organizers publish challenges, each one hiding a secret string called the flag. It usually has a fixed format such as flag{…} or picoCTF{…}. You find it, submit it and get points. Most beginner CTFs are “Jeopardy” style: a board of challenges in categories like crypto, web, forensics, reverse engineering and binary exploitation, each worth more points the harder it is.

    The crypto category is the friendliest place to start. Many easy challenges are not about breaking modern encryption at all. They wrap the flag in encodings and old ciphers: Base64, hex, ROT13, Caesar, XOR. Learning to recognize these layers is the first skill this course teaches.

    One rule comes before everything else: only attack what the organizers explicitly allow. The challenge servers are in scope. The scoreboard, the infrastructure and other players are not, unless the rules say so.

    Open the lessons of chapter 1 →
    Chapter 2

    Text is just bytes

    Computers store text as numbers. In ASCII, the letter f is 102, l is 108, a is 97 and g is 103. The same number can be written in different bases: 102 is 66 in hex and 01100110 in binary. Hex, binary, octal and decimal “encodings” in CTFs are nothing more than these numbers written out.

    Base64 packs bytes into 64 safe characters (A–Z, a–z, 0–9, + and /). It takes three bytes, 24 bits, and splits them into four groups of 6 bits. Each group picks one of the 64 characters. If the input is not a multiple of three bytes, = pads the end. That is why Base64 so often ends with one or two equals signs, and why its length is a multiple of four. Base32 does the same with 5-bit groups and only uses A–Z and 2–7.

    Encoding is not encryption. There is no key: anyone who recognizes the format can turn it back. That is exactly what makes it a good first layer in a challenge.

    Open the lessons of chapter 2 →
    Chapter 3

    Peeling layers

    Easy crypto challenges stack encodings: the flag is ROT13'd, the result written as hex, the hex encoded as Base64. To solve it you go backwards, one layer at a time, and look at the result after each step. Does it look like another format? Peel again. Does it look like the flag format with scrambled letters? Try ROT13 or Caesar. Unreadable bytes? Think about XOR.

    Some steps don't look like progress on their own. ROT13 on a string of hex characters gives letters like n–s, which are no longer hex. The other way round: ROT13 on that string turns it back into valid hex. That's the kind of hint to look for. The chain decoder does this search automatically and shows each step, and you can also peel by hand.

    Open the lessons of chapter 3 →
    Chapter 4

    Classical ciphers

    The Caesar cipher moves every letter by the same number of places. With only 25 possible shifts, you just try them all. In a CTF you know part of the plaintext: the flag prefix. If the ciphertext starts with mshn and the flag format is flag, the shift is the distance from f to m.

    For longer texts, frequency analysis works for every single-alphabet substitution: in English, E, T and A are the most common letters. Count the letters of the ciphertext and line the peaks up with English.

    Vigenère uses a keyword: each letter of the key gives the shift for one letter of the text, and the key repeats. That flattens the letter frequencies. To break it, find the key length first (the index of coincidence of every n-th letter jumps up at the right length), then solve each column like a Caesar cipher. The cipher tab does both.

    Open the lessons of chapter 4 →
    Chapter 5

    XOR

    XOR (exclusive or, written ⊕) compares two bits: the result is 1 if they differ and 0 if they are equal. Applied to bytes, every bit of the data is flipped where the key has a 1. The key property: XOR with the same key twice gives back the original, (m ⊕ k) ⊕ k = m. That's why XOR is everywhere in cryptography, and in CTFs.

    With a single-byte key there are only 255 possibilities. Try them all and keep the one that gives readable text. With a longer, repeating key, use what you know about the plaintext: c ⊕ m = k. If the flag starts with flag{, XOR the first five bytes of the ciphertext with flag{ and you get the first five bytes of the key. If they repeat, you have the whole key. This is called a known-plaintext attack.

    Real ciphers like AES are built so that this does not work. XOR with a short repeating key is not encryption you should ever use, but it is a classic challenge.

    Open the lessons of chapter 5 →
    Chapter 6

    Knowing when to stop

    Not every string is a layer. A hash such as MD5 or SHA-256 is a one-way fingerprint: there is nothing inside to decode. 32 hex characters after a decoding step are a strong sign that you reached a hash, not another layer, and the flag must come from somewhere else in the challenge. The same goes for real encryption like AES: without the key, no amount of decoding helps. Then the challenge is about finding the key, for example in the source code you were given.

    Open the lessons of chapter 6 →
    Chapter 7

    Final check

    That's the course. Next step: pick a beginner-friendly CTF. picoCTF runs all year with a practice area, and CTFtime lists upcoming events. Keep the CTF tools open in a tab: the chain decoder, the XOR key finder and the cipher cracker run in your browser, so nothing from the challenge leaves your device.

    Open the lessons of chapter 7 →
    Glossary

    Words you will meet

    ASCII
    The table that gives every basic character a number from 0 to 127, e.g. A = 65.
    Base64
    An encoding that writes any bytes with 64 safe characters. No key, fully reversible.
    Brute force
    Trying every possible key until one works.
    CTF
    Capture the Flag: a security competition where you find hidden flags.
    Crib
    A piece of plaintext you know or guess, used to recover the key.
    Encoding
    A different way to write data. Not a secret: anyone can reverse it.
    Flag
    The secret string you submit for points, e.g. flag{…}.
    Frequency analysis
    Counting letters to break substitution ciphers.
    Hex
    Base 16: each byte as two characters from 0–9 and a–f.
    Index of coincidence
    How likely two random letters of a text are equal. About 0.066 for English.
    Jeopardy CTF
    A CTF with a board of challenges in categories, each worth points.
    Known-plaintext attack
    Using known plaintext and its ciphertext to work out the key.
    ROT13
    Caesar shift by 13. Applying it twice gives back the original.
    XOR
    Exclusive or: 1 where two bits differ. XOR with the same key twice cancels out.

    Searches the list of pages on this site. What you type stays in your browser.