Lesson Plan: Creating a Caesar Cipher

Lesson Overview

In this lesson, students will learn about the Caesar cipher, a simple encryption technique. They will then implement their own Caesar cipher encoder and decoder using Python.

Learning Objectives

Lesson Structure

1. Introduction to Cryptography (10 min)

- Brief history of cryptography.
- Overview of substitution ciphers.
- Explanation of the Caesar cipher:

2. Pseudocode for Caesar Cipher (10 min)

Discuss the logic:

3. Implementing the Caesar Cipher in Python (20 min)

Step 1: Writing the encryption function

def caesar_cipher_encrypt(text, shift): encrypted_text = "" for char in text: if char.isalpha(): shift_amount = shift % 26 new_char = chr(((ord(char.lower()) - ord('a') + shift_amount) % 26) + ord('a')) encrypted_text += new_char.upper() if char.isupper() else new_char else: encrypted_text += char # Preserve spaces and punctuation return encrypted_text

Step 2: Writing the decryption function

def caesar_cipher_decrypt(text, shift): return caesar_cipher_encrypt(text, -shift)

Step 3: Testing the functions

message = "Hello, World!" shift_value = 3 encrypted_message = caesar_cipher_encrypt(message, shift_value) decrypted_message = caesar_cipher_decrypt(encrypted_message, shift_value) print(f"Original: {message}") print(f"Encrypted: {encrypted_message}") print(f"Decrypted: {decrypted_message}")

4. Enhancements & Challenges (15 min)

5. Q&A and Wrap-up (5 min)

Assessment