30 Days of CTF Series | Day 7: Encoding vs Encryption (and Week 1 Review)

Welcome to Day 7 of the 30 Days of CTF series. This is the last day of Week 1.
Over the past six days, you have already met Base64 (Day 1), hex (Day 6) and XOR (Day 6). In CTFs, you will see strange looking text all the time, and the first question is always the same: “Is this encoded, encrypted or hashed?”
Today you will learn to answer that question in seconds, recognise the most common encodings just by looking at them, and decode even multi layer puzzles. Then we will review everything from Week 1, so you start Week 2 with a strong base.
Practice labs for Day 7:
Encoding vs Encryption vs Hashing
These three words are mixed up all the time, even by experienced people. Here is the simple difference:
Encoding: changing the format, no secret.
Encoding converts data into another format so it can be stored or sent safely. Anyone can reverse it, because there is no key. Example: Base64.
Encryption: hiding data with a key.
Encryption scrambles data so only someone with the key can read it. Without the key, it should be very hard to reverse. Example: AES, RSA.
Hashing: a one way fingerprint.
Hashing turns any data into a fixed length “fingerprint”. It cannot be reversed. The same input always gives the same hash. Example: MD5, SHA256.
A simple way to remember:
- Encoding is like writing a message in a different language. Anyone with a dictionary can read it.
- Encryption is like locking the message in a box. You need the key.
- Hashing is like taking a fingerprint. You cannot rebuild the person from the fingerprint.
Why this matters in CTFs: If it is encoding, decode it. If it is encryption, look for the key or a weakness. If it is a hash, you cannot “decode” it, you have to crack it by guessing (we will do this on Day 16).
How to Recognise Common Encodings
This is a skill you build by practice. Here are the patterns to look for.
Base64
SGFja0NURg==
- Letters (upper and lower case), numbers,
+ and /
- Often ends with
= or ==
- Length is usually a multiple of 4
Base32
JBQWG22DKRDA====
- Only uppercase letters and numbers 2 to 7
- Often ends with many
= signs
Hex (Base16)
4861636b435446
- Only numbers
0 to 9 and letters a to f
- Every 2 characters = 1 letter (
48 = H)
Binary
01001000 01101001
- Only
0 and 1, usually in groups of 8
- Each group of 8 = 1 letter (this one says
Hi)
Decimal (ASCII numbers)
72 97 99 107
- Numbers mostly between 32 and 126
- Each number = 1 letter (
72 = H). Use chr() from Day 6.
URL Encoding
HackCTF%7Ba%20b%7D
- Lots of
% followed by 2 hex characters
%20 = space, %7B = {, %7D = }
- Very common in web logs and web challenges
ROT13
UnpxPGS
- Looks like normal letters, but the words make no sense
- Every letter is shifted 13 places. Since the alphabet has 26 letters, applying ROT13 twice gives the original text.
UnpxPGS becomes HackCTF.
Hashes (not encodings!)
56dd6f52fdfcf60325c2ec2f5d7c48d4 (MD5, 32 hex characters)
bc2d0d174b8d3e0563568c3aa284831c51657315ed17466c7aa3cae91eefd580 (SHA256, 64 hex characters)
- Fixed length hex strings
- If you see exactly 32, 40 or 64 hex characters, think “hash”, not “hex encoded text”
Tools to Decode
1. CyberChef (easiest)
Open CyberChef, paste your text and drag operations like From Base64, From Hex, URL Decode or ROT13 into the recipe.
Pro tip: Use the Magic operation. It tries to detect the encoding automatically. It is not perfect, but it saves a lot of time.
2. Linux terminal
$ echo "SGFja0NURg==" | base64 -d # Base64
$ echo "JBQWG22DKRDA====" | base32 -d # Base32
$ echo "4861636b435446" | xxd -r -p # Hex
$ echo "UnpxPGS" | tr 'A-Za-z' 'N-ZA-Mn-za-m' # ROT13
If xxd is missing on your system, install it with sudo apt install xxd.
3. Python (from Day 6)
import base64, codecs, urllib.parse
print(base64.b64decode("SGFja0NURg==").decode())
print(base64.b32decode("JBQWG22DKRDA====").decode())
print(bytes.fromhex("4861636b435446").decode())
print(codecs.decode("UnpxPGS", "rot13"))
print(urllib.parse.unquote("HackCTF%7Ba%20b%7D"))
Let’s Solve a Challenge Together
A challenge gives you this text and says:
“We hid the flag under three layers. Peel them one by one.”
AQt2ZGLmAzV0ZmH0AQL3LwZmAzH2ZmZjAwDmZGMyAwp1MwZkAmZ1MwMyZmN3AQIzZmZ2MGLmAmV3BGpjAmDmZGZjAzH3MN==
Step 1: Look at it.
It ends with == and has upper and lower case letters and numbers. It looks like Base64. Let’s try it.
$ echo "AQt2ZGLm...MN==" | base64 -d
The output is garbage. So it is not plain Base64. What else changes letters but keeps the shape? ROT13. ROT13 only shifts letters, so numbers and = stay the same, which is why it still looks like Base64.
Step 2: Undo ROT13.
$ echo "AQt2ZGLm...MN==" | tr 'A-Za-z' 'N-ZA-Mn-za-m'
NDg2MTYzNmI0MzU0NDY3YjMzNmU2MzMwNjQzMTZlNjc1ZjMxNzM1ZjZlMzA3NDVmMzM2ZTYzNzI3OTcwNzQzMTMwNmU3ZA==
Now this is real Base64.
Step 3: Decode Base64.
4861636b4354467b336e633064316e675f31735f6e30745f336e637279707431306e7d
Only 0 to 9 and a to f. That is hex, and it starts with 4861636b which you already know means Hack.
Step 4: Decode hex.
HackCTF{3nc0d1ng_1s_n0t_3ncrypt10n}
Flag captured. You can also do it all in one line by chaining with pipes (Day 3):
$ echo "AQt2ZGLm...MN==" | tr 'A-Za-z' 'N-ZA-Mn-za-m' | base64 -d | xxd -r -p
(In the real command, paste the full text in place of AQt2ZGLm...MN==.)
The lesson: Look, guess, test, repeat. If the output looks like another encoding, keep going. If it looks like garbage, go back one step and try a different guess.
Try It Yourself on Hacklido
1. Caesar’s Mistake
An old cipher was used, but the shift is unknown. Your goal is to try different shifts until the flag becomes readable. Read the hints on the challenge page carefully, they connect directly to the ROT13 trick you learned today.
Link: learn.hacklido.com/challenges/caesars-mistake
2. Hex Speak
A developer converted the flag to hex, but also added a simple XOR layer first. Decode the hex, then use the XOR skills from Day 6 to recover the flag.
Link: learn.hacklido.com/challenges/hex-speak
3. Strange Log File
If you did not solve it on Day 3, try again now. One line in the log hides something using an encoding you learned today (look for % signs).
Link: learn.hacklido.com/challenges/strange-log-file
4. Chat History
Part of the flag is in plain text and another part uses a less common Base encoding. Use CyberChef and today’s recognition tips to find the right one.
Link: learn.hacklido.com/challenges/chat-history
Week 1 Review: What You Have Learned
Congratulations, you have completed Week 1. Here is everything in one place:
- Day 1: What Is CTF. Jeopardy vs Attack Defense, the 7 categories, flag formats and the CTF mindset.
- Day 2: Linux Basics.
pwd, ls -la, cd, cat, file, hidden files and permissions.
- Day 3: Linux Power Tools.
find, grep, strings and the pipe |.
- Day 4: Networking Fundamentals. IP addresses, ports, TCP vs UDP, DNS,
curl and nc.
- Day 5: Scanning and Enumeration. Nmap,
-p-, -sC -sV, and checking every open port.
- Day 6: Python for CTF. Strings, bytes, decoding,
requests and pwntools.
- Day 7: Encoding vs Encryption. Recognising Base64, Base32, hex, binary, URL encoding, ROT13 and hashes.
Week 1 Self Check
Answer these without looking back. If you get stuck on any, revisit that day.
- Which command shows hidden files in a folder?
- How do you search all files in the current folder for the text
HackCTF?
- What does
2>/dev/null do?
- What is the difference between port 80 and port 443?
- Which Nmap option scans all 65,535 ports?
- What does
-sC -sV do in Nmap?
- How do you decode Base64 in Python?
- You see a 32 character hex string. Is it more likely encoded text or a hash?
- Text ends with
== but decoding gives garbage. What could be the reason?
Answers (scroll down only after trying):
ls -la
grep -r "HackCTF" .
- It hides error messages by sending them to the trash.
- Port 80 is HTTP (not secure), port 443 is HTTPS (secure).
-p-
-sC runs default scripts, -sV detects service versions.
base64.b64decode(data).decode()
- Most likely an MD5 hash.
- It may have another layer on top, like ROT13, so undo that first.
Week 1 Challenge Recap on Hacklido
If you missed any of these, finish them over the weekend before starting Week 2:
Day 7 Cheat Sheet
Save this in your notes:
- Encoding: no key, anyone can reverse it (Base64, hex, URL)
- Encryption: needs a key (AES, RSA)
- Hashing: one way, crack it, do not decode it (MD5, SHA256)
- Base64: A to Z, a to z, 0 to 9,
+, /, ends with =
- Base32: A to Z and 2 to 7, many
= at the end
- Hex: 0 to 9 and a to f, 2 characters per letter
- Binary: 0 and 1 in groups of 8
- URL encoding:
% followed by 2 hex characters
- ROT13: readable letters that make no sense
- Hash lengths: MD5 = 32, SHA1 = 40, SHA256 = 64 hex characters
base64 -d, base32 -d, xxd -r -p, tr 'A-Za-z' 'N-ZA-Mn-za-m'
- CyberChef Magic: auto detect encodings
Day 7 Task
What’s Next?
Week 2 starts tomorrow, and it is all about Web Exploitation, the most popular CTF category. In Day 8, we will learn How the Web Works: HTTP requests, status codes, headers, cookies and the first places to look for hidden flags on any website.
See you tomorrow on Day 8. Happy hacking.