Free Friday: 12/5/25

Today, I watched a video and created a simple substitution cipher program using Python. I learned how to encrypt and decrypt messages using a random key from this video. The program takes a message from the user, replaces each character with a randomly shuffled character, and then letsthe message to be decrypted back to its original form.

SNIPPET:

#ENCRYPT
plain_text = input("Enter a message to encrypt: ")
cipher_text = ""

for letter in plain_text:
    index = chars.index(letter)
    cipher_text += key[index]

print(f"original message : {plain_text}")
print(f"encrypted message: {cipher_text}")

^This part handles encryption. It goes through each character of the user’s message, it finds its position in the original list, and it replaces it with the corresponding character in the shuffled key. The program then prints both the original and encrypted messages.

Leave a Reply

Your email address will not be published. Required fields are marked *