You are on page 1of 3

ARUSHA TECHNICAL COLLEGE

DEPARTMENT: INFORMATION COMMUNICATION TECHNOLOGY


PROGRAM: COMPUTER SCIENCE
NAME: DONALD DONALD MWAKATOGA
ADMISSION: 21050513023
Objective:
Demonstrating the Caesar cipher's implementation in Python.
Programing language used:
Python programing language
Methodology used to implement Caesar Cipher encryption using Python language
The Caesar Cipher encryption algorithm is implemented in this Python code, which requests
a plain text message from the user along with an alphabet shift key. An array is initialized to
hold the alphabet, and another is initialized to hold the encrypted text. The program searches
the alphabet array for matches as iteratively goes over each character in the user-provided
plain text. It uses the key to determine the encrypted character's index for each match, then
saves the result in the encrypted text array. With the assumption that the input consists solely
of lowercase letters, the software outputs the encrypted text that results.

# Get user input for the plain text to encrypt


plain_text = input("Please give us plain text to encrypt: \t")

# Get user input for the key used in the cipher and convert it to an integer
key = int(input("Please give us the key for the cipher: \t"))

# Define the alphabet as a string


alphabets = 'abcdefghijklmnopqrstuvwxyz'

# Initialize an empty string to store the encrypted text


cypher_text = ''

# Iterate through each character in the input plain text


for char in plain_text:
# Check if the character is in the alphabet
if char in alphabets:
# Calculate the index of the encrypted character and wrap around using modulus
cyphered_char_index = (alphabets.index(char) + key) % 26
# Append the encrypted character to the cypher_text string
cypher_text += alphabets[cyphered_char_index]

# Print the final encrypted text


print(cypher_text)

Results:
The application uses the Caesar Cipher and input cryptographic key to encrypt the plain text
and successfully encrypted.

You might also like