0% found this document useful (0 votes)
23 views6 pages

Bis Project

The document presents a micro project report on encryption and decryption using the Caesar Cipher method, implemented in Python. It includes a program that allows users to encrypt and decrypt messages based on a specified key, with a simple command-line interface. The report details the encryption and decryption functions, as well as the main program structure for user interaction.

Uploaded by

kajalshrma7703
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views6 pages

Bis Project

The document presents a micro project report on encryption and decryption using the Caesar Cipher method, implemented in Python. It includes a program that allows users to encrypt and decrypt messages based on a specified key, with a simple command-line interface. The report details the encryption and decryption functions, as well as the main program structure for user interaction.

Uploaded by

kajalshrma7703
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

BIS MICRO PROJECT

AN MICRO PROJRCT REPORT ON


ENCRYPTION & DECRYPTION USING CAESAR
CIPHER

Submitted by

KASHISH MAHOVIA (216300307006)


KARINA SHARMA (226300307120 )
PRUTHA PANCHAL (226300307078)

Student of

Diploma In Engineering
in

computer Department
Project Overview:
 The project will consist of:
 A Python program to encrypt and decrypt messages.
 A simple user interface (command-line) where the user can input a message and choose
to either encrypt or decrypt it using a key (shift value).

Encryption Algorithm - Caesar Cipher:

 Encryption: The plaintext is shifted by a key value. For example, if the key is 3, 'A'
becomes 'D', 'B' becomes 'E', and so on.
 Decryption: The ciphertext is shifted in the opposite direction by the same key to retrieve
the original message.

 CODE(python):
# Caesar Cipher Encryption and Decryption

def encrypt(plaintext, key):

"""Encrypts the plaintext using Caesar Cipher with a given key."""

ciphertext = ''

for char in plaintext:

# Encrypt only alphabets (both uppercase and lowercase)

if char.isalpha():

shift = key % 26 # Ensure key is within the alphabet range

start = ord('A') if char.isupper() else ord('a')

encrypted_char = chr(start + (ord(char) - start + shift) % 26)

ciphertext += encrypted_char

else:
# Non-alphabet characters remain unchanged

ciphertext += char

return ciphertext

def decrypt(ciphertext, key):

"""Decrypts the ciphertext using Caesar Cipher with a given key."""

plaintext = ''

for char in ciphertext:

# Decrypt only alphabets (both uppercase and lowercase)

if char.isalpha():

shift = key % 26 # Ensure key is within the alphabet range

start = ord('A') if char.isupper() else ord('a')

decrypted_char = chr(start + (ord(char) - start - shift) % 26)

plaintext += decrypted_char

else:

# Non-alphabet characters remain unchanged

plaintext += char

return plaintext

def main():

print("Welcome to Caesar Cipher Encryption/Decryption")

while True:

# Menu for the user to choose between encryption or decryption


choice = input("\nChoose an option:\n1. Encrypt a message\n2. Decrypt a message\n3.
Exit\nEnter your choice (1/2/3): ")

if choice == '1':

message = input("\nEnter the message to encrypt: ")

key = int(input("Enter the encryption key (an integer): "))

encrypted_message = encrypt(message, key)

print(f"Encrypted message: {encrypted_message}")

elif choice == '2':

message = input("\nEnter the message to decrypt: ")

key = int(input("Enter the decryption key (an integer): "))

decrypted_message = decrypt(message, key)

print(f"Decrypted message: {decrypted_message}")

elif choice == '3':

print("Exiting the program...")

break

else:

print("Invalid choice, please try again.")

if __name__ == "__main__": main()


How It Works:

 Encrypt Function:

The encrypt() function shifts each letter of the input message by the specified key
(integer). The shift is done modulo 26 to keep the result within the alphabet
range.

Non-alphabet characters (such as spaces, punctuation) remain unchanged.

 Decrypt Function:

The decrypt() function works similarly but shifts the letters back in the opposite
direction to recover the original message.

 Main Program:

The user is presented with a menu to choose between encrypting a message,


decrypting a message, or exiting the program.

Depending on the user's choice, they are prompted to input the message and key
(shift value).

OUTPUT SCREENSHORT :

You might also like