0% found this document useful (0 votes)
26 views2 pages

cs609 Assignment 1 (mc180200043)

The document describes an assignment to implement a Caesar cipher decryption algorithm in C/C++. It provides instructions to write a function that takes an input and output file path and shift value as parameters. The function should decrypt the ciphertext in the input file byte by byte using a shift of 5 and write the plaintext to the output file, ignoring any error messages. It also asks to write the function signature for the CreateFile API to open the file "myFile1.txt" for reading, allowing it to be created if it does not exist but not requiring file sharing. The solution provided the code to implement the Caesar cipher decryption function and function signature for CreateFile as requested.

Uploaded by

anuuujeee420
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)
26 views2 pages

cs609 Assignment 1 (mc180200043)

The document describes an assignment to implement a Caesar cipher decryption algorithm in C/C++. It provides instructions to write a function that takes an input and output file path and shift value as parameters. The function should decrypt the ciphertext in the input file byte by byte using a shift of 5 and write the plaintext to the output file, ignoring any error messages. It also asks to write the function signature for the CreateFile API to open the file "myFile1.txt" for reading, allowing it to be created if it does not exist but not requiring file sharing. The solution provided the code to implement the Caesar cipher decryption function and function signature for CreateFile as requested.

Uploaded by

anuuujeee420
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/ 2

Assignment No.

01
Semester: Spring 2022 Total Marks: 20
Mc180200043 (Sarmad)
DueDate: 09th June, 2022
System Programming – CS609
QUESTION: 1:- Encryption is a process which scrambles the data, so that it can only be ready by the
authorized person. In today’s world, encryption is an integral part of information security. This
technique dates back to the Roman Empire era. They use basic encryption techniques to encrypt
their secret conversations in war days. One of the various techniques is the Caesar Cipher Decryption
algorithm.
In this method an alphabet is substituted by another alphabet placed n positions forward in a circular
manner.

Write a function in C/C++ to implement a Caesar Cipher Decryption algorithm. This function will
convert an input file containing some cipher-text (of alphabets only) into output file of plain-text.

Detailed Instructions:
i. The function will take the following
a. Two file paths (input and output)
b. One Shift variable of DEORD type
ii. Take 5 as the value of Shift variable.
iii. Input file should be converted to plain-text file, byte-by-byte.
iv. The function must ignore any error reporting messages.

SOLUTION:

The Code for the above asked question is given below:


void (decrypt (ifstream abc, ofstream xyz, DWORD key=5)
{
ifstream OutputData (abc);
char ch[50] = “ ”;
ofstream InputData (xyz);
OutputData.getline(ch, 49);
do
{
for ( int i=0; i<strlen (ch); i++)
{
ch[i] = ch[i] – key;
}
InputData << ch;
}
while (OutputData.getline (ch,49));
OutputData.close();
InputData.close();

cout << “File successfully decrypted” << endl;


cout << “Decrypted text is stored on” << xyz << endl;
}
QUESTION: 2:- Write function signature of CreateFile() API, in which a file, myFile1.txt is required to
be opened for reading purpose. Include all the necessary parameters with the required API along
with the following options:
i. The file may or may not exist on the disk. If it doesn’t exist, create it.
ii. File if not required to be shared for concurrent read.

Solution:

The Code for the above asked question is given below:

CreateFile (“c:\\myfile1.txt”, // file path name


GENERIC_READ, // reading purpose, open it
FILE_SHARE_READ, // share for only one person
NULL, // for security

CREATE_NEW, // create new file, if not exist


FILE_ATTRIBUTE_NORMAL // normal file
NULL); // no attribute template is added

BEST OF LUCK

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy