Course / 10 Crypto and files / Lesson 07 of 19

When to stay in CyberChef and when to open Python

Estimated time: 18 min reading · 16 min activity

When two tools perform the same transformation, compare their input bytes, operation and output representation. A CyberChef recipe makes the operation order visible. A Python script records instructions in a file, which can be read and later applied consistently. A tool choice should follow the task and its evidence requirements.

The supplied example declares standard Base64. Decoding yields bytes; reading those bytes as ASCII yields the displayed word. This is a representation change, not secret decryption. A short round trip can check consistency with that operation, but does not prove that an unknown input used it or that every future record will be valid.

Before you begin

Estimated time
18 min reading, 16 min activity. Setup and optional practice may take longer.
Where you work
Read the printed evidence in a desktop or mobile browser and keep notes on paper or in a text editor. No installation, recovery tool, GPU, real password, live lookup or external account is required. Any later optional tool setup is outside the estimates.
Without a lab
All evidence needed for the activity appears on this page. Copy it into notes if downloads are unavailable. Read the labeled model and predict each result; a paper trace practises the reasoning while tool operation waits for a lab. Reading needs no JavaScript. Answer checking needs JavaScript and a secure context; saving progress also needs usable browser storage.

After this lesson you can:

  • Compare declared input, recipe operation and Python source.
  • Match printed decoded bytes with their ASCII text.
  • Choose an appropriate form for repeatable local transformations.

01Example

Declared sample and predicted representations. Earlier observations are identified separately below.

Input: c2VhbA==
Recipe operation: From Base64
Python operation: base64.b64decode
Result bytes: 73 65 61 6c
ASCII reading: seal

02One sample can stay on the page

Read transform.py before any optional later execution. import base64 loads the standard-library module; b64decode performs the named decoding operation. A bytes value remains bytes until a text-decoding step interprets it as characters. Compare like with like: printed text and a hex view can represent the same underlying bytes.

Recorded sample: Python 3.12.3 and a single CyberChef From Base64 bake produced seal for the supplied input. That historical match covers one sample only. Here you read source and printed evidence; a new tool run remains separate.

Compare the same transform in a readable recipe and Python source before choosing how to repeat work.Model. A teaching model drawn by hand. It shows the idea, not real tool output.

Read the full explanation below.

Playback is optional. Step through at your own pace.

Supplied teaching sample

Supplied Base64 input

c2VhbA==input

Two declared operations

From Base64recipe operation
base64.b64decodePython operation

Same predicted bytes

73 65 61 6cresult bytes

ASCII reading

sealASCII

c2VhbA== + From Base64 → 73 65 61 6cRecipe path

73 65 61 6c → sealASCII correspondence

The recipe path predicts the supplied result bytes.

Follow the explanation

  1. The recipe path predicts the supplied result bytes.
  2. The Python operation predicts the same bytes for the same input.
Read every state and value

1. The recipe path predicts the supplied result bytes.

Example
Supplied teaching sample
Visible Item
c2VhbA== · recipe · python · 73 65 61 6c · seal
Current mappings
recipe · ASCII correspondence
Annotations
None

2. The Python operation predicts the same bytes for the same input.

Example
Supplied teaching sample
Visible Item
c2VhbA== · recipe · python · 73 65 61 6c · seal
Current mappings
python · ASCII correspondence
Annotations
Item: 73 65 61 6c; Text: No recipe or Python program was run by this scene.
Choose a repeatable workflow after matching the transform; this comparison is not a new CyberChef or Python run.

03Match the sample, then choose for a batch

Use bGFtcA== as a fresh guided parity sample. Its declared decoded bytes are 6c 61 6d 70, ASCII lamp. Both forms are printed for a complete paper comparison.

Label: standard Base64 of the four bytes of the word seal.
The earlier 2026-10-12 QA record reports Python and one CyberChef bake showing seal; the values below remain the supplied reference.

Input text: c2VhbA==
Predicted bytes: 73 65 61 6c
Predicted word: seal

A second sample, the word lamp, is bGFtcA==.
Predicted word: lamp.
That second sample is the module-case parity check.

Download the Base64 parity card

Label: From Base64 operation list for the seal sample.
Historical 2026-10-12 observation: one CyberChef From Base64 bake showed seal. Do not add an operation that fetches a URL.

Parity sample c2VhbA==
1. From Base64
Predicted output: seal

Batch note: a saved script can apply that same operation to each local record.
One pasted sample can stay in the recipe view.

Download the authored recipe

"""Decode one printed Base64 sample.

 The printed result is seal.
Uses the standard library only. No network. Decode the string in this
file and nothing else.
"""
import base64


def main():
    text = base64.b64decode("c2VhbA==")
    print(text.decode("utf-8"))


if __name__ == "__main__":
    main()

Download the transform script

  1. Write the input and the one operation From Base64 in a recipe note.
  2. Find the corresponding base64.b64decode call in transform.py. Explain how using the guided input would change its data while leaving the intended operation the same. Do not edit or run the original source for this trace.
  3. Compare the four guided bytes with lamp. Record a matching recipe/source prediction, then name one future check needed for additional records: valid input and the expected output interpretation.
  4. Stop after that comparison. A later optional tool run uses only these declared strings and local Base64 decoding; no fetch operation is needed.

04Module case

Use the module case for about fifteen minutes. Complete each original shift, fixed-key XOR, digest-record, block-label and toy-product line. For its repeated-record job, name the repeatable file supplied by the packet. Keep a limit beside each transformation: a readable result or round trip is narrower than a claim of security. This is an ungraded written synthesis.

Label: ungraded Cryptography module case. Original cards. No tool was run.
About fifteen minutes. Write the transformations and their limits in notes.

1. Caesar shift +1. Ciphertext MJT.
   M steps back to L. J steps back to I. T steps back to S.
   Write the three letters.

2. XOR key 0x01. Cipher byte 0x70.
   0111 0000 XOR 0000 0001 = 0111 0001.
   Write the two hex digits.

3. generation-log.txt names hashlib.sha256 for the input night-desk.
   Write the call name on that line.

4. ECB toy row: plaintext KK KK MM, ciphertext labels 44 44 55.
   Write how many times the label 44 appears.

5. Toy primes p=2 and q=5. Write the product. This product is a teaching size.

6. One hundred local records need the same Base64 step already checked on seal.
   The repeatable file in this packet is transform.py.
   Write that file name.

Limits to write in one line each:
- A round trip shows the operation returned. It does not choose a production cipher.
- The sha256 line is a hashlib record of a public input. It is not a password hash.
- The ECB labels are a diagram. They are not AES output.
- n=10 from 2*5 is not a deployable modulus.

Download the cryptography module case

05Optional challenge

For about ten optional minutes, design a two-record worksheet with columns input, declared method, predicted bytes and status. Add an invalid-input row marked needs inspection instead of silently discarding it. This adds data-quality reasoning without executing a script.

06Fresh cases for the checks

Use these fictional cases for the checks below. They have different inputs from the worked examples. Read them here or make notes; no installation or external service is needed.

Parity card A: fresh declared representationOwned fixture. An original file made for this course. Follow the activity's instructions in your own lab.

Input: b3ds, declared standard Base64.
Recipe: From Base64 → interpret bytes as ASCII.
Equivalent source operations: base64.b64decode(input_value), then result.decode("ascii").
Supplied result bytes: 6f 77 6c. Supplied ASCII mapping: 6f=o, 77=w, 6c=l.
This is a paper comparison of declared data, not a new tool run.

Source card B: independent incorrect operationOwned fixture. An original file made for this course. Follow the activity's instructions in your own lab.

Goal: standard Base64 input → decoded bytes → ASCII text.
S1 import base64
S2 raw = base64.b64encode(input_value)
S3 text = raw.decode("ascii")
The error to diagnose is the direction of the Base64 transformation, not a missing network step.

Batch card C: separate jobOwned fixture. An original file made for this course. Follow the activity's instructions in your own lab.

Repeat an already-checked local transform on 80 records. Some rows may be invalid.
Required: retain row identity, record valid outputs, and mark invalid rows for review instead of silently dropping them. No network fetching is part of the job.

07Explain the evidence and its limit

Optional self-check: compare input bytes, operation order and output representation between a recipe and source, then design a per-record batch note.

Review it: distinguish bytes from their text or hex display, check the transform direction, preserve invalid rows and keep the job local.

08Common mistakes

If output differs, compare bytes and text encoding before changing the operation. A hex display and a readable word can describe the same bytes.

If one matched sample is treated as proof for all records, add a per-record validity check and an explicit stop on unexpected input.

If a tool recipe adds network retrieval, it changes the task and its scope. The supplied comparison is local Base64 decoding only.

References

  • CyberChef README

    Official recipe or Base64 API background for comparing the same declared operation.

  • Python 3.12: base64

    Official recipe or Base64 API background for comparing the same declared operation.