Symmetric encryption · 対称暗号化
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.
鍵によるロック
- 暗号化はメッセージをかき混ぜ、鍵を持つ者のみ読み取れるようにします。
- 対称暗号化では、同じ鍵でロック(暗号化)とアンロック(復号化)を行います。送受信者双方がこの鍵を知っている必要があります。
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.
ケーサー暗号
- 最古の例:すべての文字を一定の数を前へシフトさせる。シフト量が3の場合、
a → d、b → e、などとなる。 - 鍵はシフト量である。復号化は単に逆方向へシフトするだけだ。
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.
ケーサー暗号が弱い理由
- シフト可能なパターンは25通りしかなく、コンピュータは瞬時にすべてを試せる。
- これは鍵に対するブルートフォース攻撃であり、これが現実の暗号化が耐えなければならないものと同じだ。
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.
現代の暗号が果たす役割
- AESなどの現代の対称暗号は、何兆億もの可能性を持つ鍵を使用する。
- しかし彼らが残す最大の課題:二人がどうやって秘密の鍵を安全に共有するか? 次のレッスンで解決する。
対象: IGCSE 2.3 (対称暗号化), A-Level 17.1.
Common mistakes
- One shared key both encrypts and decrypts.
- The hard part is sharing that key safely.
よくあるミス
- 一つの共有鍵で暗号化も復号化も行う。
- その難関は、その鍵を安全に共有することにある。
Symmetric encryption · 対称暗号化
The Caesar cipher uses one shared key to encrypt and decrypt. · シーザー暗号は、暗号化と復号化に一つの共有鍵を使用します。
Encrypt hello with a Caesar cipher: shift each letter forward by shift places (wrapping past z back to a). Build the encrypted string and print it. · hello をシーザー暗号で暗号化します。各文字を shift だけ前方へシフトさせ(zを超えてaに戻る)、暗号化した文字列を構築して印刷します。
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。
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, and print the shift that turns cipher into attack. · 次にこれを破ります——これがシーザー暗号が脆弱である理由です。cipher を盗聴しましたが、明文中が attack だと推測しています。1 から 25 までのすべてのシフト尝试し、逆方向にシフトして、cipher が attack に変換されるシフト数を印刷します。
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。