Codifica e Decodifica: Guida
Traduzione di messaggi usando regole di codifica e schemi di sostituzione
Indice
Impara
Codici di Sostituzione
Mappature dirette lettera-simbolo o lettera-numero
Trasformazioni Alfabetiche
Spostamento e trasformazione dell'alfabeto
Codici Avanzati
Regole di codifica combinate e a più passaggi
Cifrari a Trasposizione
Riarrangiamento delle posizioni delle lettere senza sostituzione
Impara 1
Codici Lettera-Numero
Ogni lettera è sostituita dalla sua posizione nell'alfabeto.
Letter-to-number coding is the simplest substitution cipher. Each letter is replaced by its position in the alphabet: A=1, B=2, C=3, and so on up to Z=26. To decode, convert each number back to its corresponding letter. This is often the first code type introduced in aptitude tests.
A=1, B=2, C=3, ... Z=26
- CAT = 3-1-20
- HELLO = 8-5-12-12-15
- 3-15-4-5 = CODE
Come riconoscerlo
- Numbers 1-26 (no numbers higher than 26)
- Pattern follows alphabetical position
- Often separated by hyphens or spaces
Errori comuni
- Confusing letter positions (common: J=10, not 11)
- Forgetting alphabet order mid-word
- Not recognizing double-digit numbers (12 is L, not 1-2)
Soluzione passo per passo
Codifica la parola 'CAT' con codice lettera-numero
- C è la 3a lettera dell'alfabeto
- A è la 1a lettera dell'alfabeto
- T è la 20a lettera dell'alfabeto
Risposta: 3-1-20
Impara 2
Codici Numero-Lettera
Decodificare numeri convertendoli nella lettera corrispondente.
Number-to-letter decoding is the reverse of letter-to-number encoding. Given a sequence of numbers, convert each to the letter at that position in the alphabet: 1=A, 2=B, 3=C, etc. The key skill is quickly recognizing position values, especially for letters later in the alphabet.
1=A, 2=B, 3=C, ... 26=Z
- 19-21-14 = SUN
- 2-15-15-11 = BOOK
- 23-1-20-5-18 = WATER
Come riconoscerlo
- Given numbers, asked to find the word
- Numbers are between 1 and 26
- Decode by finding the letter at each position
Errori comuni
- Confusing high numbers (is 20 T or U?)
- Not recognizing common patterns (15=O, 5=E)
- Mixing up single and double digit parsing
Soluzione passo per passo
Decodifica la sequenza 19-21-14
- 19 è la 19a lettera = S
- 21 è la 21a lettera = U
- 14 è la 14a lettera = N
Risposta: SUN
Impara 3
Cifrario Atbash
Ogni lettera è sostituita dal suo speculare nell'alfabeto (A in Z, B in Y, ecc.).
The Atbash cipher is an ancient Hebrew substitution cipher that replaces each letter with the letter at the opposite end of the alphabet. A becomes Z, B becomes Y, C becomes X, and so on. The pattern is symmetric: encoding and decoding use the same operation.
A to Z, B to Y, C to X, D to W, E to V, F to U, G to T, H to S, I to R, J to Q, K to P, L to O, M to N
- HELLO -> SVOOL
- CAT -> XZG
- WIZVM -> DREAM
Come riconoscerlo
- Each letter maps to its 'mirror' position
- A always becomes Z, Z always becomes A
- Encoding and decoding are identical operations
Errori comuni
- Confusing middle letters (L->O, M->N)
- Not recognizing the symmetric pattern
- Forgetting that the same operation encodes and decodes
Soluzione passo per passo
Codifica 'HELLO' con il cifrario Atbash
- H è l'8a lettera. Il suo speculare è l'8a dalla fine = S
- E è la 5a lettera. Il suo speculare è la 5a dalla fine = V
- L è la 12a lettera. Il suo speculare è la 12a dalla fine = O
- L di nuovo diventa O
- O è la 15a lettera. Il suo speculare è la 15a dalla fine = L
Risposta: SVOOL
Impara 4
Cifrario di Cesare
Ogni lettera viene spostata di un numero fisso di posizioni nell'alfabeto.
The Caesar cipher shifts each letter by a fixed number of positions. If the shift is 3, A becomes D, B becomes E, and so on. At the end of the alphabet, it wraps around: X→A, Y→B, Z→C (with shift 3). Named after Julius Caesar who reportedly used a shift of 3 for military messages.
Shifted letter = (Original position + Shift) mod 26. With shift=3: A→D, B→E, C→F, ..., X→A, Y→B, Z→C
- Shift 1: CAT → DBU
- Shift 3: HELLO → KHOOR
- Shift 5: APPLE → FUUQJ
Come riconoscerlo
- All letters shifted by the same amount
- Key shows consistent pattern (A→D, B→E means shift 3)
- Wraps around at Z back to A
Errori comuni
- Forgetting to wrap around (Y+3 should be B, not beyond Z)
- Shifting in the wrong direction for decoding
- Not identifying the shift value from given examples
Soluzione passo per passo
Codifica 'HELLO' con cifrario di Cesare spostamento 3
- H è l'8a lettera. Aggiungi 3: posizione 11 = K
- E è la 5a lettera. Aggiungi 3: posizione 8 = H
- L è la 12a lettera. Aggiungi 3: posizione 15 = O
- L di nuovo: posizione 15 = O
- O è la 15a lettera. Aggiungi 3: posizione 18 = R
Risposta: KHOOR
Impara 5
Sostituzione con Simboli
Le lettere sono sostituite con simboli secondo una chiave data.
Symbol substitution codes replace letters with symbols (@, #, $, %, etc.) according to a provided key. Unlike alphabetic shifts, there's no predictable pattern—you must use the key exactly as given. The key may only cover some letters, with others following a different rule.
A=@, B=#, C=$, etc. (as specified in key)
- If A=@, B=#, C=$ then ABC = @#$
- If X=!, Y=?, Z=* then XYZ = !?*
- Decode #@$ using A=@, B=#, C=$ → BAC
Come riconoscerlo
- Message contains symbols not normally in words
- A key is provided mapping letters to symbols
- No predictable pattern—must use the key
Errori comuni
- Trying to find a pattern instead of using the key
- Confusing similar-looking symbols
- Misreading which symbol maps to which letter
Soluzione passo per passo
Decodifica '#@$' usando la chiave: A=@, B=#, C=$
- Cerca # nella chiave: B=#, quindi # = B
- Cerca @ nella chiave: A=@, quindi @ = A
- Cerca $ nella chiave: C=$, quindi $ = C
Risposta: BAC
Impara 6
Codici Combinati
Più regole di codifica vengono applicate in sequenza.
Combined codes apply multiple transformations in sequence. For example, first reverse the alphabet, then shift by 2. Or first convert to numbers, then apply an operation. These are more complex because you must apply each rule in the correct order. The key will usually show the final result.
Apply Rule 1 to get intermediate result, then apply Rule 2 to get final result
- Reverse then shift 1: A→Z→A (reverse gives Z, shift gives A)
- Shift 2 then reverse: A→C→X (shift gives C, reverse gives X)
- Number + 5: A=1+5=6, B=2+5=7, etc.
Come riconoscerlo
- Key doesn't match any single simple pattern
- May need to work backwards to identify rules
- Look for two-step transformations in examples
Errori comuni
- Applying rules in the wrong order
- Trying to find a single rule when two are needed
- Not checking your work by encoding back
Soluzione passo per passo
Codifica 'AB' con: prima spostamento +2, poi inverti alfabeto
- Passo 1: Sposta A di +2 → C
- Passo 2: Inverti C → X (C è 3a, X è 3a dalla fine)
- Passo 1: Sposta B di +2 → D
- Passo 2: Inverti D → W (D è 4a, W è 4a dalla fine)
Risposta: XW
Impara 7
Quadrato di Polibio
Le lettere sono codificate come coppie di coordinate in una griglia 5x5.
The Polybius square is a cipher invented by the Greek historian Polybius around 150 BCE. Letters are arranged in a 5x5 grid, and each letter is represented by its row and column numbers. Since there are 26 letters but only 25 cells, I and J share a position.
Grid: Row 1 (ABCDE), Row 2 (FGHIK), Row 3 (LMNOP), Row 4 (QRSTU), Row 5 (VWXYZ). A=11, B=12, ... I/J=24, ... Z=55
- CAT -> 13 11 44
- HELLO -> 23 15 31 31 34
- DOG -> 14 34 22
Come riconoscerlo
- Two-digit numbers representing coordinates
- First digit is row (1-5), second is column (1-5)
- I and J encode to the same value (24)
Errori comuni
- Confusing row and column order
- Forgetting I/J share a cell
- Not recognizing the 5x5 grid pattern
Soluzione passo per passo
Codifica 'CAT' con il quadrato di Polibio
- La griglia: Riga 1 = ABCDE, Riga 2 = FGHIK, Riga 3 = LMNOP, Riga 4 = QRSTU, Riga 5 = VWXYZ
- C è in Riga 1, Colonna 3 → 13
- A è in Riga 1, Colonna 1 → 11
- T è in Riga 4, Colonna 4 → 44
Risposta: 13 11 44
Impara 8
Cifrario a Spostamento Variabile
Ogni lettera viene spostata del suo numero di posizione (1ª +1, 2ª +2, ecc.).
Unlike the Caesar cipher where all letters shift by the same amount, the variable shift cipher uses position-dependent shifting. The first letter shifts by 1, the second by 2, and so on. This makes the cipher harder to break since the same letter can encode differently based on its position.
Letter at position N shifts forward by N positions. Position 1: +1, Position 2: +2, Position 3: +3, etc.
- CAT -> D(C+1) C(A+2) W(T+3) = DCW
- HELLO -> I(H+1) G(E+2) O(L+3) P(L+4) T(O+5) = IGOPT
Come riconoscerlo
- Different shifts for each position
- First letter always shifts by 1
- Pattern: 1st +1, 2nd +2, 3rd +3...
Errori comuni
- Using same shift for all letters
- Forgetting to wrap around Z back to A
- Miscounting positions (starting from 0 vs 1)
Soluzione passo per passo
Codifica 'CAT' con spostamento variabile (posizione 1 = +1, posizione 2 = +2, ecc.)
- C è alla posizione 1. Sposta +1: C (3a lettera) + 1 = D
- A è alla posizione 2. Sposta +2: A (1a lettera) + 2 = C
- T è alla posizione 3. Sposta +3: T (20a lettera) + 3 = W
Risposta: DCW
Impara 9
Codice Vocale-Consonante
Le vocali e le consonanti seguono regole di spostamento diverse.
This cipher applies different transformation rules to vowels (A, E, I, O, U) versus consonants. Typically, vowels shift by one amount while consonants shift by another. This creates two parallel encoding systems within the same cipher.
Vowels (A,E,I,O,U) shift by X positions. Consonants shift by Y positions.
- With vowels +1, consonants +2: CAT -> E(C+2) B(A+1) V(T+2) = EBV
- WATER -> Y(W+2) B(A+1) V(T+2) F(E+1) T(R+2) = YBVFT
Come riconoscerlo
- Two different shift patterns
- Identify vowels vs consonants first
- Vowels: A, E, I, O, U; all others are consonants
Errori comuni
- Applying wrong shift to vowels/consonants
- Forgetting Y is a consonant (not a vowel)
- Not identifying which shift applies to which group
Soluzione passo per passo
Codifica 'CAT' con vocali +1, consonanti +2
- C è una consonante. Sposta +2: C (3a) + 2 = E
- A è una vocale. Sposta +1: A (1a) + 1 = B
- T è una consonante. Sposta +2: T (20a) + 2 = V
Risposta: EBV
Impara 10
Cifrario Tastiera
Le lettere si spostano lungo la loro riga nella tastiera QWERTY.
The keyboard cipher shifts letters within their QWERTY keyboard row. Q-W-E-R-T-Y-U-I-O-P form the top row, A-S-D-F-G-H-J-K-L the middle row, and Z-X-C-V-B-N-M the bottom row. Each letter shifts to an adjacent letter in its row, wrapping around at the end.
Top row: QWERTYUIOP, Middle row: ASDFGHJKL, Bottom row: ZXCVBNM. Shift right within each row.
- Shift 1: CAT -> V(C->V) S(A->S) Y(T->Y)
- Shift 1: DOG -> F(D->F) P(O->P) H(G->H)
Come riconoscerlo
- Letters stay in their keyboard row
- Adjacent letters on keyboard
- Q->W, A->S, Z->X pattern
Errori comuni
- Not visualizing the keyboard layout
- Confusing which row a letter belongs to
- Forgetting row wrap-around (P->Q, L->A, M->Z)
Soluzione passo per passo
Codifica 'DOG' con spostamento tastiera +1
- Righe tastiera: Alta = QWERTYUIOP, Media = ASDFGHJKL, Bassa = ZXCVBNM
- D è nella riga media. Sposta +1 → F
- O è nella riga alta. Sposta +1 → P
- G è nella riga media. Sposta +1 → H
Risposta: FPH
Impara 11
Parola Invertita
La parola è scritta al contrario (trasposizione, non sostituzione).
Unlike substitution ciphers that replace letters, the reverse word cipher is a transposition cipher that rearranges the order of letters. The word is simply spelled backwards. This is one of the simplest ciphers but represents a fundamentally different approach to encoding.
Read letters from right to left. WORD -> DROW
- WATER -> RETAW
- HELLO -> OLLEH
- STAR -> RATS
Come riconoscerlo
- No letter substitution occurs
- Same letters in reversed order
- Read backwards to decode
Errori comuni
- Looking for letter substitution patterns
- Not recognizing it as simple reversal
- Confusing with Atbash (reverse alphabet)
Soluzione passo per passo
Codifica 'WATER' invertendola
- Scrivi la parola: W-A-T-E-R
- Leggi da destra a sinistra: R è ora il primo
- E è il secondo
- T è il terzo
- A è il quarto, W è l'ultimo
Risposta: RETAW
Impara 12
Cifrario a Salto
Le lettere vengono riorganizzate prendendo posizioni alternate.
The skip cipher is a transposition cipher that rearranges letters by extracting them at regular intervals. In the basic form, odd-positioned letters (1st, 3rd, 5th...) are written first, followed by even-positioned letters (2nd, 4th, 6th...). This scrambles the word without changing any individual letters.
Take positions 1,3,5... then 2,4,6... Example: WATER (W1,A2,T3,E4,R5) -> WTR + AE = WTRAE
- WATER -> WTRAE
- HELLO -> HLOEL
- STARS -> SASRT
Come riconoscerlo
- Same letters, different order
- Pattern: odd positions first, then even
- No letter substitution
Errori comuni
- Looking for substitution patterns
- Miscounting odd/even positions
- Forgetting which set comes first
Soluzione passo per passo
Codifica 'WATER' con il cifrario a salto
- Numera le posizioni: W(1) A(2) T(3) E(4) R(5)
- Estrai posizioni dispari (1, 3, 5): W, T, R
- Estrai posizioni pari (2, 4): A, E
- Combina: dispari prima, poi pari
Risposta: WTRAE
Impara 13
Codifica Binaria
Rappresenta la posizione di ogni lettera nell'alfabeto come numero in base 2.
La codifica binaria usa solo le cifre 0 e 1. Ogni posizione rappresenta una potenza di 2: a destra 2^0 = 1, poi 2^1 = 2, 2^2 = 4, ecc. Per codificare una lettera, associala al suo indice alfabetico (A=1 ... Z=26) e converti in binario. Cinque bit bastano per tutte le 26 lettere.
Lettera → posizione → binario
- A (= 1) → 00001
- M (= 13) → 01101
- Z (= 26) → 11010
- 1011₂ = 8 + 0 + 2 + 1 = 11
Come riconoscerlo
- Compaiono solo le cifre 0 e 1
- Ogni gruppo è tipicamente di 5 bit
- Decodificare richiede interpretare ogni gruppo in base 2
Errori comuni
- Mescolare A=0 e A=1
- Leggere i bit nel verso sbagliato
- Usare potenze di 10 invece di 2
Impara 14
Codifica Tastiera Telefonica (Multi-tap)
Codifica lettere come coppie (tasto, pressione) secondo la tastiera ITU E.161.
Su una tastiera telefonica standard ITU E.161, le lettere sono raggruppate sotto le cifre 2–9: 2=ABC, 3=DEF, 4=GHI, 5=JKL, 6=MNO, 7=PQRS (quattro lettere), 8=TUV, 9=WXYZ (quattro lettere). Nel multi-tap, ogni lettera è rappresentata dal suo tasto più il numero di pressioni — A = 2-1, ..., Z = 9-4. Insensibile al caso; 0 e 1 non sono usati.
lettera → (tasto, pressione)
- HELLO → 4-2 3-2 5-3 5-3 6-3
- ABC → 2-1 2-2 2-3
- Z → 9-4
Come riconoscerlo
- Cifre 2–9 accoppiate a 1–4
- 0 e 1 non compaiono come primo numero
- Viene citata la disposizione 2=ABC ... 9=WXYZ
Errori comuni
- Dimenticare che 7 e 9 hanno quattro lettere
- Iniziare il conteggio da 0
- Assegnare lettere a 1 o 0
Impara 15
Cifrario a Staccionata (Rail Fence)
Un cifrario di trasposizione che scrive il testo in chiaro a zig-zag su N binari e legge il cifrato riga per riga.
Nel cifrario a staccionata, il testo in chiaro è scritto in diagonale verso il basso e verso l'alto su un numero di 'binari', formando un motivo a zig-zag. Il testo cifrato viene letto riga per riga. Il numero di binari N è la chiave. È una trasposizione pura — nessuna lettera viene sostituita — quindi le frequenze corrispondono a quelle del testo in chiaro.
Scrivere M a zig-zag su N binari; leggere riga per riga per C
- HELLOWORLD, 3 binari → HOLELWRDLO
- 'WE ARE DISCOVERED' con 3 binari
- La decifratura inverte lo zig-zag con il numero di binari noto
Come riconoscerlo
- È specificato un numero di binari
- Il testo cifrato contiene esattamente le stesse lettere del chiaro
- Le frequenze corrispondono alla lingua originale
Errori comuni
- Confonderlo con un cifrario a sostituzione
- Leggere male lo zig-zag
- Usare il numero di binari sbagliato
Impara 16
Cifrario ROT13
Un cifrario di Cesare con spostamento fisso di 13 che è l'inverso di sé stesso per l'alfabeto latino di 26 lettere.
ROT13 sostituisce ogni lettera con quella 13 posizioni dopo nell'alfabeto, con ritorno all'inizio: A↔N, B↔O, C↔P, ..., M↔Z. Poiché 13 è esattamente metà di 26, applicarlo due volte restituisce il testo originale — il cifrario è l'inverso di sé stesso. Maiuscole/minuscole e caratteri non alfabetici restano invariati.
E(x) = (x + 13) mod 26
- HELLO → URYYB
- CLAUDE → PYNHQR
- ROT13(ROT13(x)) = x
Come riconoscerlo
- Ogni lettera è spostata dello stesso importo
- Applicare due volte restituisce l'originale
- A↔N, B↔O, C↔P sono le coppie classiche
Errori comuni
- Confondere ROT13 con atbash (che inverte l'alfabeto)
- Applicare lo spostamento a cifre o punteggiatura
- Spostare di 12 o 14 invece di esattamente 13
Impara 17
Cifrario di Vigenère
Un cifrario polialfabetico a sostituzione che usa una parola chiave ripetuta per determinare lo spostamento di ciascuna lettera.
Il cifrario di Vigenère cifra ogni lettera del testo in chiaro con uno spostamento alla Cesare la cui ampiezza è determinata dalla lettera corrispondente di una chiave ripetuta. Con A=0, ..., Z=25: C_i = (M_i + K_i) mod 26 e M_i = (C_i − K_i) mod 26. Ciò neutralizza l'analisi di frequenza semplice.
C_i = (M_i + K_i) mod 26; M_i = (C_i − K_i) mod 26
- HELLO con chiave KEY → RIJVS
- ATTACK con chiave LEMON → LXFOPV
- Una chiave AAAA riduce Vigenère a Cesare con spostamento 0
Come riconoscerlo
- Viene fornita una chiave insieme al testo cifrato
- La stessa lettera cifrata non corrisponde sempre alla stessa lettera in chiaro
- Le frequenze sono più piatte di un cifrario monoalfabetico
Errori comuni
- Dimenticare di ripetere la chiave
- Usare A=1 invece di A=0
- Sottrarre invece di sommare durante la cifratura
Esempi svolti
Gli esempi svolti conservano la serie originale per ogni difficoltà. Aprine uno per confrontare consegna, opzioni, risposta corretta e spiegazione.