Symmetric encryption · Criptografia simétrica
Locking with a key
- Encryption scrambles a message so only someone with the key can read it.
- In symmetric encryption, the same key locks and unlocks. Sender and receiver must both know it.
Trancando com uma chave
- Criptografia embaralha uma mensagem para que apenas alguém com a chave possa lê-la.
- Na criptografia simétrica, a mesma chave tranca e destranca. Remetente e destinatário devem conhecê-la.
The Caesar cipher
- The oldest example: shift every letter forward by a fixed number. With shift 3,
a → d,b → e, and so on. - The key is the shift. Decrypting just shifts back.
O Cifra de César
- O exemplo mais antigo: desloque cada letra para frente por um número fixo. Com deslocamento 3,
a → d,b → ee assim por diante. - A chave é o deslocamento. Descriptografar basta voltar o deslocamento.
text = "attack"
shift = 3
out = "".join(chr((ord(c) - 97 + shift) % 26 + 97) for c in text)
print(out) # dwwdfn
Why Caesar is weak
- There are only 25 possible shifts, so a computer can try them all in a blink.
- This is a brute-force attack on the key — exactly what real encryption must resist.
Por que César é fraco
- Existem apenas 25 deslocamentos possíveis, então um computador pode testá-los todos em um piscar de olhos.
- Este é um ataque de força bruta na chave — exatamente o que a criptografia real deve resistir.
What real ciphers do
- Modern symmetric ciphers like AES use keys with billions of billions of possibilities.
- The big problem they leave: how do two people share the secret key safely? The next lesson solves it.
Covers: IGCSE 2.3 (symmetric encryption), A-Level 17.1.
O que cifras reais fazem
- Cifras simétricas modernas como AES usam chaves com bilhões de bilhões de possibilidades.
- O grande problema que elas deixam: como duas pessoas compartilham a chave secreta com segurança? A próxima aula resolve isso.
Cobertura: IGCSE 2.3 (criptografia simétrica), A-Level 17.1.
Common mistakes
- One shared key both encrypts and decrypts.
- The hard part is sharing that key safely.
Erros comuns
- Uma chave compartilhada tanto encripta quanto descriptografa.
- A parte difícil é compartilhar essa chave com segurança.
Symmetric encryption · Criptografia simétrica
The Caesar cipher uses one shared key to encrypt and decrypt. · O ciframento César usa uma chave compartilhada para criptografar e descriptografar.
Encrypt hello with a Caesar cipher · Cifra César: shift each letter forward by shift places (wrapping past z back to a). Build the encrypted string and print it. · Criptografe hello com uma cifra de César: desloque cada letra para frente em shift posições (envolvendo de z para a). Construa a string criptografada e imprima-a.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.
Now break it — that is why Caesar is weak. You intercepted cipher, and you suspect the plaintext is attack. Try every shift from 1 to 25, shifting back · para trás, and print the shift that turns cipher into · em attack. · Agora quebre-o — é por isso que César é fraco. Você interceptou cipher e suspeita que o plaintext é attack. Tente todo deslocamento de 1 a 25, deslocando para trás, e imprima o deslocamento que transforma cipher em attack.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.