Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
417 views

Python Capstone Project On Message Encrypter and Decrypter

This document describes a Python program that provides a graphical user interface for encrypting and decrypting messages. The program uses the Tkinter library to create two windows - one for encryption/decryption using the base64 algorithm, and one for the AES algorithm. It includes functions for encoding and decoding messages along with the corresponding keys. The interface allows the user to input a message and key, select encryption or decryption, and view the output. Buttons are also included to reset the fields and exit the program. The goal is to provide an easy-to-use tool for encrypting and securing messages with different algorithms.

Uploaded by

john pradeep
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
417 views

Python Capstone Project On Message Encrypter and Decrypter

This document describes a Python program that provides a graphical user interface for encrypting and decrypting messages. The program uses the Tkinter library to create two windows - one for encryption/decryption using the base64 algorithm, and one for the AES algorithm. It includes functions for encoding and decoding messages along with the corresponding keys. The interface allows the user to input a message and key, select encryption or decryption, and view the output. Buttons are also included to reset the fields and exit the program. The goal is to provide an easy-to-use tool for encrypting and securing messages with different algorithms.

Uploaded by

john pradeep
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

INT216 CAPSTRONE- PROJECT

ON
Project Title: Message Encrypter and Decrypter
Section: K21MD
Submitted by: - KARRI JOHN PRADEEP REDDY.
Reg. No: 12109211

Roll No: RK21MPB42


Under the Guidance of
(VED PRAKASH CHAUBEY)

School of Computer Science and Engineering


DECLARATION
We here by declare that the project work entitled “Message Encrypter and
Decrypter” is an authentic record of our own work carried out as
requirements of Capstone Project for the award of B. Tech degree in Python
Project from Lovely Professional University, Phagwara, under the guidance
of Mr Ved Prakash Chaubey , during January to May 2023. All the
information furnished in this capstone project report is based on our own
intensive work and is genuine.
Name of Student: Karri John Pradeep Reddy
Registration Number: 12109211
CERTIFICATE
This is to certify that the declaration statement made by this group of
students is correct to the best of my knowledge and belief. They have
completed this Capstone Project under my guidance and supervision. The
present work is the result of their original investigation, effort, and study.
No part of the work has ever been submitted for any other degree at any
University. The Capstone Project is fit for the submission and partial
fulfilment of the conditions for the award of B.Tech degree in from Lovely
Professional University, Phagwara.

Signature
Name of the Mentor

Designation School of Computer Science and Engineering, Lovely


Professional University, Phagwara, Punjab.
Date:
TABLE OF CONTENTS

SNO TITLE PAGE NUMBER


1 DECLARATION 2

2 CERTIFICATE 3

3 ABSTRACT 5

4 INTRODUCTION 6

5 OBJECTIVE 6-7

6 DESCRIPTION 7-8

7 SOURCE CODE 9-18

8 OUTPUT 19-21

9 SCOPE OF PROJECT 22

10 FUTURE DEVELOPMENT OF 23
PROJECT
11 CONCLUSION 24
ABSTRACT

Encryption and decryption are techniques used to protect sensitive


information by encoding it in such a way that only authorized parties can
access it. In Python, encryption and decryption can be implemented using
various algorithms such as Advanced Encryption Standard (AES), and
Rivest–Shamir–Adleman (RSA).

In this program, we use a simple encoding technique based on a given key


to encrypt and decrypt the user's input. The program is implemented using
the tkinter library, which provides a simple and easy-to-use graphical user
interface (GUI) for the user to input the message, key, and mode (either
encrypt or decrypt), and view the output.
The program uses a custom encoding function that takes the message and
key as inputs and returns an encoded message using the key. Similarly, the
program also uses a decoding function that takes the encoded message and
key as inputs and returns the original message.
The program provides a simple GUI that allows the user to input the
message, key, and mode, and displays the encoded or decoded message in
the output box. The user can also reset the inputs and output or exit the
program using the respective buttons.
Overall, this program provides a simple and easy-to-use interface for
encrypting and decrypting messages in Python, and can be extended to use
more advanced encryption techniques based on the specific needs of the
user.
INTRODUCTION

The code is a graphical user interface (GUI) program written in


Python using the tkinter library. It is an implementation of a simple
encryption and decryption algorithm that encodes a message using a
user-specified key and then decodes it using the same key. The
program provides a user-friendly interface with input fields for the
message and key and radio buttons to select between encryption and
decryption modes. The program is designed to be simple and easy to
use, making it an ideal tool for anyone who wants to secure their
messages without having to learn complex encryption techniques.

OBJECTIVE

The objective of the code is to create a simple GUI-based


encryption and decryption tool using Python and the Tkinter
library. The tool takes a message and a secret key as inputs, and
allows the user to choose whether to encrypt or decrypt the
message using the key.

The encryption and decryption process involves converting each


character in the message to a new character based on the
corresponding character in the secret key. The output of the
encryption or decryption process is then encoded using base64 to
ensure that it can be easily transmitted without any issues.
The GUI interface of the tool is designed using the Tkinter library,
which provides a simple and easy-to-use way to create user
interfaces in Python. The tool features a clear and intuitive layout,
with input fields for the message and key, radio buttons to select
between encryption or decryption, and an output field to display the
result of the encryption or decryption process. The tool also
includes options to reset the inputs and to exit the application.

Overall, the objective of the code is to provide a user-friendly and


simple tool for users to quickly and easily encrypt or decrypt
messages using a secret key which protects the sensitive
information

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)

# Create main window


root = tk.Tk()

# Create two sub-windows


window1 = tk.Toplevel(root)
window1.title("Window 1")
window1.geometry("200x200")
label1 = tk.Label(window1, text="This is window 1")
label1.pack()
#Encoding Function
def encode(key, msg):
aes = AES.new(key, AES.MODE_ECB)
padded_message = msg + (AES.block_size - len(msg) % AES.block_size)
* chr(AES.block_size - len(msg) % AES.block_size)
encrypted_message = aes.encrypt(padded_message.encode())
print(base64.b64encode(encrypted_message).decode())
return base64.b64encode(encrypted_message).decode()

#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

#Function that executes on clicking Show Message function


def Result():
msg = Message.get()
k= key.get().encode("utf8")
i=1
i = mode.get()
print(i)
if (i==1):
Output.set(encode(k, msg))
elif(i==2):
Output.set(decode(k, msg))
else:
messagebox.showinfo('Encrypter', 'Please Choose one of Encryption or
Decrption. Try again.')

#Function that executes on clicking Reset function


def Reset():
Message.set("")
key.set("")
mode.set(0)
Output.set("")

#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)

label1 = Label(window1, text='Enter the Message', font=('Courier',10))


label1.place(x=10,y=150)

msg = Entry(window1,textvariable=Message, width=35,


font=('calibre',10,'normal'))
msg.place(x=200,y=150)

label2 = Label(window1, text='Enter the key', font=('Courier',10))


label2.place(x=10,y=200)

InpKey = Entry(window1, textvariable=key,


width=35,font=('calibre',10,'normal'))
InpKey.place(x=200,y=200)

label3 = Label(window1, text='Check one of encrypt or decrypt',


font=('Courier',10))
label3.place(x=10,y=250)

Radiobutton(window1, text='Encrypt', variable=mode,


value=1).place(x=100,y=300)
Radiobutton(window1, text='Decrypt', variable=mode,
value=2).place(x=200,y=300)
label3 = Label(window1, text='Result', font=('Courier',10))
label3.place(x=10,y=350)

res = Entry(window1,textvariable=Output, width=35,


font=('calibre',10,'normal'))
res.place(x=200,y=350)

ShowBtn = Button(window1,text="Show Message",bg='lavender blush2',


fg='black',width=15,height=1,command=Result)
ShowBtn['font'] = font.Font( size=12)
ShowBtn.place(x=180,y=400)

ResetBtn = Button(window1, text='Reset', bg='honeydew2', fg='black',


width=15,height=1,command=Reset)
ResetBtn['font'] = font.Font( size=12)
ResetBtn.place(x=15,y=400)

QuitBtn = Button(window1, text='Exit', bg='old lace',


fg='black',width=15,height=1, command=window1.destroy)
QuitBtn['font'] = font.Font( size=12)
QuitBtn.place(x=345,y=400)

##---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)

#Function that executes on clicking Show Message function


def Result():
msg = Message.get()
k= key.get()
i = mode.get()
print(i)
if (i==1):
Output.set(encode(k, msg))
elif(i==2):
Output.set(decode(k, msg))
else:
messagebox.showinfo('Encrypter', 'Please Choose one of Encryption or
Decrption. Try again.')

#Function that executes on clicking Reset function


def Reset():
Message.set("")
key.set("")
mode.set(0)
Output.set("")

#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)

headingLabel = Label(headingFrame1, text=" Welcome to Encryption and


\nDecryption Using Base64", fg='grey19', font=('Courier',13,'bold'))
headingLabel.place(relx=0,rely=0, relwidth=1, relheight=1)

label1 = Label(window2, text='Enter the Message', font=('Courier',10))


label1.place(x=10,y=150)

msg = Entry(window2,textvariable=Message, width=35,


font=('calibre',10,'normal'))
msg.place(x=200,y=150)

label2 = Label(window2, text='Enter the key', font=('Courier',10))


label2.place(x=10,y=200)

InpKey = Entry(window2, textvariable=key,


width=35,font=('calibre',10,'normal'))
InpKey.place(x=200,y=200)

label3 = Label(window2, text='Check one of encrypt or decrypt',


font=('Courier',10))
label3.place(x=10,y=250)
Radiobutton(window2, text='Encrypt', variable=mode,
value=1).place(x=100,y=300)
Radiobutton(window2, text='Decrypt', variable=mode,
value=2).place(x=200,y=300)

label3 = Label(window2, text='Result', font=('Courier',10))


label3.place(x=10,y=350)

res = Entry(window2,textvariable=Output, width=35,


font=('calibre',10,'normal'))
res.place(x=200,y=350)

ShowBtn = Button(window2,text="Show Message",bg='lavender blush2',


fg='black',width=15,height=1,command=Result)
ShowBtn['font'] = font.Font( size=12)
ShowBtn.place(x=180,y=400)

ResetBtn = Button(window2, text='Reset', bg='honeydew2', fg='black',


width=15,height=1,command=Reset)
ResetBtn['font'] = font.Font( size=12)
ResetBtn.place(x=15,y=400)

QuitBtn = Button(window2, text='Exit', bg='old lace',


fg='black',width=15,height=1, command=window2.destroy)
QuitBtn['font'] = font.Font( size=12)
QuitBtn.place(x=345,y=400)
# Create radio buttons to toggle between windows
var = tk.IntVar()
var.set(1)
rb1 = tk.Radiobutton(root, text="Window 1", variable=var, value=1,
command=toggle_window)
rb1.pack()
rb2 = tk.Radiobutton(root, text="Window 2", variable=var, value=2,
command=toggle_window)
rb2.pack()

# Hide one of the windows initially


hide_window(window2)

# Start the main event loop


root.mainloop()

OUTPUT OF PROJECT:
SCOPE OF PROJECT

The above code is a basic implementation of a graphical user interface


(GUI) for a simple encryption and decryption program using the Python
programming language and the Tkinter library. Its scope is to provide users
with a simple and intuitive way to encrypt and decrypt messages using a
key.

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.

The scope of the code is limited to simple encryption and decryption of


messages and does not provide advanced security features such as key
exchange, authentication, or digital signatures. The program is intended for
educational purposes and can be used to teach basic concepts of
cryptography, programming, and GUI development using Python and
Tkinter.
FUTURE DEVELOPMENT OF PROJECT

Certainly! there are some ways we could make the cryptography program
better and more futuristic:

Use a stronger encryption method: The current encryption algorithm is


basic and not very secure. Using a stronger encryption method like AES
would make the program more secure.

Add password protection: To increase security, we could prompt the user to


enter a password before allowing them to encrypt or decrypt their data.
This would prevent unauthorized access.

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.

Implement machine learning: We could make the program more secure by


using a machine learning model to detect and prevent potential threats.

By making these changes, the program would become more secure,


versatile, and user-friendly.
CONCLUSION

The code provided is a encryption and decryption program using the


Python Tkinter library. It allows users to choose a button for choosing an
algorithm input a message and a key, and then choose whether to encrypt
or decrypt the message using a AES or base64 algorithm. The output is
displayed in the GUI window and can be copied to the clipboard for further
use. The program can be further improved by adding more advanced
encryption algorithms and increasing the security of the application.
Overall, this code serves as a good starting point for learning about basic
encryption techniques and GUI development using Python.

You might also like