Please read the following instructions carefully before submitting assignment.
It should be clear that your assignment will not get any credit if:
Objective
The objective of this assignment is:
Guidelines
Assignment Description
In this assignment, you are required to write c++ code that will protect the provided text file using the protection mechanism given in guidelines. It will also check the security of file and if any change is made in the contents of protected file, it will point out the file as changed.
Protection mechanism:
The program will protect the file by generating a protection key on the basis of contents of the file. The key will be saved at the end of the file with “%” symbol as prefix. This key will be used to detect either the file contents are changed or not e.g. if file contents are changed the new key generated will not match the existing one, leading to conclusion that file contents have been changed.
Solution guidelines
The program should operate in following sequence.
Important note
A text file (data.txt) is attached with assignment, use it for protection checking. Video file (Output-Demo.mp4) of desired function is also attached with assignment. Watch the demo video carefully to understand the required functionality (output) of program. Your program should work as per functionality performing in demo video file. You do not need to send text file with your solution. Just upload .cpp file from your LMS account. For any query related to assignment no. 3 contact us at cs201@vu.edu.pk.
Submission
You are required to submit your solution C++ program through LMS i.e. .cpp file.
Tags:
#Doll meray pas koi error nai hai and menay check kr k upload ki hai yhn
@Zain nasar nice work. thanks for sharing the solution. case 5 is not working on this solution. anyone have the idea?
data file kaisy attach krni ha koi bta dy plzzzzzz
data file attach nai kerni just .cpp file upload kerni ha
data file un k pass ha
data file solution ma program k sath kaisy attach krni ha ye pocha ha assignment uploading k bry ma nai
i ve saved changes in the data file twice thrice after protection but every time i run my program and check the security, it displays "the content of the file are not change after protection" is there a way out to this problem?? Moreover when i press a key to continue it terminates
#include <iostream>
#include <fstream>
using namespace std;
// this func will generate key bases on length of each line in file
int get_key(string a_lines)
{ int key = 0;
key += a_lines.length();
return key; }
// this func will find that file has key or not
bool findkey(string a_lines)
{ int ans = a_lines.find("%");
if(ans >= 0)
{ return 1; }
else
{ return 0; } }
bool readkey(string a_lines)
{
}
main()
{ ifstream infile; // input file handler
ofstream outfile;
char fileName[100]; // name of file to open
string line; // character array for each line in text file
string lines; // character array for full text file
int option;
cout "Enter the name of text file in current directory:";
cin >> fileName;
infile.open(fileName, ios::in); // opening file in input mode
bool jump = true;
bool ans;
if(!infile)
{ cout "file not found"; }
else
{ while(!infile.eof())
{ getline(infile, line);
lines += line; }
infile.close();
do
{ cout "\nOperations on text file";
cout "\n1.Protect my text file";
cout "\n2.check security of my text file";
cout "\n1.Enter your choice (1/2)";
cin >> option;
switch(option)
{ case 1:
if(findkey(lines))
{ cout "already protected";
cout " and return " findkey(lines);
infile.close();
jump = false;
break; }
else
{ outfile.open(fileName, ios::app);
outfile "%";
outfile get_key(lines);
cout "key added";
cout "and return " findkey(lines);
jump = false;
outfile.close();
break; }
case 2:
if(findkey(lines))
{ cout "file is protected using option 2";
cout "and return " findkey(lines);
jump = false;
break; }
else
{ cout "file is not protected please protect file";
cout "and return " findkey(lines); } } }
while(jump == true); } }
//
clude
#include
using namespace std;
int get_key(string a_lines)
{ int key = 0;
key += a_lines.length();
return key; }
bool findkey(string a_lines)
{ int answer = a_lines.find("%");
if(answer >= 0)
{ return 1; }
else
{ return 0; } }
bool readkey(string a_lines)
{
}
main()
{ ifstream infile;
ofstream outfile;
char fName[100];
string line;
string lines;
int option;
cout "Enter the name of text file in current directory:";
cin >> fName;
infile.open(fName, ios::in); // opening file in input mode
bool jump = true;
bool answer;
if(!infile)
{ cout "file not found choose 1"; }
else
{ while(!infile.eof())
{ getline(infile, line);
lines += line; }
infile.close();
do
{ cout "\nOperations on text file";
cout "\n1.Protect my text file";
cout "\n2.check security of my text file";
cout "\n1.Enter your choice (1/2)";
cin >> option;
switch(option)
{ case 1:
if(findkey(lines))
{ cout "already protected";
cout " and return " findkey(lines);
infile.close();
jump = false;
break; }
else
{ outfile.open(fName, ios::app);
outfile "%";
outfile get_key(lines);
cout "key added";
cout "and return " findkey(lines);
jump = false;
outfile.close();
break; }
case 2:
if(findkey(lines))
{ cout "file is protected using option 2";
cout "and return " findkey(lines);
jump = false;
break; }
else
{ cout "file is not protected please protect file";
cout "and return " findkey(lines);
jump=false;
break; } } }
while(jump == true);
system("pause");
} }
© 2021 Created by + M.Tariq Malik.
Powered by
Promote Us | Report an Issue | Privacy Policy | Terms of Service
We are user-generated contents site. All product, videos, pictures & others contents on site don't seem to be beneath our Copyrights & belong to their respected owners & freely available on public domains. We believe in Our Policy & do according to them. If Any content is offensive in your Copyrights then please email at m.tariqmalik@gmail.com with copyright detail & We will happy to remove it immediately.
Management: Admins ::: Moderators
Awards Badges List | Moderators Group
All Members | Featured Members | Top Reputation Members | Angels Members | Intellectual Members | Criteria for Selection
Become a Team Member | Safety Guidelines for New | Site FAQ & Rules | Safety Matters | Online Safety | Rules For Blog Post