bool TEnterPasswordDialog::CanClose() { BYTE encryptedPassword[MAX_CRYPT_SIZE+IV_SIZE]; passwordEdit->GetText(password,sizeof(password)); // pad out password if it is less than the crypt key size if (strlen(password) < CRYPT_KEY_SIZE-1) { int sum=0; for (int i=0; i< strlen(password);i++) { sum += (int)password[i]; } for (i=strlen(password);i<CRYPT_KEY_SIZE;i++) { password[i] = sum % 31 + 1; // keep extra chars in the range of control chars } password[CRYPT_KEY_SIZE]=0; } ifstream datafile("pass.dat",ios::binary); datafile.read(encryptedPassword,sizeof(encryptedPassword)); datafile.close(); BYTE buffer[MAX_ENTRY_SIZE+IV_SIZE]; memset(buffer,0,sizeof(buffer)); memcpy(buffer,encryptedPassword,sizeof(encryptedPassword)); TCrypt *crypt = new TCrypt(); crypt->decrypt(buffer,sizeof(buffer),(BYTE *)password); delete crypt; if (strcmp((char *)buffer,password) != 0) { MessageBox("Sorry, that password is incorrect.","Incorrect Password"); if (++login_attempts > 2) CmCancel(); passwordEdit->Clear(); passwordEdit->SetFocus(); return false; } return TRUE; }
//---------------------------------- // Cancel Button Pressed //---------------------------------- void About::EvClickCancel(void) { CmCancel(); }
//---------------------------------- // Cancel Button Pressed //---------------------------------- void SetTool::EvClickCancel(void) { CmCancel(); }
//---------------------------------- // Cancel Button Pressed //---------------------------------- void UserFunc::EvClickCancel(void) { CmCancel(); }