I m trying to make a password protected program.My password must be read from a file and compare with the password written when you run the program.The password written from keyboard must be encrypted with ASTERIX. This is what I've done by now:
#include <iostream>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <string>
using namespace std;
void main()
{
char pass[20], mypass[20], ch;
cout << "Enter the password: " << endl;
int i=0;
do
{
ch=cin.get();
pass[i]=ch;
if (ch!=27 && ch!=13 && ch!=9)
putchar('*');
else
break;
i++;
} while (i<19);
pass[i]='\0';
ifstream myfile("password.txt");
if (myfile.is_open())
{
while (!myfile.eof())
{
if (strcmp(pass, mypass)!=0)
{
cout << "Incorrect password." << endl;
}
myfile.close();
}
}
}