lesson_16: ciphers, keys, and representations
01 — why this lab matters
fort knocks is a cipher learning lab.
it teaches how a message can change shape through substitution, transposition, keys, modern cryptographic primitives, encodings, hashes, and vault-style artifacts.
The name is wordplay.
fort knocks (for t knock s) is inspired by fort knox, but the lab is not about a vault building.
it is about the idea of protecting, transforming, packing, and inspecting messages.
The phrase for t, knock s is also a useful joke: if t becomes s, that is a mapping rule.
That kind of rule belongs to substitution.
The lab begins with a simple order:
message first. method second. command third.
That order matters because cryptography is not button magic.
You should know what message is being transformed, what method is selected, and what action is being performed.
micro meaning
• message = the original human-readable input
• method = the transformation rule
• command = encrypt, decrypt, swap, demo, clear, or download
• ciphertext = transformed output
• key = extra input that changes the transformation
• artifact = packaged output with metadata
02 — cipher does not always mean modern security
The word cipher can refer to many different kinds of transformations.
Some ciphers are historical learning tools.
Some are mathematical toys.
Some are real modern cryptographic constructions.
Some methods in this lab are deliberately educational and not secure.
For example:
• caesar is useful for learning substitution
• rot13 is useful for seeing symmetric rotation
• atbash is useful for mirror mapping
• rail fence is useful for transposition
• vigenere is useful for keyed classical ciphers
• aes-gcm is a modern authenticated encryption mode
• sha-256 is a hash, not encryption
• base64 is encoding, not encryption
The lesson is not that all methods are equally strong.
The lesson is that different transformations answer different questions.
micro meaning
• classical cipher teaches structure
• modern crypto protects data when used correctly
• encoding changes representation
• hashing creates a one-way fingerprint
• strength depends on method, key, mode, and implementation
03 — substitution replaces symbols
substitution means one symbol is replaced by another symbol.
The position of the symbol may stay the same, but the symbol identity changes.
Example idea:
t → s
That means every t can be replaced with s.
This is why the phrase for t, knock s works as a teaching joke.
It describes a mapping.
Mapping belongs to substitution.
The lab includes substitution methods such as:
• caesar rotation
• rot13
• atbash mirror
• affine cipher
• knock map
• polybius square
• bacon cipher
micro meaning
• substitution changes symbol identity
• mapping defines what each symbol becomes
• alphabet is the working symbol set
• ciphertext keeps positions mostly recognizable
• simple substitution is usually easy to analyze
04 — caesar rotation teaches shifting
caesar rotation moves each letter by a fixed number of positions in the alphabet.
If the rotation is 3, then:
• a becomes d
• b becomes e
• c becomes f
The alphabet wraps around at the end.
That wraparound is important.
Without wraparound, letters near the end would fall outside the alphabet.
Caesar is simple, but it teaches the core idea of a deterministic mapping.
micro meaning
• rotation is a fixed alphabet shift
• wraparound keeps output inside the alphabet
• same input letter always becomes the same output letter
• fixed substitution leaks patterns
• decrypt shifts in the opposite direction
05 — rot13 is a symmetric rotation
rot13 is caesar rotation by 13 positions.
In the english alphabet, rotating by 13 twice returns the original text.
That means the same operation can encode and decode.
This makes rot13 useful for demonstrations.
It is not secure.
It is a reversible text transformation.
micro meaning
• rot13 is rotation by 13
• same operation encodes and decodes
• reversible does not mean secure
• pattern leakage remains obvious
• educational value comes from symmetry
06 — atbash mirrors the alphabet
atbash maps the alphabet to its mirror.
• a becomes z
• b becomes y
• c becomes x
The method is reversible because mirroring twice restores the original text.
Atbash is useful because it shows that a substitution does not have to be a rotation.
It can be a mirror mapping.
micro meaning
• atbash is alphabet mirroring
• mirror mapping is a substitution rule
• same operation can reverse itself
• letter frequency still leaks information
• simple mapping is not modern security
07 — knock map teaches custom substitution
knock map lets the user define custom mappings.
knock map is not a historical cipher name.
it is the name of this lab’s custom substitution mode.
the idea is simple: define a small mapping table such as t=s, k=x, o=q, n=m.
that means selected characters are replaced according to user-defined rules.
this belongs to substitution because symbol identity changes while position usually stays the same.
Example:
t=s,k=x,o=q,n=m
This means:
• t becomes s
• k becomes x
• o becomes q
• n becomes m
This is the most direct expression of the for t, knock s joke.
It shows that substitution can be defined by a small table.
But small custom maps can also create partial transformations where only some letters change.
micro meaning
• knock map is user-defined substitution
• t=s means t maps to s
• partial map changes only selected letters
• inverse map is needed for decrypt
• custom mapping teaches how codebooks work
08 — transposition moves positions
transposition keeps symbols but changes their positions.
That is different from substitution.
In substitution, letters become other letters.
In transposition, letters are rearranged.
Example:
signal can become langis if the order is reversed.
The same letters remain, but their positions change.
The lab includes transposition methods such as:
• reverse
• rail fence
• columnar
• scytale
micro meaning
• substitution changes symbols
• transposition changes positions
• same letters can remain visible
• order carries meaning
• reversal is the simplest transposition
09 — rail fence teaches structured rearrangement
rail fence writes text along zig-zag rails and then reads across the rails.
The number of rails changes the pattern.
A larger rail count changes the shape of the rearrangement.
This makes rail fence useful for seeing how a simple positional rule can scramble readable text.
The message is not protected by modern standards, but the positional idea is important.
micro meaning
• rails define the zig-zag structure
• position changes while symbols remain
• rearrangement can hide direct readability
• decrypt requires the same rail structure
• parameter changes the transformation
10 — columnar transposition uses a key for order
columnar transposition writes text into rows and reads columns in an order derived from a key.
The key does not replace letters.
The key changes the order in which columns are read.
That makes it a keyed transposition method.
The same message and same method can produce different output if the key changes.
micro meaning
• columnar is position rearrangement
• key controls column order
• symbols usually keep identity
• positions carry the secrecy attempt
• same key is needed to reverse the process
11 — keyed classical ciphers use a key stream
keyed classical ciphers use a key to influence the transformation.
The lab includes:
• vigenere
• beaufort
• autokey vigenere
• xor mask
The key changes the output.
That is a major step beyond fixed substitution.
With a fixed caesar shift, the mapping stays the same.
With a keyed method, the mapping can vary across the message.
micro meaning
• key changes transformation
• vigenere uses repeated key shifts
• beaufort uses a related key-minus-text idea
• autokey extends the key stream
• xor works at byte level
12 — vigenere teaches polyalphabetic substitution
vigenere is a classical polyalphabetic cipher.
Instead of using one fixed alphabet shift, it uses different shifts based on a key.
Example key:
signal
Each key letter defines a shift for a message letter.
This makes the output less repetitive than a simple caesar cipher.
Vigenere is historically important because it shows how a key can drive changing substitutions.
micro meaning
• vigenere uses repeated key shifts
• polyalphabetic means multiple substitution alphabets
• key stream controls the shift sequence
• same plaintext can encrypt differently by position
• classical strength is not modern strength
13 — xor mask teaches byte-level reversibility
xor is a reversible operation at the byte level.
If a byte is xor-masked with a key byte, applying the same key byte again restores the original value.
That makes xor useful for teaching reversible masking.
In the lab, xor output is shown as hex because raw bytes may not display cleanly as text.
This is an important bridge from text ciphers to byte operations.
micro meaning
• xor is reversible with the same key
• byte is the working unit
• hex displays byte output safely
• repeated key is educational, not strong crypto
• byte-level thinking matters in real systems
14 — modern crypto uses stronger primitives
The lab includes modern crypto demos such as:
• aes-gcm
• rsa-oaep
These are different from classical ciphers.
aes-gcm is symmetric authenticated encryption.
It uses a secret key, a nonce, ciphertext, and authentication data.
rsa-oaep is public-key encryption.
It uses a public key to encrypt and a private key to decrypt.
The lab uses browser web crypto where available.
The demo is educational and simplified.
Real cryptographic systems require careful key management, randomness, modes, storage, rotation, and protocol design.
micro meaning
• aes-gcm is modern symmetric encryption
• rsa-oaep is public-key encryption
• nonce must be handled correctly
• key management is part of security
• primitive is not the whole system
15 — aes-gcm teaches authenticated encryption
aes-gcm does more than hide the message.
It also detects tampering.
That is why it is called authenticated encryption.
If ciphertext is changed, decryption should fail instead of silently producing modified plaintext.
This matters because confidentiality without integrity can be dangerous.
A secure message system usually needs both.
micro meaning
• confidentiality hides content
• integrity detects tampering
• authenticated encryption provides both
• nonce must not be reused with the same key
• decryption failure can be a security signal
16 — rsa-oaep teaches public-key direction
rsa-oaep teaches the direction of public-key encryption.
A public key can encrypt.
A private key can decrypt.
That means someone can send protected data without sharing the private key.
The lab generates a temporary browser key pair for demonstration.
The point is to show the concept, not to create a persistent production key system.
micro meaning
• public key encrypts
• private key decrypts
• key pair creates asymmetric direction
• temporary key is demo-only
• real systems need key storage and trust model
17 — encoding is representation, not secrecy
The lab includes representation methods such as:
• base64
• hex
• binary
These are encodings.
They change how data is represented.
They do not automatically protect meaning.
A base64 string may look mysterious, but if it is just encoded text, it can be decoded.
A hex string may look technical, but it may simply be byte notation.
Binary is even lower-level representation.
micro meaning
• encoding changes format
• base64 represents bytes as text
• hex represents bytes compactly
• binary represents bits
• encoded does not mean encrypted
18 — hashing is one-way fingerprinting
sha-256 is a hash function.
It creates a fixed-size digest from input data.
The goal is not to decrypt it later.
The goal is to produce a fingerprint.
If the input changes, the digest changes.
That makes hashes useful for integrity checks, identifiers, deduplication, signatures, and password storage systems when combined with proper salts and slow password hashing methods.
The lab also includes hmac-sha256.
hmac is a keyed digest.
It uses a secret key to authenticate the message.
micro meaning
• hash is one-way
• sha-256 produces a digest
• digest is a fingerprint
• hmac is keyed integrity
• hashing is not encryption
19 — vault artifact packages the result
The vault artifact feature packages output with metadata.
A useful artifact can include:
• tool name
• method
• group
• created_at
• input
• output
• payload
• hint
This teaches that ciphertext alone is often not enough.
A system also needs metadata to know how to interpret, store, route, or decode the output.
But metadata can also leak information.
So artifact design is part of security design.
micro meaning
• artifact packages data and metadata
• metadata helps interpretation
• metadata can leak context
• ciphertext may need method information
• storage format affects future decoding
20 — reversible and one-way methods are different
Some methods can be reversed.
Examples:
• caesar
• rot13
• atbash
• vigenere
• xor
• aes-gcm with the right key and nonce
Some methods are one-way by design.
Examples:
• sha-256
• hmac-sha256
This distinction is essential.
A decrypt button makes sense for a reversible cipher.
It does not make sense for a hash.
micro meaning
• reversible method can return plaintext
• one-way method creates a digest
• decrypt is not universal
• hash verification compares digests
• method type determines possible commands
21 — what this lab makes visible
This lab makes message transformation observable.
It surfaces:
• input message
• cipher group
• selected method
• method controls
• key or passphrase
• rotation
• rails
• knock map
• encrypt command
• decrypt command
• reverse preview
• what happened
• artifact preview
• downloaded vault artifact
The value is that the user sees transformation, classification, and metadata together.
A cipher is not just an output string.
It is a method, a key, a mode, a representation, and an interpretation path.
micro meaning
• input gives the message
• method gives the rule
• control changes the rule
• output shows the transformation
• artifact preserves context
22 — what the user should learn
The user should leave understanding that cryptographic language has layers.
The important questions are:
• is this substitution or transposition?
• is there a key?
• is the method reversible?
• is this encoding, encryption, or hashing?
• where does the security come from?
• what metadata is needed to decode it later?
• what should not be trusted as secure?
A good cipher lab should teach both curiosity and caution.
It should make transformations fun without pretending that every transformation is strong security.
micro meaning
• cipher literacy begins with classification
• method type matters
• key handling matters
• encoding is not secrecy
• modern crypto requires careful system design
23 — final line
substitution changes symbols.
transposition changes positions.
keys change transformations.
encoding changes representation.
hashing creates fingerprints.
encryption protects meaning only when the whole system is designed correctly.
good cipher literacy begins with three questions:
• what transformation happened?
• what information is needed to reverse or verify it?
• is this actually security, or only a different representation?