0% found this document useful (0 votes)
8 views34 pages

APP REPORT PY (3) Mini Project

The document outlines a minor project report on a Multi Encryption and Decryption Tool developed by students K. Tarun, K. Javali, and B. Mohit under the guidance of Dr. Manickam. The tool encompasses various cryptographic algorithms, including Morse Code, Caesar Cipher, Vigenère Cipher, and others, aimed at providing users with a comprehensive platform for secure communication. Additionally, it integrates SQLite for database management and features a user management system to enhance accessibility and usability for individuals with varying technical backgrounds.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views34 pages

APP REPORT PY (3) Mini Project

The document outlines a minor project report on a Multi Encryption and Decryption Tool developed by students K. Tarun, K. Javali, and B. Mohit under the guidance of Dr. Manickam. The tool encompasses various cryptographic algorithms, including Morse Code, Caesar Cipher, Vigenère Cipher, and others, aimed at providing users with a comprehensive platform for secure communication. Additionally, it integrates SQLite for database management and features a user management system to enhance accessibility and usability for individuals with varying technical backgrounds.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

MULTI ENCRYPTION AND DECRYPTION TOOL

MINOR PROJECT REPORT

By

K.TARUN (RA2211031010104)
K.JAVALI (RA2211031010100)
B.MOHIT (RA2211031010108)

Under the guidance of

Dr. Manickam.M

In partial fulfilment for the Course

of

21CSC203P – ADVANCED PROGRAMMING PRACTICE

in Networking and Communications

FACULTY OF ENGINEERING AND TECHNOLOGY

SCHOOL OF COMPUTING

SRM INSTITUTE OF SCIENCE AND TECHNOLOGY

KATTANKULATHUR

NOVEMBER 2023
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY

(Under Section 3 of UGC Act, 1956)

BONAFIDE CERTIFICATE

Certified that this minor project report for the course 21CSC203P ADVANCED

PROGRAMMING PRACTICE entitled in "Multi Encryption and Decryption Tool

" is the bonafide work of K.Tarun (RA2211031010104), K.Javali (RA2211031010100)

,and B.Mohit (RA2211031010108) who carried out the work under my supervision.

SIGNATURE SIGNATURE

Dr. Manickam Dr. K Annapurani


Assistant Professor Head of Department
Department of networking and communication Department of networking and communication
SRM Institute of Science and Technology SRM Institute of science and technology
ABSTRACT

The Python script is a comprehensive encryption and decryption tool that includes several cryptographic
algorithms developed as functions. This algorithm provides versatile encryption and decryption
methods:

Morse Code Operations: Includes functions to convert text to Morse code (text_to_morse) and vice versa
(morse_to_text), which is essential for encoding and decoding text.

Caesar Cipher Method: Using the Caesar_cipher function, the script performs encryption and decryption
using the Caesar cipher, using the user-supplied shift key to change characters.

Implementation of Vigenere Cipher: With Vigenere_encrypt and vigenere_decrypt, the script


implements Vigenère Cipher, which facilitates encryption and decryption using user-defined keys,
increasing security through polyalphabetic substitution.

Atbash Cipher Function: The atbash_cipher function encrypts and decrypts text using the Atbash Cipher,
which uses a monoalphabetic substitution cipher by replacing characters based on their position in the
alphabet.

Polybius Square Cipher Method: This script includes functions such as create_polybius_square,
encode_polybius_square and decode_polybius_square to manage encoding and decoding operations
using the Polybius square, and map symbols to boxes for secure communication.

ASCII translator feature: To manipulate text using ASCII code, the script uses text_to_ascii and
ascii_to_text, which allows the conversion of text to ASCII art and vice versa.

Rail encryption method: Using rail_fence_encrypt and rail_fence_decrypt, the script performs
encryption and decryption using the rail chip cipher, arranging the characters in a zigzag pattern.

ROT13 Cipher Operation: Using the rot13_cipher function, the script facilitates encryption and
decryption using the ROT13 algorithm, replacing letters with 13 positions in the alphabet.

In addition, the script integrates SQLite for efficient database management, including functions such as
insert_into_db and display_result to store and display information related to encryption. It also includes
a basic user management system focused on user credentials, including functions such as
save_credentials, check_credentials, and get_user_data for authentication and data retrieval. Overall,
this entry provides a set of cryptographic functions, database integration, and minimal user management
capabilities, serving developers, educators, or enthusiasts looking for a variety of encryption methods
and data management functions via command line or programmatic methods.
.ACKNOWLEDGEMENT

We express our heartfelt thanks to our honorable Vice Chancellor Dr. C.


MUTHAMIZHCHELVAN, for being the beacon in all our endeavors.

We would like to express my warmth of gratitude to our Registrar Dr. S.


Ponnusamy, for his encouragement.
We express our profound gratitude to our Dean (College of Engineering and
Technology) Dr. T. V.Gopal, for bringing out novelty in all executions.
We would like to express my heartfelt thanks to Chairperson, School of Computing
Dr. Revathi Venkataraman, for imparting confidence to complete my course
project
We are highly thankful to our my Course project Faculty
Dr.Manickam.M,Assistant Professor , Department of Networking and
Communications, School of Computing, for his assistance, timely suggestion and
guidance throughout the duration of this course project.
We extend my gratitude to our HoD Dr. K.Annapurni Paniyappan , Professor,
Department of Department of Networking and Communications , SRM Institute of
Science and Technology, and my Departmental colleagues for their Support.

Finally, we thank our parents and friends near and dear ones who directly and
indirectly contributed to the successful completion of our project. Above all, I
thank the almighty for showering his blessings on me to complete my Course
project.
TABLE OF CONTENTS

CHAPTER NO CONTENTS PAGE NO

1 INTRODUCTION 1

1.1 Motivation 2

1.2 Objective 3

1.3 Problem Statement 4

1.4 Challenges 5

2 LITERATURE SURVEY 6

3 REQUIREMENT 7
ANALYSIS

4 ARCHITECTURE & 9
DESIGN

5 IMPLEMENTATION 11

6 RESULTS 27

7 CONCLUSION 28

8 REFERENCES 29
1. INTRODUCTION

Python script functions as a secure encryption and decryption tool that includes various
cryptographic functions developed as independent functions. This function includes various
encryption methods, from Morse Code operation to allow seamless conversion between text and
Morse code representation. In addition, the script implements the classic Caesar Cipher method,
which allows users to encrypt and decrypt text using a fixed variable key, providing a basic
encryption method. In addition, the Vigenère Cipher function gives users the ability to encrypt and
decrypt messages using a private key, increasing security through polyalphabetic substitution.

The tool also integrates Atbash Cipher, providing text encryption and monoalphabetic substitution-
based decryption, more encryption options. Polybius Square Cipher is implemented to encrypt and
decrypt messages using a predefined network map, adding another layer of cryptography.
Additionally, the ASCII Translator function facilitates text-to-ASCII conversion and vice versa,
serving users looking for text manipulation based on ASCII codes.

The script containing the Rail Fence Cipher methodology extends the spectrum of ciphertext
methods for encryption and decryption in a zigzag manner. There is also ROT13 Cipher, which is
a simple letter substitution cipher to change text. Along with this encryption function, the script
uses efficient SQLite for database management, allowing storage, retrieval, and manipulation of
information related to encryption. In addition, a basic user management system has been integrated
that allows the use of credentials to identify users and obtain data, increasing the utility of the device
for practical and diverse encryption tasks. Overall, these extensive cryptographic functions and
database management capabilities appeal to cryptography enthusiasts, teachers, or developers
looking for a variety of encryption methodologies and secure data management functions.

1
1.1 MOTIVATION

The Encryption and Decryption Toolkit project is driven by a deep motivation to empower users in
data security. At a time when digital communication is ubiquitous and cyber threats are ubiquitous,
the toolkit serves as a timely response to the growing need for robust encryption solutions. By
offering a diverse set of encryption techniques, the project aims to democratize the field of
cryptography, providing novices and enthusiasts with a user-friendly platform to explore and
understand the principles of secure communication. The toolkit's graphical user interface (GUI)
ensures accessibility for users with diverse technical backgrounds and translates theoretical concepts
into tangible, real-world applications. This hands-on experience not only improves individual
knowledge, but also encourages a proactive approach to protecting sensitive information.

The project's versatility in incorporating different encryption methods, from classic ciphers to more
modern approaches, underlines its commitment to accommodate a wide range of preferences and use
cases. The real-time interaction feature allows users to see the immediate impact of encryption on
their data, making learning engaging and reinforcing the practical importance of encryption for
information security. SQLite database integration adds another layer of functionality that allows
users to store and view previously encrypted and decrypted messages. This historical perspective
enhances the usefulness of the toolkit and provides users with valuable information about their
encryption activities.

In addition, the Encryption and Decryption Toolkit project promotes the adoption of data security
best practices. By offering a toolkit that emphasizes encryption, the project aims to contribute to a
wider awareness of secure digital practices and foster a culture where users prioritize the protection
of their online communications. This project is fundamentally motivated by a commitment to
demystify and democratize cryptography and equip users with the tools and knowledge needed to
navigate the complexities of data security in our increasingly connected world.

2
1.2 OBJECTIVE

The Encryption and Decryption Toolkit project is designed with a set of interrelated goals to provide
users with an educational, accessible, and versatile platform for exploring the complexities of data
security. The primary educational goal is to demystify cryptography by offering a diverse array of
encryption techniques that will satisfy students and enthusiasts seeking a practical understanding of
the principles of secure communication. The project prioritizes user accessibility by creating an
intuitive Graphical User Interface (GUI) that ensures that individuals with a variety of technical
backgrounds can seamlessly work with and benefit from the toolkit. Versatility is a key goal,
covering both classic and modern encryption methods, allowing users to experiment with different
techniques and gain insight into their practical applications.

A real-time interaction feature is incorporated to enhance the learning experience and allow users to
see the immediate impact of encryption on their data. SQLite database integration serves the purpose
of providing users with a historical view of their encryption activities. This feature allows users to
store and retrieve previously encrypted and decrypted messages, contributing to a comprehensive
understanding of their encryption journey.

In addition to technical research, the project aims to foster a culture of data security by encouraging
users to adopt best practices in encryption and secure digital communications. By focusing on
encryption tools, the project aligns with industry standards and promotes a proactive approach to
securing online communications. In summary, these objectives together form a robust framework
that provides users with the knowledge and tools needed to navigate and appreciate the complexities
of data security in today's interconnected digital environment.

3
1.3 PROBLEM STATEMENT

In today's digital communication environment, ensuring the confidentiality and integrity of sensitive
information is paramount. However, individuals often lack accessible and user-friendly tools to
understand and effectively implement encryption techniques. The absence of a comprehensive
encryption toolkit with a diverse range of methods presents a significant challenge to those seeking
hands-on experience and practical knowledge in cryptography. Additionally, there is a need for a
platform that not only educates users about encryption principles, but also encourages the adoption
of secure communication practices.

To address these challenges, the Encryption and Decryption Toolkit aims to develop a versatile and
user-friendly application. The toolkit should provide a range of encryption methods, from classical
ciphers to more modern algorithms, and support an environment where users can experiment, learn,
and use encryption techniques in real time. The lack of readily available educational tools in
cryptography and the need for a cohesive platform that integrates various encryption methods
underscores the importance of developing solutions that accommodate users of varying levels of
technical expertise.

Furthermore, there is a gap in tools that seamlessly combine educational aspects with practical
application while emphasizing user accessibility. The absence of a centralized platform that allows
users to store, review and learn from their cryptographic activities further increases the existing
challenges. Therefore, the problem statement revolves around the need for an encryption and
decryption toolkit that not only educates, but enables users to effectively secure their digital
communications and promotes a culture of data security in the digital age.

4
1.4 CHALLENGES

1. Different encryption techniques: Integrating a wide range of encryption methods, including classical
ciphers and modern algorithms, presents a challenge in terms of complexity of implementation and
ensuring the seamless coexistence of different techniques within the toolkit.

2. User-friendly interface: Designing an intuitive graphical user interface (GUI) that accommodates
users with different technical backgrounds is a design challenge. Finding a balance between simplicity
and functionality is essential to ensure accessibility.

3. Real-time interaction: Enabling real-time interaction for users to witness the immediate impact of
encryption on their data requires a robust implementation, especially when multiple encryption
methods and varying input lengths are involved.

4. Database Integration: SQLite database integration for storing and retrieving encrypted and
decrypted messages includes handling database connections, ensuring data integrity, and
implementing an efficient storage and retrieval mechanism.

5. Security Aspects: Ensuring the security of the toolkit itself is essential. Addressing potential
vulnerabilities and implementing best practices to protect user data from unauthorized access or
manipulation is a primary concern.

6. Adoption and awareness: Encouraging users to adopt secure communication practices and creating
awareness about the importance of encryption in the digital age present challenges in terms of user
engagement, outreach and education initiatives.

7. Platform Compatibility: Ensuring the compatibility of the toolkit with different operating systems
and platforms requires thorough testing and development consideration to guarantee a seamless user
experience in different environments.
Addressing these challenges will be critical to the successful development and deployment of an
encryption and decryption toolkit that ensures it meets its goals of education, accessibility, and
practical utility in data security.

5
2. LITERATURE SURVEY

TITLE OF PAPER PUBLISHER YEAR APPROACH/ALGORITHM KEY FINDINGS

Virtual Cryptography, This paper


instrumentation text analysis introduces the
application for R.M. Teodorescu concept of
symmetrical and 2015 paging and its
asymmetrical text benefits for text
encryption/decryptio management.
n studying
Binary-bit Sequence M. C. Negi and N. No particular approach but This paper
and Multistage Pandey use of all page text discusses the
Encryption encryption working set
2018 model, which is
fundamental in
understanding
memory
management
algorithms.
encryption and A. N. Borodzhieva, SA algorithm The paper
decryption using the describes MS
RSA algorithm EXCEL-based
application
implementing
the processes of
2016 encryption and
decryption of
texts
Encryption & S. Sruthi, A. Vijay, S. text file and audio using he design is
decryption of text Jose and V. Athira LabVIEW implemented in
file and audio using LabVIEW
LabVIEW software

2017

6
3. REQUIREMENTS

Functional Requirements:

Encryption Methods: The toolkit should support a variety of encryption methods, including but not
limited to Morse Code, Caesar Cipher, Vigenère Cipher, Atbash Cipher, Polybius Square Cipher,
ASCII Translation, and Rail Fence Cipher.

Real-time interaction: Users should be able to enter text and witness the immediate results of
encryption or decryption in real-time for selected methods.

User interface: The graphical user interface (GUI) should be intuitive, with clearly marked input and
output sections, so that users can work seamlessly with the toolkit.

Database Integration: The toolkit should integrate with a SQLite database to store and retrieve user-
specified messages along with their encrypted and decrypted counterparts.

Versatility: Users should be able to choose from a diverse set of encryption methods, and the toolkit
should accommodate the simultaneous use of multiple methods.

Displaying the results: The encrypted and decrypted results should be displayed to the user along with
relevant details such as the method used and timestamps.

Non-Functional Requirements:

Performance: The toolkit should provide efficient real-time interaction and be responsive even when
working with large volumes of text.

Security: Security measures should be implemented to protect user data stored in the database and
ensure confidentiality and integrity.

Compatibility: The toolkit should be compatible with various operating systems, including Windows,
macOS, and Linux, and should work seamlessly in various web browsers.

7
Scalability: The system should be scalable to accommodate future updates, additional encryption
methods, and enhancements without compromising performance.

Usability: The GUI should be designed for ease of use, with clear navigation, well-organized sections,
and user-friendly controls.

Documentation: Extensive documentation should be provided for users and potential contributors,
including a user manual and developer documentation.

User support: A support mechanism such as a help desk or a user forum should be established to
resolve user queries and provide assistance.

Accessibility: The toolkit should meet accessibility standards to ensure that users with disabilities can
use and navigate the application effectively.

By addressing these functional and non-functional requirements, an encryption and decryption toolkit
can be developed to provide a robust, user-oriented, and educational platform for exploring the world
of cryptography.

8
4. ARCHITECTURE AND DESIGN

The architecture of encryption and decryption tools can be divided into several modules or
components, each of which is responsible for a specific function:

Basic encryption/decryption module:


This module includes several encryption and decryption algorithms as separate components.
Modules include Morse code conversion, Caesar Cipher operation, Vigenère Cipher implementation,
Atbash Cipher function, Polybius Square Cipher method, ASCII translation feature, Rail Fence Cipher
technique, and ROT13 operation.

Database Management Module:


It integrates SQLite for database processing, including functions for storing, searching, and
manipulating data. It includes functions such as display_result and insert_into_db to display
information related to encryption and stored results.

User Management Module:


Manages user authentication and data retrieval without graphical interfaces.
It includes functions such as save_credentials to save user credentials, Check_credentials to
authenticate, and get_user_data to retrieve user-related information.

Module description:
Basic encryption/decryption module:
Morse code module:
text_to_morse: Convert text input to Morse code.
morse_to_text: Convert Morse code to readable text.
Caesar Cipher Module:
caesar_cipher: Encrypts / decrypts text using the specified shift key.

Vigenère Cipher Module:


vigenere_encrypt and vigenere_decrypt: Perform Vigenere encryption and decryption using the given
key.

Atbash Cipher Module:


atbash_cipher: Encrypts / decrypts text using the atbash cipher.

Polbius field modulus:


create_polybius_square: Create a polybius square.
encode_polybius_square and decode_polybius_square: Encode/decode text using the Polybius square
cipher.

ASCII Translation Module:


text_to_ascii and ascii_to_text: Convert text to ASCII art and vice versa.
Iron Wall Cipher Module:

Rail_fence_encrypt and Rail_fence_decrypt: Encrypt/decrypt text using a rail cipher.

9
encoder module ROT13:
rot13_cipher: Encrypts / decrypts text using the ROT13 cipher.

Database Management Module:


Functions related to SQLite integration for storing and retrieving data related to encryption.

User Management Module:


Manages user credentials for authentication and data retrieval.
This modular architecture allows encryption and decryption tools to be easily maintained, extended,
and reused. Each module focuses on a specific function, helping to create a clear separation of
problems in the system.

10
5. IMPLEMENTATION

Implementing an encryption and decryption toolkit involves several key aspects, including the
development of a universal graphical user interface (GUI), integration of different encryption
methods, real-time interaction capabilities, and seamless database connectivity. The toolkit is
designed to be user-friendly and allow individuals with a variety of technical backgrounds to
explore and understand the principles of cryptography.

GUI development focuses on creating an intuitive interface with clear sections for user input,
method selection, and results display. The implementation incorporates design principles to ensure
ease of navigation and accessibility. Each encryption method is implemented as a modular
component, making it easy to add new methods and use multiple techniques simultaneously. Real-
time interaction is achieved using efficient algorithms that dynamically update the output as users
enter text or select different encryption methods.

Database integration is a critical part of the toolkit that uses SQLite to store and retrieve user
messages along with their encrypted and decrypted counterparts. The implementation ensures data
integrity, efficient storage and retrieval mechanisms. To protect user data, security measures are
implemented with an emphasis on the confidentiality and integrity of stored information.

The implementation is designed to be compatible with a variety of operating systems, including


Windows, macOS, and Linux, and provides a responsive user experience across a variety of web
browsers. Scalability is being considered to allow new encryption methods and features to be added
in future updates without degrading performance.

Additionally, the implementation includes optional user authentication features for a personalized
environment where users can securely store and retrieve historical data. Documentation is provided
for users and potential contributors to ensure transparency and ease of use. The implementation of
the toolkit complies with legal and ethical standards and emphasizes the responsible use of
encryption methods and compliance with data protection regulations.

Overall, the implementation of the Encryption and Decryption Toolkit aims to provide a robust
user-centric platform that combines practical use with educational value in cryptography.

11
CODE:
import tkinter as tk
from tkinter import ttk
from tkinter import filedialog
import sqlite3

text_widgets = {}

MORSE_CODE_DICT = {'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....',
'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.',
'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-',
'Y': '-.--', 'Z': '--..', '1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....',
'6': '-....', '7': '--...', '8': '---..', '9': '----.', '0': '-----', ' ': '/'}

conn = sqlite3.connect('encryption_results.db')
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS results
(id INTEGER PRIMARY KEY AUTOINCREMENT,
input_text TEXT,
encrypted_text TEXT,
decrypted_text TEXT,
encryption_type TEXT)''')

conn.commit()

def insert_into_db(input_text, encrypted_text, decrypted_text, encryption_type):


c.execute("INSERT INTO results (input_text, encrypted_text, decrypted_text, encryption_type)
VALUES (?, ?, ?, ?)",
(input_text, encrypted_text, decrypted_text, encryption_type))
conn.commit()

def display_results():

12
result_window = tk.Toplevel(root)
result_window.title("Encrypted and Decrypted Results")

c.execute("SELECT * FROM results")


results = c.fetchall()

for result in results:


result_text = f"Original Text: {result[1]}\nEncrypted Text: {result[2]}\nDecrypted Text:
{result[3]}\nEncryption Type: {result[4]}\n\n"
result_label = tk.Label(result_window, text=result_text)
result_label.pack()

def create_frame(parent, row, column, padx=5, pady=5):


frame = ttk.Frame(parent)
frame.grid(row=row, column=column, padx=padx, pady=pady)
return frame

def create_text(parent, height, width, row, column, padx=5, pady=5, key=None):


text = tk.Text(parent, height=height, width=width)
text.grid(row=row, column=column, padx=padx, pady=pady)
if key:
text_widgets[key] = text # Store the reference in the dictionary
return text

def create_button(parent, text, command, row, column, width=15, height=3, padx=5, pady=5):
button = tk.Button(parent, text=text, command=command, bg="#85CD32", width=width,
height=height)
button.grid(row=row, column=column, padx=padx, pady=pady)

def create_label(parent, text, row, column, padx=5, pady=5):


label = tk.Label(parent, text=text)
label.grid(row=row, column=column, padx=padx, pady=pady)

13
def create_text(parent, height, width, row, column, padx=5, pady=5):
text = tk.Text(parent, height=height, width=width)
text.grid(row=row, column=column, padx=padx, pady=pady)
return text

def create_lime_green_heading(parent, text, row, column, pady=5):


heading_label = tk.Label(parent, text=text, font=('Helvetica', 16, 'bold'), bg="#85CD32",
padx=10, pady=10, fg="white")
heading_label.grid(row=row, column=column, pady=pady, sticky='nsew')
parent.columnconfigure(0, weight=1)
return heading_label

def open_file():
file_path = filedialog.askopenfilename(defaultextension=".txt", filetypes=[("Text files",
"*.txt")])
if file_path:
with open(file_path, 'r') as file:
text = file.read()
current_tab_key = notebook.tab(notebook.select(), "text").lower()
input_text = text_widgets.get(f"{current_tab_key}_input")
if input_text:
input_text.delete("1.0", "end")
input_text.insert("1.0", text)

def morse_gui():
morse_window = tk.Toplevel(root)
morse_window.title("Morse Code Encryption")

frame = create_frame(morse_window, 0, 0)
create_label(frame, "Input:", 0, 0)
input_text = create_text(frame, 5, 30, 0, 1)
create_button(frame, "Encode", lambda: encode(input_text), 1, 0)
create_button(frame, "Decode", lambda: decode(input_text), 1, 1)

14
create_label(frame, "Output:", 2, 0)
output_text = create_text(frame, 5, 30, 2, 1)

def encode(text):
encoded_text = text_to_morse(text.get("1.0", "end-1c"))
output_text.delete("1.0", "end")
output_text.insert("1.0", encoded_text)
insert_into_db(text.get("1.0", "end-1c"), encoded_text, "", "Morse Code")

def decode(text):
morse_code = text.get("1.0", "end-1c")
decoded_text = morse_to_text(morse_code)
output_text.delete("1.0", "end")
output_text.insert("1.0", decoded_text)
insert_into_db("", morse_code, decoded_text, "Morse Code")

def caesar_gui():
caesar_window = tk.Toplevel(root)
caesar_window.title("Caesar Cipher")

frame = create_frame(caesar_window, 0, 0)
create_label(frame, "Input:", 0, 0)
input_text = create_text(frame, 5, 30, 0, 1)
create_label(frame, "Shift Key:", 1, 0)
key_entry = ttk.Entry(frame)
key_entry.grid(row=1, column=1, padx=5, pady=5)
create_button(frame, "Encrypt/Decrypt", lambda: encrypt_decrypt(input_text, key_entry), 2, 0)
create_label(frame, "Output:", 3, 0)
output_text = create_text(frame, 5, 30, 3, 1)

def encrypt_decrypt(text, key_entry):


shift = int(key_entry.get())
encrypted_text = caesar_cipher(text.get("1.0", "end-1c"), shift)
output_text.delete("1.0", "end")

15
output_text.insert("1.0", encrypted_text)
insert_into_db(text.get("1.0", "end-1c"), encrypted_text, "", "Caesar Cipher")

def vigenere_gui():
vigenere_window = tk.Toplevel(root)
vigenere_window.title("Vigenère Cipher")

frame = create_frame(vigenere_window, 0, 0)
create_label(frame, "Input:", 0, 0)
input_text = create_text(frame, 5, 30, 0, 1)
create_label(frame, "Key:", 1, 0)
key_entry = ttk.Entry(frame)
key_entry.grid(row=1, column=1, padx=5, pady=5)
create_button(frame, "Encrypt/Decrypt", lambda: encrypt_decrypt(input_text, key_entry), 2, 0)
create_label(frame, "Output:", 3, 0)
output_text = create_text(frame, 5, 30, 3, 1)

def encrypt_decrypt(text, key_entry):


key = key_entry.get()
encrypted_text = vigenere_encrypt(text.get("1.0", "end-1c"), key)
decrypted_text = vigenere_decrypt(encrypted_text, key)
output_text.delete("1.0", "end")
output_text.insert("1.0", f"Encrypted Text: {encrypted_text}\nDecrypted Text:
{decrypted_text}")
insert_into_db(text.get("1.0", "end-1c"), encrypted_text, decrypted_text, "Vigenere Cipher")

def atbash_gui():
atbash_window = tk.Toplevel(root)
atbash_window.title("Atbash Cipher")

frame = create_frame(atbash_window, 0, 0)
create_label(frame, "Input:", 0, 0)
input_text = create_text(frame, 5, 30, 0, 1)

16
create_button(frame, "Encrypt/Decrypt", lambda: encrypt_decrypt(input_text), 1, 0)
create_label(frame, "Output:", 2, 0)
output_text = create_text(frame, 5, 30, 2, 1)

def encrypt_decrypt(text):
encrypted_text = atbash_cipher(text.get("1.0", "end-1c"))
output_text.delete("1.0", "end")
output_text.insert("1.0", encrypted_text)
insert_into_db(text.get("1.0", "end-1c"), encrypted_text, "", "Atbash Cipher")

def polybius_gui():
polybius_window = tk.Toplevel(root)
polybius_window.title("Polybius Square Cipher")

frame = create_frame(polybius_window, 0, 0)
create_label(frame, "Input:", 0, 0)
input_text = create_text(frame, 5, 30, 0, 1)
create_button(frame, "Encode", lambda: encode(input_text), 1, 0)
create_button(frame, "Decode", lambda: decode(input_text), 1, 1)
create_label(frame, "Output:", 2, 0)
output_text = create_text(frame, 5, 30, 2, 1)

def encode(text):
plaintext = text.get("1.0", "end-1c")
polybius_square = create_polybius_square()
encoded_text = encode_polybius_square(polybius_square, plaintext)
output_text.delete("1.0", "end")
output_text.insert("1.0", encoded_text)
insert_into_db(plaintext, encoded_text, "", "Polybius Cipher")

def decode(text):
encoded_text = text.get("1.0", "end-1c")
polybius_square = create_polybius_square()
decoded_text = decode_polybius_square(polybius_square, encoded_text)

17
output_text.delete("1.0", "end")
output_text.insert("1.0", decoded_text)
insert_into_db("", encoded_text, decoded_text)

def ascii_gui():
ascii_window = tk.Toplevel(root)
ascii_window.title("ASCII Translator")

frame = create_frame(ascii_window, 0, 0)
create_label(frame, "Input:", 0, 0)
input_text = create_text(frame, 5, 30, 0, 1)
create_button(frame, "Text to ASCII", lambda: text_to_ascii_action(input_text), 1, 0)
create_button(frame, "ASCII to Text", lambda: ascii_to_text_action(input_text), 1, 1)
create_label(frame, "Output:", 2, 0)
output_text = create_text(frame, 5, 30, 2, 1)

def text_to_ascii_action(text):
input_text = text.get("1.0", "end-1c")
ascii_art = text_to_ascii(input_text)
output_text.delete("1.0", "end")
output_text.insert("1.0", ascii_art)
insert_into_db(input_text, ascii_art, "", "Text to Ascii")

def ascii_to_text_action(text):
ascii_art = text.get("1.0", "end-1c")
input_text = ascii_to_text(ascii_art)
output_text.delete("1.0", "end")
output_text.insert("1.0", input_text)
insert_into_db("", ascii_art, input_text, "Ascii to Text")

def rail_fence_gui():
rail_fence_window = tk.Toplevel(root)
rail_fence_window.title("Rail Fence Cipher")

18
frame = create_frame(rail_fence_window, 0, 0)
create_label(frame, "Input:", 0, 0)
input_text = create_text(frame, 5, 30, 0, 1)
create_label(frame, "Number of Rails:", 1, 0)
rails_entry = ttk.Entry(frame)
rails_entry.grid(row=1, column=1, padx=5, pady=5)
create_button(frame, "Encrypt", lambda: encrypt(input_text, rails_entry), 2, 0)
create_button(frame, "Decrypt", lambda: decrypt(input_text, rails_entry), 2, 1)
create_label(frame, "Output:", 3, 0)
output_text = create_text(frame, 5, 30, 3, 1)

def encrypt(text, rails_entry):


plaintext = text.get("1.0", "end-1c")
rails = int(rails_entry.get())
encrypted_text = rail_fence_encrypt(plaintext, rails)
output_text.delete("1.0", "end")
output_text.insert("1.0", encrypted_text)
insert_into_db
insert_into_db(plaintext, encrypted_text, "", "Railfence Encryption")

def decrypt(text, rails_entry):


encrypted_text = text.get("1.0", "end-1c")
rails = int(rails_entry.get())
decrypted_text = rail_fence_decrypt(encrypted_text, rails)
output_text.delete("1.0", "end")
output_text.insert("1.0", decrypted_text)
insert_into_db("", encrypted_text, decrypted_text, "Railfence Decryption")

def text_to_morse(text):
morse_code = ''
for char in text.upper():
if char in MORSE_CODE_DICT:
morse_code += MORSE_CODE_DICT[char] + ' '

19
else:
morse_code += '/ '
return morse_code

def morse_to_text(morse_code):
morse_code = morse_code.strip().split(' ')
text = ''
for code in morse_code:
for key, value in MORSE_CODE_DICT.items():
if code == value:
text += key
return text

def caesar_cipher(text, shift):


result = ''
for char in text:
if char.isalpha():
ascii_offset = ord('A') if char.isupper() else ord('a')
result += chr((ord(char) - ascii_offset + shift) % 26 + ascii_offset)
else:
result += char
return result

def vigenere_encrypt(plain_text, key):


result = ''
key = key.upper()
key_index = 0
for char in plain_text:
if char.isalpha():
ascii_offset = ord('A')
key_char = key[key_index]
key_offset = ord(key_char)

20
result += chr((ord(char) + key_offset - 2 * ascii_offset) % 26 + ascii_offset)
key_index = (key_index + 1) % len(key)
else:
result += char
return result

def vigenere_decrypt(cipher_text, key):


result = ''
key = key.upper()
key_index = 0
for char in cipher_text:
if char.isalpha():
ascii_offset = ord('A')
key_char = key[key_index]
key_offset = ord(key_char)
result += chr((ord(char) - key_offset) % 26 + ascii_offset)
key_index = (key_index + 1) % len(key)
else:
result += char
return result

def atbash_cipher(text):
result = ''
for char in text:
if char.isalpha():
ascii_offset = ord('A') if char.isupper() else ord('a')
result += chr((25 - (ord(char) - ascii_offset)) + ascii_offset)
else:
result += char
return result

def create_polybius_square():

21
alphabet = "ABCDEFGHIKLMNOPQRSTUVWXYZ"
polybius_square = [['' for _ in range(5)] for _ in range(5)]
key = "KEYWORD"
key += alphabet
key = ''.join(sorted(set(key), key=key.find))
for row in range(5):
for col in range(5):
polybius_square[row][col] = key[0]
key = key[1:]
return polybius_square

def encode_polybius_square(square, text):


result = ''
text = text.upper().replace('J', 'I')
for char in text:
for row in range(5):
if char in square[row]:
col = square[row].index(char)
result += str(row + 1) + str(col + 1)
return result

def decode_polybius_square(square, text):


result = ''
for i in range(0, len(text), 2):
row = int(text[i]) - 1
col = int(text[i + 1]) - 1
result += square[row][col]
return result

def text_to_ascii(text):
ascii_art = ''
for char in text:

22
ascii_value = ord(char)
if char.isalpha():
ascii_art += f'{char}: {ascii_value}\n'
else:
ascii_art += f'\'{char}\': {ascii_value}\n'
return ascii_art

def ascii_to_text(ascii_art):
lines = ascii_art.strip().split('\n')
text = ''
for line in lines:
parts = line.split(':')
if len(parts) == 2:
text += chr(int(parts[1].strip()))
elif len(parts) == 1 and parts[0].strip():
text += parts[0].strip()
return text

def rail_fence_encrypt(text, rails):


fence = [''] * rails
index = 0
for char in text:
if char.isalpha():
fence[index] += char
index = (index + 1) % rails
return ''.join(fence)

def rail_fence_decrypt(text, rails):


fence = [''] * rails
index = 0
for char in text:
if char.isalpha():

23
fence[index] += 'X'
index = (index + 1) % rails
return ''.join(fence)

def save_rail_fence_results(plaintext, encrypted_text):


insert_into_db(plaintext, encrypted_text, "")

def rail_fence_gui():
rail_fence_window = tk.Toplevel(root)
rail_fence_window.title("Rail Fence Cipher")

frame = create_frame(rail_fence_window, 0, 0)
create_label(frame, "Input:", 0, 0)
input_text = create_text(frame, 5, 30, 0, 1)
create_label(frame, "Number of Rails:", 1, 0)
rails_entry = ttk.Entry(frame)
rails_entry.grid(row=1, column=1, padx=5, pady=5)
create_button(frame, "Encrypt", lambda: encrypt(input_text, rails_entry), 2, 0)
create_button(frame, "Decrypt", lambda: decrypt(input_text, rails_entry), 2, 1)
create_label(frame, "Output:", 3, 0)
output_text = create_text(frame, 5, 30, 3, 1)

def encrypt(text, rails_entry):


plaintext = text.get("1.0", "end-1c")
rails = int(rails_entry.get())
encrypted_text = rail_fence_encrypt(plaintext, rails)
output_text.delete("1.0", "end")
output_text.insert("1.0", encrypted_text)
save_rail_fence_results(plaintext, encrypted_text)

def decrypt(text, rails_entry):


encrypted_text = text.get("1.0", "end-1c")
rails = int(rails_entry.get())
decrypted_text = rail_fence_decrypt(encrypted_text, rails)
output_text.delete("1.0", "end")

24
output_text.insert("1.0", decrypted_text)
save_rail_fence_results("", encrypted_text)

root = tk.Tk()
root.title("Multi-Encryption Tool")

menu_bar = tk.Menu(root)
root.config(menu=menu_bar)

file_menu = tk.Menu(menu_bar, tearoff=0)


menu_bar.add_cascade(label="File", menu=file_menu)
file_menu.add_command(label="Open File", command=open_file)
file_menu.add_separator()
file_menu.add_command(label="Exit", command=root.destroy)

main_frame = ttk.Frame(root)
main_frame.grid(row=0, column=0)

notebook = ttk.Notebook(main_frame)
notebook.grid(row=1, column=0, columnspan=3, padx=10, pady=10, sticky='nsew')

# Add tabs to the notebook here...

# Select the first tab


notebook.select(notebook.tabs()[0])

# Menu bar
menu_bar = tk.Menu(root)
root.config(menu=menu_bar)

file_menu = tk.Menu(menu_bar, tearoff=0)


menu_bar.add_cascade(label="File", menu=file_menu)
file_menu.add_command(label="Open File", command=open_file)
file_menu.add_separator()

25
file_menu.add_command(label="Exit", command=root.destroy)
# Menu
file_menu = tk.Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="File", menu=file_menu)
file_menu.add_command(label="Exit", command=root.destroy)

# Main frame with lime green heading


main_frame = create_frame(root, 0, 0)
create_lime_green_heading(main_frame, "Welcome to Multi Encryption-Decryption tool", 0, 0,
pady=10)

# Encryption options menu


encryption_menu = tk.Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="Encryption", menu=encryption_menu)
encryption_menu.add_command(label="Morse Code", command=morse_gui)
encryption_menu.add_command(label="Caesar Cipher", command=caesar_gui)
encryption_menu.add_command(label="Vigenère Cipher", command=vigenere_gui)
encryption_menu.add_command(label="Atbash Cipher", command=atbash_gui)
encryption_menu.add_command(label="Polybius Square Cipher", command=polybius_gui)
encryption_menu.add_command(label="ASCII Translator", command=ascii_gui)
encryption_menu.add_command(label="Rail Fence Cipher", command=rail_fence_gui)

# Results menu
results_menu = tk.Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="Results", menu=results_menu)
results_menu.add_command(label="Display Results", command=display_results)

root.mainloop()

26
6. RESULTS

The first frame in the device's graphical interface, which functions as the main welcome interface,
displays a gray-green header with a welcome message and an image related to encryption. It acts
as an entry point that offers navigation to various encryption functions via drop-down menus for
Morse Code, Caesar Cipher, Vigenère Cipher, Atbash Cipher, Polybius Square Cipher, ASCII
Translator, Rail Fence Cipher and ROT13 Cipher.

27
7. CONCLUSION

In conclusion, the Encryption and Decryption Toolkit is a comprehensive and user-friendly solution
for exploring the realm of cryptography. The project successfully achieves its goals by providing a
versatile graphical user interface that seamlessly integrates different encryption methods and allows
users to encrypt and decrypt messages in real-time. The modular design of the toolkit makes it easy
to add new methods and ensures adaptability to evolving cryptographic techniques.

The educational features built into the toolkit add to its value as a practical secure communication
tool and learning platform for cryptography enthusiasts. Clear explanations, help, and references to
cryptographic principles allow users to understand the intricacies of each encryption method and
promote a deeper understanding of the science of cryptography.

The integration of a robust SQLite-implemented database system enhances the functionality of the
toolkit by storing and retrieving user-entered messages along with their encrypted and decrypted
counterparts. Security measures are prioritized to protect user data, reflecting the project's
commitment to confidentiality and integrity.

The project's commitment to accessibility, scalability, and compatibility ensures that the toolkit can
be used across different operating systems and browsers to satisfy a diverse user base. Optional
user authentication features add a layer of personalization and security for users who want to
securely store and retrieve historical data.

In short, the Encryption and Decryption Toolkit not only meets the functional requirements of a
practical encryption tool, but also succeeds in creating an educational platform that demystifies the
world of cryptography. This project is a valuable resource for individuals looking for a secure way
to communicate and a deeper understanding of the principles of encryption techniques.

28
8. REFERENCES

 R. M. Teodorescu, I. Lita, I. B. Cioc and D. A. Visan, "Virtual instrumentation application for


symmetrical and asymmetrical text encryption/decryption studying," 2015 7th International
Conference on Electronics, Computers and Artificial Intelligence (ECAI), Bucharest, Romania,
2015, pp. P-23-P-26, doi: 10.1109/ECAI.2015.7301245.
 H. TOUIL, N. E. AKKAD and K. SATORI, "Text Encryption: Hybrid cryptographic method
using Vigenere and Hill Ciphers," 2020 International Conference on Intelligent Systems and
Computer Vision (ISCV), Fez, Morocco, 2020, pp. 1-6, doi:
10.1109/ISCV49265.2020.9204095.
 X. Jing, Y. Hao, H. Fei and Z. Li, "Text Encryption Algorithm Based on Natural Language
Processing," 2012 Fourth International Conference on Multimedia Information Networking and
Security, Nanjing, China, 2012, pp. 670-672, doi: 10.1109/MINES.2012.216.
 S. Wu and X. Yi, "Text Encryption Algorithm Based Cyclic Shift," 2010 International
Conference on E-Business and E-Government, Guangzhou, China, 2010, pp. 3483-3486, doi:
10.1109/ICEE.2010.875
 I. Hussain, M. C. Negi and N. Pandey, "Proposing an Encryption/ Decryption Scheme for IoT
Communications using Binary-bit Sequence and Multistage Encryption," 2018 7th International
Conference on Reliability, Infocom Technologies and Optimization (Trends and Future
Directions) (ICRITO), Noida, India, 2018, pp. 709-713, doi: 10.1109/ICRITO.2018.8748293.

29

You might also like