"VARDHAMAN COLLEGE OF ENGINEERING
(AUTONOMOUS)
Affiliated to JNTUH, Approved by AICTE, Accredited by NAAC with A++ Grade, ISO 9001:2015 Certified
Kacharam, Shamshabad, Hyderabad – 501218, Telangana, India
Implementing Triple DES With OTP
A Course End Project Submitted in Fulfillment of the Requirements
for the Course of
A7609 - INFORMATION TECHNOLOGY
In
Department of Computer Science and Engineering
Submitted By
Name of the Student Roll Number
GUNDU JANAKI RAMA VIVEK 21881A05F4
GUTTI VENKATA SAI PRASHANTH 21881A05F5
INDLA BHANU 21881A05F6
Under the Esteemed Guidance of
Ms. Farhana Begum
ASSISTANT PROFESSOR
VARDHAMAN COLLEGE OF ENGINEERING
(AUTONOMOUS)
Affiliated to JNTUH, Approved by AICTE, Accredited by NAAC with A++ Grade, ISO 9001:2015 Certified
VARDHAMAN COLLEGE OF ENGINEERING (Autonomous)
Information Security (A7609) Page 2
Kacharam, Shamshabad, Hyderabad – 501218, Telangana, India
VARDHAMAN COLLEGE OF ENGINEERING
(AUTONOMOUS)
Affiliated to JNTUH, Approved by AICTE, Accredited by NAAC with A++ Grade, ISO 9001:2015 Certified
Kacharam, Shamshabad, Hyderabad – 501218, Telangana, India
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
CERTIFICATE
Certified that this is a bonafide record of the course end project work entitled,
“Implementing Triple DES With OTP” done by, Gundu Janaki Rama
Vivek(21881A05F4), Gutti Venkata Sai Prashanth(21881A05F5), Indla Bhanu
(21881A05F6) submitted to the faculty of Computer Science and Engineering, in
partial fulfillment of the requirements for the course of Information Security during the
year 2023-2024 (VI Semester).
Semester End Examination held on ……………………………………………

 Course Instructor: Head of Department:
 Ms. Farhana Begum Dr. Ramesh Karnati
 (Assistant Professor) (HOD, CSE)
VARDHAMAN COLLEGE OF ENGINEERING (Autonomous)
Information Security (A7609) Page 3
Abstract
This project presents a novel approach to secure data encryption by combining Triple DES
(Data Encryption Standard) with a One-Time Pad (OTP). Triple DES is a symmetric-key block
cipher, while OTP is a symmetric encryption technique known for its theoretical unbreak
ability when used correctly. This combined approach aims to enhance data security by
leveraging the strengths of both encryption methods. The implementation involves generating
a random 24-byte key for Triple DES encryption and a random OTP key of the same length as
the Triple DES ciphertext. The plaintext is first encrypted using Triple DES, then the resulting
ciphertext is further obfuscated using OTP encryption. Decryption follows the reverse process:
the OTP-encrypted ciphertext is decrypted to recover the Triple DES ciphertext, which is then
decrypted using the original Triple DES key to obtain the plaintext. The project provides a
Python implementation using the pycryptodome library, demonstrating the feasibility of the
proposed encryption scheme. Overall, this work contributes to the exploration of innovative
encryption techniques for enhancing data security in various applications. In the realm of data
security, the implementation of robust encryption algorithms is crucial for safeguarding
sensitive information. This paper explores the integration of Triple Data Encryption Standard
(Triple DES) with One-Time Password (OTP) systems, aiming to enhance the security of
authentication mechanisms. Triple DES, an advanced version of the original DES algorithm,
provides a stronger encryption method by applying the DES algorithm three times to each data
block, significantly increasing the difficulty of brute-force attacks. OTP, on the other hand,
offers a dynamic and secure method of authentication, generating unique passwords for each
login session or transaction. The synergy of these two techniques leverages the strengths of
both encryption and dynamic authentication. This study delves into the design and
implementation aspects, examining the cryptographic protocols, key management, and system
architecture required to integrate Triple DES with OTP effectively. We analyze the security
benefits, performance implications, and potential vulnerabilities associated with this hybrid
approach.
Through comprehensive analysis and experimental validation, we demonstrate that combining
Triple DES with OTP not only enhances the security of the authentication process but also
mitigates common attack vectors such as replay attacks and unauthorized access. The findings
suggest that this integrated approach provides a feasible and robust solution for environments
requiring high levels of data protection and secure user authentication.
VARDHAMAN COLLEGE OF ENGINEERING (Autonomous)
Information Security (A7609) Page 4
The study confirms that combining Triple DES with OTP, facilitated by PyCryptodome, offers
a robust and feasible solution for applications requiring high levels of data protection and
secure user authentication. This research paves the way for future advancements in optimizing
computational efficiency and extending the application of this hybrid security model across
diverse domains.
VARDHAMAN COLLEGE OF ENGINEERING (Autonomous)
Information Security (A7609) Page 5
List of Contents
Abstract
CHAPTER 1 INTRODUCTION
CHAPTER 2 DESCRIPTION
CHAPTER 3 ADVANTAGES AND APPLICATIONS
CHAPTER 4 CONCLUSION
CHAPTER 5 REFERENCES
VARDHAMAN COLLEGE OF ENGINEERING (Autonomous)
Information Security (A7609) Page 6
CHAPTER 1
INTRODUCTION
What is DES?
DES (Data Encryption Standard) is a symmetric-key block cipher algorithm used for
encrypting and decrypting electronic data. Developed in the early 1970s by IBM and based on
an earlier cipher called Lucifer, DES became the first widely used encryption algorithm
standardized by the U.S. government.
What is triple DES?
Triple DES (3DES), also known as TDEA (Triple Data Encryption Algorithm), is a symmetrickey block cipher algorithm that applies the Data Encryption Standard (DES) cipher algorithm
three times to each data block. It was developed to provide a higher level of security compared
to the original DES algorithm, which had become vulnerable to brute-force attacks due to its
relatively short key length.
Key Features of Triple DES:
>Symmetric Encryption
>Block Cipher
>Key Length
>Encryption Process
>Decryption Process >Compatibility
What is OTP?
OTP stands for One-Time Pad, which is a symmetric encryption technique used to encrypt and
decrypt messages. It's known for its theoretical unbreak ability when implemented correctly.
The key concept behind OTP is the use of a random key that is at least as long as the message
itself and is only used once.
VARDHAMAN COLLEGE OF ENGINEERING (Autonomous)
Information Security (A7609) Page 7
CHAPTER 2
DESCRIPTION
3DES Implementation: We will use the pycryptodome library, which provides an easyto-use
interface for implementing 3DES.
OTP Implementation: We will use the pycryptodome library, which provides an easy-touse
interface for implementing 3DES.
Firstly, we install the required library pycryptodome using following command
pip install pycryptodome
Example Code:-
from Crypto.Cipher import DES3 from
Crypto.Random import get_random_bytes import
os
def pad(data):
""" Pad data to be multiple of 8 bytes """
pad_len = 8 - len(data) % 8 return data +
bytes([pad_len] * pad_len)
def unpad(data): """
Unpad data """ pad_len =
data[-1] return data[:-
pad_len]
def generate_otp(length):
""" Generate a one-time pad key """ return
os.urandom(length)
def triple_des_encrypt(key, plaintext): """
Encrypt plaintext using 3DES """ cipher =
DES3.new(key, DES3.MODE_ECB)
padded_plaintext = pad(plaintext) ciphertext =
VARDHAMAN COLLEGE OF ENGINEERING (Autonomous)
Information Security (A7609) Page 8
cipher.encrypt(padded_plaintext) return
ciphertext
def triple_des_decrypt(key, ciphertext): """
Decrypt ciphertext using 3DES """ cipher =
DES3.new(key, DES3.MODE_ECB)
padded_plaintext = cipher.decrypt(ciphertext)
return unpad(padded_plaintext)
def otp_encrypt_decrypt(data, otp_key): """
Encrypt/Decrypt data using OTP """ return bytes(a
^ b for a, b in zip(data, otp_key))
# Step 1: Triple DES encryption
key = DES3.adjust_key_parity(get_random_bytes(24)) # 24-byte key for 3DES plaintext =
b"hello"
ciphertext_3des = triple_des_encrypt(key, plaintext)
# Step 2: OTP encryption
otp_key = generate_otp(len(ciphertext_3des))
ciphertext_final = otp_encrypt_decrypt(ciphertext_3des, otp_key)
# Step 3: OTP decryption
ciphertext_3des_recovered = otp_encrypt_decrypt(ciphertext_final, otp_key)
# Step 4: Triple DES decryption
plaintext_recovered = triple_des_decrypt(key, ciphertext_3des_recovered)
print(f"Original plaintext: {plaintext}") print(f"Recovered
plaintext: {plaintext_recovered}") print(f"triple
des_encrypted: {ciphertext_3des}") print(f"otp_ciphertext
final: {ciphertext_final}") print(f"otp_decrypted:
{ciphertext_3des_recovered}”)
VARDHAMAN COLLEGE OF ENGINEERING (Autonomous)
Information Security (A7609) Page 9
Explanation: -
1)Triple DES (3DES):
DES (Data Encryption Standard) is a symmetric-key algorithm for encryption. Triple DES
enhances its security by applying the DES algorithm three times with either two or three
different keys.
Padding: Data must be in multiples of 8 bytes (64 bits) to be encrypted with DES. We pad the
plaintext if it isn't.
Encryption/Decryption: The data is encrypted and decrypted using the same key.
2)One-Time Pad (OTP):
OTP is a symmetric encryption technique where a plaintext is paired with a random key (pad)
that is as long as the plaintext. Each bit/character of the plaintext is encrypted by XORing it
with the corresponding bit/character from the key.
Security: When used correctly (truly random key, key length equal to message length, key
used only once), it is theoretically unbreakable.
Implementation Steps: -
1) Padding Function:
• pad(data): Ensures the plaintext length is a multiple of 8 bytes by appending padding
bytes. The padding bytes indicate the number of padding bytes added.
• unpad(data): Removes the padding bytes to recover the original plaintext.
2)OTP Key Generation:
• generate_otp(length): Creates a random key of specified length using os.urandom.
3)Triple DES Encryption/Decryption:
• triple_des_encrypt(key, plaintext): Encrypts the plaintext using 3DES in ECB mode
after padding it.
• triple_des_decrypt(key, ciphertext): Decrypts the ciphertext using 3DES and then
removes the padding.
4)OTP Encryption/Decryption:
• otp_encrypt_decrypt(data, otp_key): Encrypts or decrypts data by XORing it with the
OTP key.
VARDHAMAN COLLEGE OF ENGINEERING (Autonomous)
Information Security (A7609) Page 10
In the quest to bolster data security, the implementation of robust encryption algorithms and
authentication mechanisms is paramount. This paper explores the integration of Triple Data
Encryption Standard (Triple DES) with One-Time Password (OTP) systems using the
PyCryptodome library, a Python package for low-level cryptographic operations. Triple DES,
an enhancement of the original DES algorithm, strengthens encryption by applying the DES
algorithm three times to each data block, thereby significantly enhancing resistance to bruteforce attacks. OTP provides a dynamic authentication method, generating unique, timesensitive passwords for each login session or transaction.
By leveraging PyCryptodome, we develop a hybrid security model that combines Triple DES
encryption with OTP, leveraging the library's cryptographic functions for efficient
implementation. This study delves into the design, development, and deployment of this
integrated system, focusing on cryptographic protocols, key management, and system
architecture. We analyze the security benefits, performance implications, and potential
vulnerabilities of this approach.
Our findings suggest that the combination of Triple DES with OTP not only enhances
authentication security but also mitigates common threats such as replay attacks and
unauthorized access. Experimental validation confirms that this integrated approach, powered
by PyCryptodome, provides a feasible and robust solution for environments demanding high
levels of data protection and secure user authentication.
VARDHAMAN COLLEGE OF ENGINEERING (Autonomous)
Information Security (A7609) Page 11
VARDHAMAN COLLEGE OF ENGINEERING (Autonomous)
Information Security (A7609) Page 12
CHAPTER 3
ADVANTAGES AND APPLICATIONS
Advantages:
1. Enhanced Security: By combining two strong encryption techniques, the overall
security of the system is increased. Triple DES provides robust encryption, while OTP
offers perfect secrecy when used correctly.
2. Resistance to Brute Force Attacks: Triple DES with a 168-bit key (when using three
56-bit keys) provides a large key space, making brute force attacks computationally
infeasible. Adding OTP on top further enhances security, as OTP keys are used only
once and are theoretically unbreakable when generated and managed securely.
3. Flexibility: Triple DES with OTP allows for flexible key management. Triple DES
keys can be securely distributed and managed, while OTP keys can be generated on the
fly for each encryption session.
4. Backward Compatibility: Triple DES is backward compatible with DES, allowing
systems that rely on DES to transition to a more secure encryption scheme gradually.
This compatibility ensures a smooth migration path without disrupting existing
systems.
Applications:
1. Secure Communication Channels: Triple DES with OTP can be used to establish
secure communication channels between parties where confidentiality and integrity are
critical. This can include secure messaging systems, email encryption, or secure file
transfer protocols.
2. Financial Transactions: In banking and financial sectors, where security is paramount,
Triple DES with OTP can be employed to encrypt sensitive data such as financial
transactions, customer information, and authentication tokens.
3. Government and Military Communication: Government agencies, military
organizations, and diplomatic channels may utilize Triple DES with OTP for secure
communication of classified or sensitive information.
4. Healthcare Data Security: In healthcare, where patient privacy and data integrity are
regulated by laws such as HIPAA, Triple DES with OTP can be used.
VARDHAMAN COLLEGE OF ENGINEERING (Autonomous)
Information Security (A7609) Page 13
CHAPTER 4
CONCLUSION
In conclusion, the combination of Triple DES (3DES) with a One-Time Pad (OTP) offers a
robust encryption solution that leverages the strengths of both techniques to enhance data
security. Triple DES provides strong encryption with its multiple rounds of the DES algorithm,
making it resistant to brute force attacks and suitable for various applications requiring secure
data transmission. On the other hand, OTP offers perfect secrecy when implemented correctly,
as the key used for encryption is random, unique for each message, and as long as the message
itself.
By combining Triple DES with OTP, the overall security of the system is increased, making it
highly resistant to cryptographic attacks. This combination is particularly useful in scenarios
where high security requirements must be met, such as secure communication channels,
financial transactions, government and military communication, healthcare data security,
critical infrastructure protection, and secure IoT communication.
However, it's important to note that implementing Triple DES with OTP requires careful key
management and distribution to ensure the security of the system. Additionally, the overhead
of generating and managing OTP keys for each encryption session should be considered.
Overall, Triple DES with OTP provides a flexible and powerful encryption solution suitable
for applications where confidentiality, integrity, and authenticity of data are paramount, and
where the computational overhead of managing keys is feasible.
The integration of Triple DES with One-Time Password (OTP) systems presents a compelling
solution for enhancing the security of authentication mechanisms in various applications. By
combining the robust encryption capabilities of Triple DES with the dynamic and unique
authentication features of OTP, this hybrid approach effectively addresses numerous security
challenges, including brute-force attacks and replay attacks.
Our study has demonstrated that this integration not only fortifies the authentication process
but also ensures a higher level of data protection. The comprehensive analysis and experimental
results highlight the practical feasibility and enhanced security posture achieved through this
synergy. Despite the inherent computational demands of Triple DES, the combination with
VARDHAMAN COLLEGE OF ENGINEERING (Autonomous)
Information Security (A7609) Page 14
OTP proves to be a balanced solution, offering both high security and manageable performance
overhead.
In conclusion, the deployment of Triple DES with OTP represents a significant advancement
in securing sensitive information and user authentication processes. Future work could explore
optimizing the computational efficiency and expanding the applicability of this hybrid
approach to various domains, ensuring that robust security measures can be implemented
without compromising performance. This research underscores the potential of integrating
established cryptographic techniques with dynamic authentication methods to create resilient
and secure systems.
VARDHAMAN COLLEGE OF ENGINEERING (Autonomous)
Information Security (A7609) Page 15
CHAPTER 5
REFERENCES:
• https://ieeexplore.ieee.org/document/9676023
• https://www.geeksforgeeks.org/double-des-and-triple-des/
• https://en.wikipedia.org/wiki/Triple_DES
• https://journal.unnes.ac.id/nju/sji/article/view/14844
• https://projectwale.medium.com"


do like this for some project in the field of information security