Python Capstone Project On Message Encrypter and Decrypter
Python Capstone Project On Message Encrypter and Decrypter
ON
Project Title: Message Encrypter and Decrypter
Section: K21MD
Submitted by: - KARRI JOHN PRADEEP REDDY.
Reg. No: 12109211
Signature
Name of the Mentor
2 CERTIFICATE 3
3 ABSTRACT 5
4 INTRODUCTION 6
5 OBJECTIVE 6-7
6 DESCRIPTION 7-8
8 OUTPUT 19-21
9 SCOPE OF PROJECT 22
10 FUTURE DEVELOPMENT OF 23
PROJECT
11 CONCLUSION 24
ABSTRACT
OBJECTIVE
DESCRIPTION
The code is a simple encryption and decryption tool built using the Python
programming language and the tkinter library for the GUI. The objective of
the code is to allow users to choose an algorithm using toggle buttons
where window 1 and window 2 for base 64 and AES algorithms
respectively. To input a message and a key and either encrypt or decrypt
the message using an algorithm. AES algorithm uses only 16 and 32 bit
key the key should be provided by the user. Base 64 uses a normal key.
The GUI interface is designed to make it easy for users to input the
message and key and select whether they want to encrypt or decrypt the
message. The interface consists of several input fields and buttons,
including:
→"Window 1" toggle button: this is used to choose base 64 algorithm.
→"Window 2" toggle button: this is used to choose AES algorithm.
The following fields are same for both the algorithms
→"Enter the Message" field: this is where the user inputs the message they
want to encrypt or decrypt.
→"Enter the key" field: this is where the user inputs the key they want to
use for encryption or decryption.
→"Encrypt" and "Decrypt" radio buttons: the user selects one of these
buttons to specify whether they want to encrypt or decrypt the message.
"Result" field: this displays the encrypted or decrypted message after the
user has clicked the "Show Message" button.
→"Show Message" button: when clicked, this button executes the
encryption or decryption function based on the user's input and displays the
result in the "Result" field.
→"Reset" button: when clicked, this button clears all input fields and the
→"Result" field.
→"Exit" button: when clicked, this button closes the GUI window. The
encryption and decryption functions both use a simple substitution cipher
algorithm that takes each character in the input message and shifts it by a
corresponding character in the key. The resulting encrypted or decrypted
message is then encoded in base64 format for security purposes.
CODE:
import tkinter as tk
from tkinter import *
import base64
from tkinter import messagebox
import tkinter.font as font
def show_window(window):
window.deiconify()
def hide_window(window):
window.withdraw()
def toggle_window():
if window1.winfo_viewable():
hide_window(window1)
show_window(window2)
var.set(2)
else:
hide_window(window2)
show_window(window1)
var.set(1)
#Decoding Function
def decode(key, code):
aes = AES.new(key, AES.MODE_ECB)
decrypted_message = aes.decrypt(base64.b64decode(code)).decode()
unpadded_message = decrypted_message[:-ord(decrypted_message[-1])]
print(unpadded_message)
return unpadded_message
#window1 = Tk()
window1.geometry("500x500")
window1.configure(bg='azure2')
window1.title("Encrypter and Decrypter ")
Message = StringVar()
key = StringVar()
mode = IntVar()
Output = StringVar()
headingFrame1 = Frame(window1,bg="gray91",bd=5)
headingFrame1.place(relx=0.2,rely=0.1,relwidth=0.7,relheight=0.16)
headingLabel = Label(headingFrame1, text=" Welcome to Encryption and
\nDecryption Using AES", fg='grey19', font=('Courier',13,'bold'))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)
##---base64 Window---##
window2 = tk.Toplevel(root)
window2.title("Window 2")
window2.geometry("200x200")
label2 = tk.Label(window2, text="This is window 2")
label2.pack()
#Encoding Function
def encode(key, msg):
enc = []
for i in range(len(msg)):
list_key = key[i % len(key)]
list_enc = chr((ord(msg[i]) +
ord(list_key)) % 256)
enc.append(list_enc)
return base64.urlsafe_b64encode("".join(enc).encode()).decode()
#Decoding Function
def decode(key, code):
dec = []
enc = base64.urlsafe_b64decode(code).decode()
for i in range(len(enc)):
list_key = key[i % len(key)]
list_dec = chr((256 + ord(enc[i]) - ord(list_key)) % 256)
dec.append(list_dec)
return "".join(dec)
#window2 = Tk()
window2.geometry("500x500")
window2.configure(bg='azure2')
window2.title("Encrypter and Decrypter ")
Message = StringVar()
key = StringVar()
mode = IntVar()
Output = StringVar()
headingFrame1 = Frame(window2,bg="gray91",bd=5)
headingFrame1.place(relx=0.2,rely=0.1,relwidth=0.7,relheight=0.16)
OUTPUT OF PROJECT:
SCOPE OF PROJECT
The program allows the user to choose an encryption algorithm and enter a
message, enter a key and select whether to encrypt or decrypt the message.
The user interface provides easy-to-use buttons and input fields to facilitate
the process. The program then applies a basic encryption algorithm to the
message, which involves converting the message into a string of ASCII
characters, adding the corresponding key value to each character, and then
encoding the resulting string in base64.
Certainly! there are some ways we could make the cryptography program
better and more futuristic:
Use a database: By adding a database, users could securely store and access
their encrypted data at a later time.
Support different file types: The current program only works with text-
based input, but we could make it work with images, audio, and video as
well. Add cloud storage support: If we add support for popular cloud
storage services like Google Drive and Dropbox, users could securely store
and access their encrypted data from anywhere in the world.