برنامه بررسی صحت پسوورد
جمعه 28 مهر 1391 2:22 PM
سلام دوستان این برنامه یه رمزی رو که از قبل براش تعریف شده رو با پسووردی که کاربر وارد می کنه بررسی می کنه و اگه صحت داشته باشه بهش پیغام میده
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
#include <conio.h> /* needed for getch() */
#include <cstring> /* needed for strcmp() */
void main()
{
char RealPass[20] = "amazonpup"; /* the actual password */
char input = '\0';
int pass;
int p = 0;
int c = 0;
while( c == 0 ) /* keep trying until correct password is entered */
{
char Password[20] = { '\0' };
cout << "Password: ";
for(p = 0;p < 19;p++)
{
input = getch(); /* get character entered */
if( input != '\r' && input != '\b' )
{
if( isprint( input ) != 0 )
Password[p] = input; /* store input in Password */
if( iscntrl( input ) == 0 )
cout << "*"; /* print '*' instead of input */
}
else if( input == '\r' ) /* if input = 'return' then */
{
break; /* break out of for() statment */
}
/* UPDATED CODE */
else if( input == '\b' ) /* if input = 'backspace' then */
{
if( p > 0 ) /* Make sure that the 'password' prompt is not deleted */
{
cout << '\b' << " " << '\b'; /* erase the last '*' */
--p;
Password[p] = '\0'; /* overwrite last character with '\0' */
}
--p;
}
/* END OF UPDATED CODE */
}
pass = strcmp( RealPass, Password ); /* compare strings */
if( pass != 0 )
{
cout << "\a\n\n\tLogin Unsuccessful!\n" << endl;
}
else if( pass == 0 )
{
cout << "\n\n\tLogin Successful!\n" << endl;
cout << "Password entered: " << Password << endl;
c++;
}
if( p == 19 ) /* indicates too many characters were entered */
cout << "\a\n\nTo many characters entered!"
<< "\nPlease try again." << endl;
}
return;
}
Seyyed.Reza.Hashemian@Gmail.Com
دوستانی که سوالی دارند یا مایل به تماس هستند می توانند از اطلاعات بالا استفاده نمایند.
اگر هم تایپکی زدید و احتیاج به پاسخگویی سریع داشتید اطلاع دهید