Jan 5, 2010 at 9:09pm UTC
it's just a part of code. exists a check of lenght before this function is called.
Jan 5, 2010 at 9:13pm UTC
If you want real help, please post all the code.
Jan 5, 2010 at 9:18pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Password Pw;
int L;
switch (Pw.FileCheckStatus()){//Checking if the file exists
case true ://file exists
L = Pw.FileCheckSize();
if (L == 0)
{
Pw.NewPassword();
}
else if (L > 0)//when file is not empty
{
Pw.PasswordCheck();
}
break ;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
void PasswordCheck()
{
cout<<"Password: " ;
Password Pw;
cin>>Pw.Typed_Password;
if ((Pw.Typed_Password.empty())|(Pw.Typed_Password.length() <Pw.MAX_SIZE)|
(Pw.Typed_Password.length()> Pw.MAX_SIZE)){
cerr<<"Wrong Password.\n" ;}
else
Pw.DeCrypting();
string EPd;
char *A = new char [Pw.MAX_SIZE * 2];
A[0] = 0;
for (int i = 0;i <= Pw.MAX_SIZE; i++)
{
char *buff = new char [2];
sprintf(buff, "%d" ,Pw.Typed_Password[i]);
A = strcat(A,buff);
}
EPd.clear();
EPd = A;
//clearing the string for obtaing purged data;
int a;
a = EPd.size();
EPd.erase(14,a-14);
if (Pw.DeCryptedPassword.compare(EPd)!=0){printf("Wrong Password.\n" );}
else cout<<"Password accepted.\n" ;
Last edited on Jan 5, 2010 at 9:32pm UTC
Jan 5, 2010 at 10:40pm UTC
What is Pw.Typed_Password?
What is the value of EPd immediately after line 23?