Password Security Version 2.0

Language
Password.cpp Author : oursharingciub Date : September 26, 2014 Firday Email : [email protected] Tool : Dev C++ Language : C++ Notice: Reference Mr. Jake Rodriguez Pomperada programming
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <string>
  4. #include <windows.h>   //system(), Sleep( )
  5. #include <time.h>
  6.  
  7.  
  8. using namespace std;
  9.  
  10. const int PASSLEN= 7 ; //The length of password
  11.  
  12. string PassGet( void ); // Get the password
  13. void Menu( void );   //The start menu
  14.  
  15.  
  16. //******** main function **********
  17. int main( void )
  18. {
  19.         Menu();
  20.        
  21.         getch();  //wait untill enter any key
  22.        
  23.         return 0;
  24. }
  25.  
  26.  
  27. //****** PassGet and menu function*****
  28.  
  29. string PassGet( void )
  30. {
  31.         char password[ PASSLEN ]= { '\0' };
  32.         char letter;
  33.         int loop;
  34.         int len;
  35.         string password2;
  36.        
  37.         len= 0;
  38.         loop= 0;
  39.         letter= '\0';
  40.        
  41.         while( letter!= '\r' )   //Caarrige return character
  42.         {
  43.             letter= getch();
  44.                
  45.                 if( letter== '\b' && password[ 0 ]== '\0' )
  46.                 {
  47.                    loop= 0;
  48.                    len= 0;
  49.                 }
  50.                 else
  51.                 {
  52.                         if( letter== '\b' && password[ 0 ]!= '\0' )  // \b :backspace
  53.                         {
  54.                             cout<< "\b";
  55.                             cout<< " ";
  56.                             cout<< "\b";
  57.                            
  58.                             loop--;
  59.                             password[ loop ]= '\0';
  60.                             len-- ;
  61.                         }
  62.                         else
  63.                         {
  64.                             if( isprint( letter )!= 0 && loop< PASSLEN )
  65.                                 {
  66.                                 password[ loop ]= tolower( letter );
  67.                                
  68.                                 cout<< "*";
  69.                                 }      
  70.                                 loop++;
  71.                                 if( loop<= PASSLEN )
  72.                                 {
  73.                                    len++;      
  74.                                 }
  75.                         }      
  76.                 }
  77.         }
  78.        
  79.         //Convert Password from character
  80.         loop= 0;
  81.         password2= "";
  82.        
  83.         while( loop< len )
  84.         {
  85.             password2= password2+ password[ loop ];
  86.                
  87.                 loop++;
  88.         }
  89.         return password2;  
  90. }  //End of Passget function
  91.  
  92.  
  93. void Menu( void )
  94. {
  95.         string password;
  96.        
  97.         //Get local time<code><code></code></code>
  98.         time_t date;
  99.         date= time( NULL );
  100.        
  101.         cout<< "\n\n";
  102.        
  103.         char str[]= "********* PASSWORD SECURITY VERSION 2.0 **********";
  104.        
  105.         for( int i= 0; i< strlen( str ); i++ )
  106.         {
  107.                 cout<< str[ i ];
  108.                 Sleep( 100 );  //wait 0.1 second
  109.         }
  110.         cout<< "\n\n";
  111.         cout<< "\n\t\t Notice: Protect your Password.";
  112.         cout<< "\n\n\t\t Enter Your Password: ";
  113.        
  114.         password= PassGet();
  115.        
  116.         if( password== "sharing" )
  117.         {
  118.                 system( "cls" );
  119.                
  120.             cout<< "\n\n\n\n";
  121.                 cout<< "\t\t Password Accepted.";
  122.                 cout<< "\n";
  123.                 cout<< "\n\n\t\t Thank You For Using this Software.";
  124.                 cout<< "\n\n\t\t Date : "<< ctime( &date );        //show local time
  125.         }
  126.         else
  127.         {
  128.            cout<< "\n\n";
  129.            cout<< "\n\t\tSorry...";
  130.            cout<< "\n\t\tPassword Denied!!!\n\n";
  131.            
  132.            Sleep( 1000 );
  133.            
  134.            cout<< "\n\n\t\tTry Again( Y ): ";
  135.            
  136.            char ch;
  137.            
  138.            cin>> ch;
  139.            if( toupper( ch )== 'Y' )
  140.            {
  141.                         system( "cls" );
  142.                        
  143.                     Menu();
  144.            }
  145.            else
  146.            {
  147.                     exit( 1 ); 
  148.            }
  149.         }
  150.        
  151.         return ;
  152. }   //End of Menu Function

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Tags

Add new comment