CRP PBL
CRP PBL
BACHELOR OF TECHNOLOGY
in
Submitted by
M. Sai Kiran [22R11A6229]
P. Sai Charan [22R11A6233]
M. Vishnu [22R11A6227]
R. Sandeep [22R11A6235]
Under the esteemed guidance of
Accredited by NAAC with ‘A+’ Grade & NBA, Approved by AICTE and Affiliated to JNTUH
Cheeryal (V), Keesara (M), Medchal (Dist), Telangana – 501 301
NOVEMBER - 2024
Geethanjali College of Engineering and Technology
Department of Computer Science and Engineering (Cyber Security)
(UGC AUTONOMOUS INSTITUTION)
Accredited by NAAC with ‘A+’ Grade & NBA, Approved by AICTE and Affiliated to JNTUH
November – 2024
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING (CYBER SECURITY)
CERTIFICATE
This is to certify that the Cryptography Project Based Learning (PBL) Report entitled “Image
Encryption and Decryption (DES)” is a bonafide work done and submitted by
M.SaiKiran[22R11A6229],P.SaiCharan[22R11A6233],M.Vishnu[22R11A627],
R.Sandeep[22R11A6235] during the academic year 2023 – 2024, in partial
fulfilment of the requirement for the award of Bachelor of Technology degree in
“Computer Science and Engineering (Cyber Security)” from Geethanjali College of
Engineering and Technology (Accredited by NAAC with ‘A+’ Grade & NBA,
Approved by AICTE and Affiliated to JNTUH), is a bonafide record of work
carried out by them under guidance and supervision.
Certified further that to the best of my knowledge, the work in this project has not been
submitted to any other institution for the award of any degree or diploma.
FACULTY GUIDE Dr. G. Kalyani
i
DECLARATION
We hereby declare that the project report entitled “Password Strength Checker” is an original
work done and submitted to the CSE (Cyber Security) Department, from Geethanjali College of
Engineering and Technology (Accredited by NAAC with ‘A+’ Grade & NBA, Approved by
AICTE and Affiliated to JNTUH), in partial fulfilment of the requirement for the award of
Bachelor of Technology in “Computer Science and Engineering (Cyber Security)” and it is a
record of bonafide project work carried out by us under the guidance of Mr. Vikram Sindhu,
Senior Assistant Professor, Department of CSE (Cyber Security).
We further declare that the work reported in this project has not been submitted, either in part or
in full, for the award of any other degree or diploma in this institute or any other Institute or
University.
ii
ACKNOWLEDGEMENT
The satisfaction of completing this project would be incomplete without mentioning our gratitude
towards all the people who have supported us. Constant guidance and encouragement have been
instrumental in the completion of this project.
First and foremost, we thank the Chairman, Principal, and Vice Principal for availing
infrastructural facilities to complete the project on time.
We offer our sincere gratitude to our faculty guide Mr. Vikram Sindhu, Senior Assistant
Professor, CSE (Cyber Security) Department, from Geethanjali College of Engineering and
Technology (Accredited by NAAC with ‘A+’ Grade & NBA, Approved by AICTE and Affiliated
to JNTUH), for his immense support, timely cooperation, and valuable advice throughout the
course of our project work.
We would like to thank the Head of the Department, Dr. G. Kalyani, for her meticulous care and
cooperation throughout the project work.
We are thankful to all the project coordinators for their supportive guidance and for having
provided the necessary help to carry forward this project without any obstacles or hindrances.
iii
ABSTRACT
This project focuses on the development and implementation of an image encryption and
decryption system using the Data Encryption Standard (DES) algorithm, aimed at enhancing the
security of digital images during transmission and storage. With the increasing reliance on digital
imagery in various fields, including healthcare, finance, and personal communications,
safeguarding these images from unauthorized access and tampering has become essential.
The DES algorithm, a widely recognized symmetric key encryption technique, operates on 64-bit
blocks of data and employs a 56-bit key for both encryption and decryption processes. In this
project, images are first converted into a binary format and segmented into 64-bit blocks. Each
block undergoes a series of transformations, including initial permutation, key generation, and 16
rounds of substitution and permutation, ensuring a high level of security through confusion and
diffusion principles.
iv
TABLE OF CONTENTS
CERTIFICATE
i
DECLARATION
ii
ACKNOWLEDGEMENT
iii
ABSTRACT
i
TABLE OF FIGURES
v
1. INTRODUCTION
1
1.1 Introduction
1
1.2 Advantages of Password Strength Checker
2
2. AIM AND OBJECTIVE
3
3. BACKGROUND
4
4. LITERATURE REVIEW
5
5. SOFTWARE REQUIREMENT SPECIFICATION
7
5.1 Functional Requirements
7
5.2 Non-Functional Requirements
8
5.3 System Requirements
9
5.4 Performance Requirements
10
5.5 Documentation Requirements
11
6. MODELS APPLIED
12
6.1 Password Strength Evaluation Model
12
6.2 Real-time Feedback Model 6.3 User Interface Model
12
14
7.1 Datasets 14
7.2 Pre-processing 15
8. IMPLEMENTATION 17
9.1 Testing 17
11. OUTPUT 26
12. CONCLUSION 27
vii
1. INTRODUCTION
In the digital era, the proliferation of image data across various platforms has raised
significant concerns regarding privacy and security. Images are frequently shared and
transmitted over the internet, making them vulnerable to unauthorized access, manipulation,
and theft. As a result, there is an urgent need for robust encryption methods to protect
sensitive visual information from potential threats. This project addresses these concerns by
implementing an image encryption and decryption system based on the Data Encryption
Standard (DES) algorithm.
The Data Encryption Standard, developed in the 1970s, is one of the most widely used
symmetric key cryptographic algorithms. Although it has been largely replaced by more
advanced encryption standards, DES remains relevant for educational purposes and certain
applications where speed and simplicity are paramount. DES operates on fixed-size blocks of
data, utilizing a 56-bit key for both encryption and decryption processes. Its structure
involves multiple rounds of substitution and permutation, which enhance the security of the
encrypted data.
This project aims to explore the practical application of the DES algorithm in securing
images. It begins with the conversion of digital images into a binary format, followed by the
segmentation of the image data into 64-bit blocks suitable for DES processing. Each block is
then encrypted using the DES algorithm, producing ciphertext that is unintelligible without
the corresponding decryption key. The decryption process reverses the encryption steps,
allowing for the recovery of the original image.
1
1.2 Advantages
2
2. AIM AND OBJECTIVE
Aim:
The primary aim of the image encryption and decryption project is to develop a robust and
efficient system that secures digital images through encryption techniques, thereby ensuring
the confidentiality, integrity, and authenticity of visual data during storage and transmission.
Objectives:
Image Processing: To convert digital images into a suitable format for encryption, which
involves transforming images into binary data and segmenting them into blocks compatible
with the DES algorithm.
Quality Assessment: To assess the quality of the encrypted images and the decrypted output,
ensuring that the original image can be accurately restored without loss of critical information
or significant degradation.
Security Analysis: To analyze the security of the encrypted images against various
cryptographic attacks, such as brute force attacks, and to evaluate the effectiveness of the key
management strategy used in the encryption process.
3
3. BACKGROUND
The rapid advancement of digital technology has transformed the way images are created,
shared, and stored. With the proliferation of digital cameras, smartphones, and social media
platforms, vast amounts of visual data are generated daily. While this has made it easier to
communicate and share information, it has also raised significant concerns regarding the
security and privacy of digital images. Unauthorized access, data breaches, and malicious
manipulation of images are pressing issues that necessitate effective security measures.
The need for image encryption can be traced back to the broader field of cryptography, which
has been used for centuries to protect sensitive information. Traditional cryptographic
techniques focused primarily on text data, but as digital imaging became more prevalent in
the late 20th century, the need for specialized encryption methods for images emerged. Early
efforts in image encryption primarily adapted existing text-based algorithms, but these
methods often proved inadequate due to the unique characteristics of image data, such as its
high dimensionality and the need for perceptual quality.
4
4. LITERATURE REVIEW
The field of image encryption and decryption has garnered significant attention due to the
increasing need for securing digital images in various applications, including healthcare, finance,
and personal privacy. This literature review explores key methodologies, algorithms, and
advancements in image encryption and decryption, highlighting their effectiveness and
limitations.
Early research in image encryption often employed traditional cryptographic algorithms, such as
the Data Encryption Standard (DES) and the Advanced Encryption Standard (AES).
1. Zhang et al. (2006) demonstrated the application of AES for image encryption,
emphasizing its strong security features. They noted that while AES is computationally
efficient, its performance could be improved when applied to large images by optimizing
block processing.
2. Khan et al. (2015) explored the use of DES in image encryption, highlighting its
simplicity and ease of implementation. However, they noted vulnerabilities to brute-force
attacks, prompting the need for stronger algorithms.
Chaos theory has been extensively applied to image encryption due to its inherent randomness
and sensitivity to initial conditions.
1. Fridrich et al. (1998) introduced chaos-based image encryption methods that utilize
chaotic maps for pixel permutation and substitution. Their work demonstrated that chaotic
systems could produce highly secure encryption keys, making it difficult for attackers to
predict the encrypted output.
2. B. S. Manjunath et al. (2010) further refined chaos-based techniques, proposing a hybrid
approach that combined chaotic encryption with traditional methods. Their findings
indicated that such hybrid systems significantly enhance security while maintaining high
image quality.
Pixel permutation and substitution are fundamental components of many image encryption
schemes.
1. Liu et al. (2010) proposed a novel encryption scheme that combined pixel permutation
with substitution, achieving a high level of security while preserving the visual quality of
5
the encrypted image. They emphasized the importance of randomness in key generation to
prevent predictable patterns.
2. Zhou et al. (2016) developed a pixel-based encryption algorithm that utilized a
combination of substitution and diffusion techniques. Their results showed that the
proposed method effectively mitigated vulnerabilities associated with statistical attacks.
Block-based encryption methods have gained traction due to their efficiency and adaptability to
image data.
1. M. A. Al-Mamun et al. (2015) explored block cipher techniques for image encryption,
demonstrating that dividing images into smaller blocks allows for efficient processing
while enhancing security. They highlighted the need for a balance between computational
efficiency and security levels.
2. B. S. Manjunath et al. (2016) proposed a block-based encryption scheme that utilized a
combination of pixel scrambling and diffusion techniques. Their work indicated that
block-based methods could effectively reduce redundancy in images and enhance security.
6
5. SOFTWARE REQUIREMENTS SPECIFICATION
1. Image Input:
o The system must allow the user to input the path of an image file to be
encrypted.
2. Key Input:
o The system must require the user to enter an 8-character key for the encryption
process.
3. Image Encryption:
o The system must encrypt the input image using the DES algorithm and the
provided key.
o The encrypted image must be saved in a binary format (e.g., .dat file).
4. Image Decryption:
o The system must allow the user to input the path of an encrypted image file for
decryption.
o The system must decrypt the encrypted image using the same DES algorithm
and the provided key.
5. Output of Decrypted Image:
o The system must save the decrypted image in a standard format (e.g., .jpg file).
6. Error Handling:
o The system must handle errors gracefully, providing meaningful error
messages when issues occur (e.g., invalid key length, file not found).
7. User Interaction:
o The system must interact with the user via console input and output, guiding
them through the encryption and decryption processes.
5.2 Non-Functional Requirements
1. Performance:
o The encryption and decryption processes should be completed in a reasonable
time frame, particularly for images of varying sizes.
7
2. Security:
o The system must ensure that the encryption process provides a level of security
that protects the image data from unauthorized access.
o The key management should be handled securely, ensuring that keys are not
hard-coded or exposed unnecessarily.
3. Usability:
o The user interface (console prompts) should be clear and easy to understand,
allowing users to navigate the encryption and decryption processes without
confusion.
4. Scalability:
o The system should be able to handle images of various sizes and formats, with
consideration for future enhancements (e.g., supporting other encryption
algorithms).
5. Compatibility:
o The system should be compatible with various operating systems that support
Java, ensuring that it can run on different platforms without modification.
6. Reliability:
o The system should consistently perform encryption and decryption accurately
without data loss or corruption.
7. Maintainability:
o The code should be structured in a way that allows for easy updates and
maintenance, including clear documentation and adherence to coding
standards.
8. Portability:
o The application should be portable, allowing it to be executed on any system
with a compatible Java Runtime Environment (JRE).
5.3 System Requirements
1. Hardware Requirements:
Processor (CPU): A dual-core processor (e.g., Intel Core i5 or equivalent) for better
performance, especially when processing larger images or running multiple applications
simultaneously.
8
Memory (RAM):4 GB of RAM or more. This will allow for smoother multitasking and
better performance when handling larger image files.
Storage: At least 500 MB of free disk space to accommodate the JRE, application files, and
additional space for images and encrypted files.
Graphics: While the application does not require a dedicated graphics card, having a decent
integrated graphics solution can help with rendering images if you decide to extend the
application with a GUI in the future.
Operating System: A 64-bit operating system is recommended for better performance with
Java applications, especially when dealing with larger memory allocations.
2. Software Requirements:
9
o The application requires access to the file system to read the input image, save the
encrypted file, and save the decrypted image. Ensure that the user running the
application has the necessary permissions to perform these actions.
1. Computational Requirements
Encryption/Decryption Complexity:
The DES algorithm operates on 64-bit blocks and involves 16 rounds of
encryption, each requiring key-dependent operations like permutation and
substitution.
The runtime is linear with respect to the size of the image data in bytes, as the DES
algorithm processes all bytes of the image data sequentially.
Impact: Larger images result in higher encryption/decryption times due to the
block-by-block processing.
2. Key Generation:
The DESKeySpec creation and SecretKeyFactory.generateSecret() operations are
lightweight and involve only key material preparation, which is negligible
compared to encryption/decryption.
3. BufferedImage Memory:
The BufferedImage object stores the entire image in memory. The memory usage
scales with the resolution and color depth of the image.
Example: A 1920x1080 image with 24-bit color depth requires about 6 MB of
memory.
4. Byte Array Conversion:
During encryption, the image is converted to a byte array using a
ByteArrayOutputStream. This byte array can consume significant memory if the
image size is large.
10
The encrypted byte array adds additional memory overhead.
5. Decryption:
Similarly, decryption produces a byte array before reconstructing the
BufferedImage. This step temporarily duplicates the memory required for the
image data.
in a Project-Based Learning (PBL) setup, the documentation requirements should cover both
technical and functional aspects.
Project Overview: Purpose, significance, and objectives (evaluate password strength and
suggest improvements).
Requirements:
Functional Specifications:
11
6. MODELS APPLIED
12
o A counter value is used to generate unique key streams for each block.
o Advantages: Allows parallel processing of blocks, improving performance.
o Disadvantages: Requires careful management of counter values.
2. Image-to-Byte Transformation Model
Images must be converted to a byte array before encryption, as DES operates on
binary data.
This transformation typically involves:
1. Image Encoding: Using formats like JPEG or PNG to generate a compressed
byte stream.
2. Memory Buffering: Storing the byte data in memory for DES processing.
Design Considerations:
The compression level (e.g., for JPEG) can impact the size and quality of the image,
which indirectly affects encryption performance.
The image's color depth (e.g., grayscale vs. 24-bit RGB) impacts the byte array size
and processing time.
3. Symmetric Key Management Model
DES uses a single, symmetric key for both encryption and decryption.
In image encryption:
o The key must be exactly 8 bytes long (64 bits).
o Key management is critical for security. If the key is exposed, the image can
easily be decrypted.
Key Models:
Static Key Model: The same key is used for all images, which is simpler but less
secure.
Dynamic Key Model: A unique key is generated for each image or session, enhancing
security but requiring secure key distribution.
4. Performance Optimization Model
Efficient image encryption using DES involves balancing encryption speed, memory usage,
and security:
Chunk-based Encryption:
o Large images are divided into smaller chunks, with each chunk encrypted
sequentially.
o Reduces memory overhead and enables streaming.
13
Parallel Processing:
o For modes like CTR, blocks can be processed in parallel to improve speed.
Types of Images:
Grayscale Images:
High-Resolution Images:
Compressed: Formats like JPEG and PNG are often used for storage efficiency.
Uncompressed: Formats like BMP or TIFF retain original pixel data, providing a
more direct mapping for encryption.
7.2 Preprocessing
Image Resizing:
Resize images to a manageable resolution to reduce encryption overhead.
Example: Downscale large images to 256x256 or 512x512 if high resolution is
unnecessary.
Format Conversion:
Convert the image into a supported format (e.g., JPEG, PNG).
If using formats like BMP or TIFF, ensure proper handling of larger file sizes.
14
Color Space Conversion:
For color images, you can process each channel (R, G, B) independently or combine
them into a single byte array.
Alternatively, convert RGB images to grayscale to simplify the encryption process.
Flattening Image Data:
Convert the image into a one-dimensional byte array.
This is necessary because DES operates on binary data rather than structured image
formats.
Padding:
Ensure that the image byte array size is a multiple of the DES block size (8 bytes or 64
bits).
Common padding schemes:
PKCS#5/PKCS#7 Padding: Adds extra bytes to fill the block.
Zero Padding: Adds zeros to the end of the data.
Normalization (Optional):
Normalize pixel values (e.g., scaling them to the range [0, 1] or [0, 255]) if needed for
specific encryption schemes.
15
8. IMPLEMENTATION
16
Execute the compiled Java program:
Step 2: Provide Inputs
Input Image Path:
o Enter the full path to the image you want to encrypt, e.g., C:\images\
sample.jpg.
Encryption Key:
o Enter an 8-character key for encryption (e.g., myp@sswd).
o Ensure the key meets the DES requirement of being exactly 8 bytes long.
Step 3: Encrypted File
The program will generate an encrypted binary file named encrypted_image.dat in the
current directory.
Step 4: Decrypt the Image
Enter the path to the encrypted_image.dat file when prompted.
The program will generate a decrypted image, decrypted_image.jpg, in the same
directory.
5. Verify Output
Encrypted File:
o Open the encrypted_image.dat file in a text editor or binary viewer. It should
appear as unreadable binary data.
Decrypted Image:
o Open the decrypted_image.jpg file in an image viewer.
o Verify that it matches the original image.
6. Debugging and Testing
Common Issues:
1. Key Length Validation:
o If the key is not exactly 8 characters, the program will terminate with a
message.
2. File Not Found:
o Ensure the paths provided for input files exist and are correct.
3. Image Format Issues:
o Ensure the image format is supported by ImageIO.
Test Cases:
Use various image formats (JPG, PNG, BMP).
17
Test with different image sizes and resolutions.
Test with valid and invalid keys.
7. Modify and Extend
Enhancements:
1. Use AES Instead of DES:
o Replace DES with AES for better security.
2. Dynamic Key Management:
o Add functionality to generate and store keys securely.
3. Error Handling:
o Improve exception messages for better debugging.
4. GUI Integration:
o Create a graphical interface for selecting files and entering keys.
18
9. TRAINING AND TESTING
9.1 TESTING
19
Case 4: Non-Image File
Description: Test with a non-image file as input.
Steps:
1. Use a text file (e.g., test.txt) as input.
2. Verify:
The program fails with an appropriate error, such as "IOException".
Deployment
Performance Evaluation
20
10. SOURCE CODE
file:DesImageEncryption.java
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.nio.file.Files;
import java.util.Base64;
import java.util.Scanner;
return encryptedBytes;
}
21
Cipher cipher = Cipher.getInstance(ALGORITHM);
cipher.init(Cipher.DECRYPT_MODE, secretKey);
byte[] decryptedBytes = cipher.doFinal(encryptedImage);
} catch (Exception e) {
e.printStackTrace();
} finally {
scanner.close();
}
22
}
}
11.OUTPUTS
23
Fig-3: Decrypted Image
24
12. CONCLUSION
In conclusion, image encryption and decryption using DES has been an important milestone
in the evolution of cryptographic techniques. While it laid the foundation for securing digital
data, its limitations, such as a small key size and vulnerability to brute-force attacks, have
rendered it unsuitable for modern high-security applications. DES can still serve as a valuable
educational tool and may find limited use in low-security or resource-constrained
environments. However, with the growing need for robust and efficient encryption methods,
DES has largely been replaced by more advanced algorithms like AES. As technology
advances, the focus will continue to shift toward quantum-resistant and AI-integrated
encryption systems, ensuring stronger protection for sensitive visual data in an increasingly
interconnected world.
25
13. FUTURE SCOPE
The future scope of image encryption and decryption using DES is limited due to its inherent
vulnerabilities, such as susceptibility to brute-force attacks and relatively small key size (56
bits). However, DES can still find applications in low-security environments or for
educational purposes to demonstrate cryptographic principles. In the future, advancements
may focus on hybrid approaches, combining DES with more robust algorithms like AES to
balance simplicity and security in resource-constrained environments. Additionally,
optimizing DES-based encryption for lightweight IoT devices or embedding it within
steganographic systems could offer niche applications. Nevertheless, for high-security
demands, DES will likely be replaced by modern, quantum-resistant encryption techniques.
26
14. REFERENCES
1. https://www.geeksforgeeks.org/encrypt-and-decrypt-image-using-java/
2. https://www.tutorialspoint.com/cryptography/data_encryption_standard.htm
27