Hello again! Right now, I'm trying to make a password system that stores and tries to protect a piece of text with a user created user & password set. this set and the text is stored in a file called a1.ran. Now, as a second part of the project, I have to make a program that checks a1.ran for a known user set and displays the text according to it. I have NO idea where to start. Anyone help me and kindly provide a code that obeys these rules? I will tweak the code according to it. BIG thanks for anyone that helps me.
CHEERS!
Here's the code for the password creator (updated)for reference:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <string>
usingnamespace std;
string username;
string password;
char szstring[500]; //What variable?
void explain()
{
cout <<"\tCreate a username and password first. Note, when\n"
<<"\ta new set is created, make sure that you have not created\n"
<<"\tthe username before, and that this uses the stupidest\n"
<<"\tform of security ever created. DO NOT STORE CONFIDENTIAL\n"
<<"\tSTUFF because any baffoon can crack this program. Also, you\n"
<<"\tcan't make a username including spaces, as the program glitches badly.\n"
<<"\t--PS: you can only store text.--\n\n\n";
return;
}
void create()
{
ofstream data;
cout <<"Username: ";
cin >> username;
data.open("a1.ran", fstream::in|fstream::app);
data <<"USERNAME: " <<username;
data << endl;
cout <<endl;
data.close();
cout <<"Password: ";
cin >> password;
data.open("a1.ran", fstream::in|fstream::app);
data <<"PASSWORD: " <<password;
data << endl
<< endl;
cout <<endl;
data.close();
return;
}
void secrettext()
{
ofstream data;
cout<<"Enter your secret text (type in # first and continue typing): ";
cin>> szstring[500];
cin.getline(szstring, 500);
data.open("a1.ran", fstream::in | fstream::app); //The variable gets stored
data<<szstring; //here...
data<< "\n\n\n"
<< "--------------------------------------------------------------------------------------------------------------------------------------------------------------------"
<< endl;
data.close();
cout<<"\n\n\nSaving...100%\n";
cout<<"\n\nSaved.";
return;
}
int main(int nNumberofArgs, char* pszArgs[])
{
explain();
create();
secrettext();
system("PAUSE");
return 0;
}
I also like help about a bug: When the secret text is written, the first letter always disappears from the file(If I enter 'this', in the file it shows up as 'his').