0% found this document useful (0 votes)
3 views16 pages

Project DSU

The document presents a micro-project report on a C program for file encryption and decryption using the XOR cipher technique, developed by students at Ashokrao Mane Polytechnic. It includes sections on the project's introduction, proposed system enhancements, requirements, source code, future scope, and conclusion, emphasizing the importance of data security. The program serves as an educational tool, illustrating basic cryptographic concepts and file handling in C programming.

Uploaded by

patilharshada974
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views16 pages

Project DSU

The document presents a micro-project report on a C program for file encryption and decryption using the XOR cipher technique, developed by students at Ashokrao Mane Polytechnic. It includes sections on the project's introduction, proposed system enhancements, requirements, source code, future scope, and conclusion, emphasizing the importance of data security. The program serves as an educational tool, illustrating basic cryptographic concepts and file handling in C programming.

Uploaded by

patilharshada974
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Encrypt Decrypt the File Ashokrao Mane Polytechnic

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

MICRO-PROJECT REPORT ON

“ Encrypt Decrypt the File”


Diploma in Computer Engineering
Submitted By

Sr.No Name Roll No

1 Patil Harshada Ananda CO2007


2 Sankpal Parshwa Ajit CO2008
3 Dhale Chetan Jaku CO2009

Subject:Data Structure Using C (313301).


Guide: Ms. H. J. Patil.

ASHOKRAO MANE POLYTECHNIC, VATHAR


Department of Computer Engineering
A.Y. 2024-25

DECLARATION
Encrypt Decrypt the File Ashokrao Mane Polytechnic

I hereby declare that the Micro-Project Report entitled “Data Structure Using C” with Module “Encrypt
and Decrypt the file.” is an authentic record of my own work as requirements of Micro Project during the
period from / / 2024 to / / 2024 in partial fulfillment of Second Year in Computer Engineering, at
Ashokrao Mane Polytechnic, Vathar under the guidance of Ms. H. J. Patil.

Sr.No Name Signature

1 Patil Harshada Ananda (CO2007).

2 Sankpal Parshwa Ajit (CO2008).


3 Dhale Chetan Jaku (CO2009).

Date: / / 2024

Place: Vathar, Kolhapur.


Encrypt Decrypt the File Ashokrao Mane Polytechnic

ACKNOWLEDGMENT

The successful presentation of the “Encrypt and Decrypt the file” would be incomplete without the
mention of the people who made it possible and whose constant guidance crowned my effort with success.

I would like to extend my gratitude to HOD of Computer Department Mr. S.A. Lakade, for providing all
the facilities to present this Micro-Project.

I would like to thank our Project Guide, Ms. H. J. Patil Department of Computer Engineering, Ashokrao
Mane Polytechnic, Vathar, for their constant guidance and inputs.

Sincerely,

Sr.No Name Roll No

1 Patil Harshada Ananda CO2007


2 Sankpal Parshwa Ajit CO2008
3 Dhale Chetan Jaku CO2009

Place: Vathar , Kolhapur.

Date: / / 2024
Encrypt Decrypt the File Ashokrao Mane Polytechnic

Abstract

This C program functions as a simple file encryption and decryption tool


utilizing the XOR cipher technique, which is known for its ease of
implementation and symmetric key nature. The program prompts the user
to choose between encrypting or decrypting a specified file and requires
the user to input the names of the input and output files, as well as an
encryption/decryption key.

The core functionality is handled by the processFile function, which opens


the input file in binary mode for reading and the output file for writing. It
applies the XOR operation on each byte of the input data with a
corresponding byte from the key, cycling through the key as necessary.
This allows for effective encryption and decryption using the same process.

The program incorporates error handling to ensure robust file operations,


providing error messages when file access fails. Additionally, it confirms
the successful completion of encryption or decryption, enhancing user
experience.

While the XOR cipher is suitable for basic applications, it is crucial to note
its limitations in terms of security, especially if the key is short or
improperly managed. This program serves as an educational tool,
illustrating essential concepts of file input/output, string manipulation, and
encryption methods in C programming. It effectively demonstrates how to
protect data through simple cryptographic techniques, making it a useful
resource for learning about data security fundamentals.
Encrypt Decrypt the File Ashokrao Mane Polytechnic

INDEX

Sr.No Content

1 Abstract

2 Title

3 Introduction

4 Proposed System

5 Requirement

6 Source Code Of Project

7 Output of Project

8 Future Scope

9 Conclusion

10 References

Title
Encrypt Decrypt the File Ashokrao Mane Polytechnic

Encrypting and Decrypting the File

1.Introduction
Encrypt Decrypt the File Ashokrao Mane Polytechnic

This C program serves as a practical tool for file encryption and decryption, employing a
simple XOR cipher to protect data. In today's digital landscape, where data security is a
critical concern, this program provides an accessible entry point into cryptography,
demonstrating how basic techniques can be used to secure files.

Upon running the program, users are greeted with a clear interface that allows them to
choose between encrypting or decrypting a file. This dual functionality is essential, as it
enables users to both safeguard their data and retrieve it when necessary. The program
prompts users to input the names of the input and output files, along with a key that will be
used in the encryption or decryption process. This key is pivotal, as it determines the
transformation applied to the data, reinforcing the importance of choosing a strong and
secure key.

The core of the program’s functionality lies in the XOR operation, a fundamental binary
operation frequently used in cryptography due to its simplicity. Each byte of the input file is
read, XORed with a corresponding byte from the key, and written to the output file. This
approach effectively obscures the original data, transforming it into an encrypted format.
Remarkably, the same process can be used for decryption; applying the XOR operation again
with the same key restores the original data. This symmetry highlights the usability of the
XOR cipher, making it a practical choice for basic encryption tasks.

File handling is another critical aspect of this program. It utilizes standard C library functions
to open, read, and write files, ensuring that users can seamlessly manage their data. The
program attempts to open the input file in binary mode; upon success, it proceeds to create or
overwrite the output file. Error handling is integrated to provide feedback if file operations
fail, enhancing the program’s reliability.

Additionally, the program prioritizes user experience. It features clear prompts and messages,
guiding users through each step of the process. After completing an operation, users receive
confirmation messages, reinforcing clarity and a sense of accomplishment.

While the XOR cipher used in this program is relatively basic and not suitable for high-
security applications, it effectively illustrates key concepts of encryption and serves as an
introduction to more advanced cryptographic techniques. Overall, this C program
encapsulates essential principles of file encryption and decryption, providing users with a
practical understanding of data security in a user-friendly manner.
Encrypt Decrypt the File Ashokrao Mane Polytechnic

2. Proposed System

The proposed system for the provided C code is a comprehensive file encryption and
decryption tool that enhances user experience and security. The current implementation
serves as a foundational platform, utilizing a simple XOR cipher for basic data protection.
To further improve this tool, several enhancements can be introduced.

First, a graphical user interface (GUI) would make the application more accessible to non-
technical users. By replacing the command-line prompts with intuitive buttons and forms,
users can easily navigate the process of selecting files and entering keys without needing
programming knowledge. Additionally, enhanced error handling could provide clearer
feedback when issues arise, such as invalid file paths or incorrect keys.

The encryption capabilities could be expanded by supporting multiple algorithms beyond


the XOR cipher, such as AES or RSA. This would allow users to choose a level of security
that fits their specific needs. Along with this, implementing secure key management would
enable users to generate strong keys and store them safely, increasing overall security.

Performance optimization is another vital aspect of the proposed system. Introducing


buffering techniques would improve file processing speed, especially for larger files.
Furthermore, implementing multithreading could allow simultaneous encryption and
decryption operations, enhancing the tool’s responsiveness.

In terms of security features, adding integrity checks, such as checksums, would ensure that
decrypted files match their original versions. Additionally, a password protection
mechanism for the encryption key could further safeguard sensitive data.

The system could also benefit from robust logging and auditing capabilities, tracking
encryption and decryption activities for accountability. User authentication measures would
restrict access to the tool, ensuring only authorized individuals can perform sensitive
operations.

To assist users, comprehensive documentation and an in-app help feature would provide
guidance on using the tool effectively. This would be particularly useful for users unfamiliar
with encryption concepts.
Lastly, ensuring cross-platform compatibility would allow the application to run on various
operating systems, broadening its reach and usability. By addressing these enhancements,
the proposed system will transform the current implementation into a robust, user-friendly
solution for file encryption and decryption, catering to a wide range of security needs in
today’s digital landscape.
Encrypt Decrypt the File Ashokrao Mane Polytechnic

3. Requirements

To successfully implement the provided C code for a file encryption and decryption tool,
several requirements must be met, encompassing functional, technical, and environmental
aspects.
Functional requirements are crucial for ensuring that the program operates as intended.
First, the program must provide a clear and user-friendly interface that allows users to
choose between encrypting and decrypting files. This includes prompting for the input file
name, output file name, and the encryption/decryption key. The tool should be capable of
reading from the specified input file and writing to the output file without corrupting data,
effectively handling binary files. Additionally, it must implement the XOR encryption
method, enabling the same function to be used for both encryption and decryption tasks.
Robust error handling is essential to manage issues such as failing to open files or invalid
input, providing informative messages to users to guide them through any problems
encountered.

On the technical side, the implementation should be carried out in C, utilizing standard
libraries such as <stdio.h>, <stdlib.h>, and <string.h> for file handling and string
manipulation. The program must effectively use appropriate data types, including char for
strings and int for numerical values, to manage user input and file processing efficiently.
The ability to open files in binary mode ("rb" for reading and "wb" for writing) is vital for
accurately processing various file types. Additionally, the system should allow users to enter
a key for encryption and decryption, considering the key's length and handling to ensure
secure operations.

In terms of environmental requirements, the program should be compatible with common


operating systems such as Windows, macOS, and Linux to ensure wide accessibility. A C
compiler, such as GCC or Clang, must be available for compiling the code, alongside a
suitable text editor or integrated development environment (IDE) for writing and editing the
program. It is also important that users have the necessary permissions to read from the
input file and write to the output location, which includes adequate file system access rights.
While optional, having a testing framework in place to validate the program's functionality
and performance would enhance reliability before deployment.

By addressing these requirements, the proposed system will provide a robust and user-
friendly file encryption and decryption tool that meets basic security needs in data handling,
ensuring users can protect their sensitive information effectively.
Encrypt Decrypt the File Ashokrao Mane Polytechnic

4. Source Code Of Project

 C Program :-

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

void processFile(const char * inputFile,


const char * outputFile,
const char * key)
{
FILE * inFile = fopen(inputFile, "rb");
if (!inFile) {
perror(" Unable to open input file");
return;
}

FILE * outFile = fopen(outputFile, "wb");


if (!outFile)
{
perror(" Unable to open output file");
fclose(inFile);
return;
}

size_t keyLen = strlen(key);


int keyIndex = 0;
int ch;

while ((ch = fgetc(inFile)) != EOF)


{
fputc(ch ^ key[keyIndex], outFile);
keyIndex = (keyIndex + 1) % keyLen;
}

fclose(inFile);
fclose(outFile);
}

int main()
{
char inputFile[256], outputFile[256], key[256];
Encrypt Decrypt the File Ashokrao Mane Polytechnic

int choice;

printf("************************************\n");
printf("File Encryption Tool \n");
printf("************************************\n");

printf("1. Encrypt a file \n");


printf("2. Decrypt a file \n");
printf("Choose an option (1 or 2): ");
scanf("%d", & choice);

printf(" Enter input file name: ");


scanf("%s", inputFile);
printf(" Enter output file name: ");
scanf("%s", outputFile);
printf(" Enter encryption/decryption key: ");
scanf("%s", key);

if (choice == 1)
{
processFile(inputFile, outputFile, key);

printf("************************************\n");
printf(" File encrypted successfully! \n");
printf("************************************\n");
}
else if (choice == 2)
{
processFile(inputFile, outputFile, key);
printf("************************************\n");
printf(" File decrypted successfully! \n");
printf("************************************\n");
}
else
{
printf(" Invalid option. Please restart the program.\n");
}

return 0;
}

5.Output of Project
Encrypt Decrypt the File Ashokrao Mane Polytechnic
Encrypt Decrypt the File Ashokrao Mane Polytechnic

6. Future Scope

The current implementation of the file encryption and decryption tool serves as a
foundational example of basic cryptography using the XOR cipher. However, several
enhancements and future developments could significantly improve its functionality,
security, and usability:

1. Improved Encryption Algorithms: The XOR cipher is relatively weak by modern


standards. Future versions could implement more secure algorithms such as AES
(Advanced Encryption Standard) or RSA (Rivest-Shamir-Adleman). These algorithms
would provide stronger security for sensitive data.

2. Key Management: Enhancements could include a robust key management system


that generates secure, random keys, and allows for key storage and retrieval. This
could involve integrating secure password storage methods and possibly user
authentication mechanisms.

3. User Interface Improvements: Developing a graphical user interface (GUI) could


make the tool more user-friendly, enabling users to easily select files and options
without needing to understand command-line interactions.

4. File Format Support: Expanding the tool to support various file formats and data
types, including images, videos, and databases, would broaden its applicability.
Implementing format detection and conversion might also be beneficial.

5. Batch Processing: Future versions could allow for batch processing of multiple files
simultaneously, increasing efficiency for users needing to encrypt or decrypt several
files at once.

6. Cross-Platform Compatibility: Enhancing compatibility across different operating


systems (Windows, macOS, Linux) would broaden the user base. This could involve
using libraries that abstract system-specific functionality.

7. Logging and Auditing: Incorporating a logging feature to track encryption and


decryption activities would enhance security, providing an audit trail for compliance
with data protection regulations.
Encrypt Decrypt the File Ashokrao Mane Polytechnic

8. Integrating Networking Features: Future iterations could include functionalities to


securely transfer files over a network using protocols like SFTP or HTTPS, enabling
encrypted communication channels.

9. Performance Optimization: Optimizing the code for larger files and better memory
management could enhance performance, particularly with respect to processing speed
and resource usage.

By implementing these enhancements, the tool could evolve from a simple educational
project into a robust, real-world application suitable for a wide range of data protection
needs.
Encrypt Decrypt the File Ashokrao Mane Polytechnic

7. Conclusion

The implemented file encryption and decryption tool in C demonstrates a fundamental


approach to securing data using the XOR cipher technique. This program not only
showcases the basic principles of file handling and cryptography but also provides a
practical utility for users needing to protect sensitive information. By allowing users to
easily encrypt and decrypt files using a specified key, it emphasizes the importance of data
security in today’s digital landscape.

While the current implementation is straightforward and effective for educational purposes,
it also highlights the potential for further development and enhancements. Future
improvements could include the integration of stronger encryption algorithms, better key
management practices, and a more user-friendly interface. Additionally, incorporating
features such as batch processing and cross-platform compatibility would significantly
broaden the tool's applicability and usability.

Overall, this program serves as an excellent starting point for those interested in exploring
cryptographic methods and their applications in data protection. With ongoing
advancements in technology and increasing concerns over data privacy, tools like this will
continue to play a crucial role in ensuring secure communication and safeguarding sensitive
information. As users become more aware of the importance of encryption, this tool can
evolve to meet those needs, contributing to a safer digital environment.
Encrypt Decrypt the File Ashokrao Mane Polytechnic

8. References

 Online References

https://mustafaserdarkonca.medium.com/encryption-and-decryption-algorithm-in-c-26c18080cbd7

https://www.youtube.com/watch?v=5ufUhxFF5wE

https://www.youtube.com/watch?v=cvKWyXDjjx8

You might also like