Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 29-04-2009
Member
 
Join Date: Apr 2009
Posts: 50
Hide password in C

I have a little problem I use code which is given below to check in software that someone login with admin id I would just hide the password when entering how do I do?
Code:
 verifAdmin int () 
   ( 
     char username [100]; 
     char password [100]; 
     puts ( "\ n Please enter your username"); 
     FFL; 
     gets (username); 
     if (strcmp (identifier, "foo") == 0) 
     ( 
      puts ( "\ n Please enter the password"); 
      FFL; 
      gets (password); 
        if (strcmp (password, "bar") == 0) 
          ( 
            CLS; 
            puts ( "\ n \ n \ n"); 
            puts ( "\ n Welcome Administrator you will be redirected in 2 seconds"); 
            sleep (2); 
            return 1; 
          ) 
        else  
           ( 
            puts ( "\ n sorry you are not administrator"); 
            return 0; 
            ) 
     ) 
     else 
         ( 
           puts ( "\ n sorry you are not administrator"); 
           return 0; 
          ) 
   )
the fact I'm in ubuntu and I define the CLS system ( "clear") to clear the screen.
Reply With Quote
  #2  
Old 29-04-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: Hide password in C

Never use gets (). As it is impossible to know in advance how many characters will be read by gets (), and it will write all the characters read, even if they fall outside the buffer, this function is extremely dangerous to use. We have already used this failure to create security holes. ALWAYS USE fgets () instead of gets ().
Reply With Quote
  #3  
Old 29-04-2009
Member
 
Join Date: May 2008
Posts: 2,383
Re: Hide password in C

At the beginning of the program, call the necessary functions to initialize the library: initscr, cbreak.

Code:
while ((c = getch ())! = '\ n' & & n <len - 1) ( 
      if (! iscntrl (c)) ( 
          buffer [n + +] = c; 
          if (mask! = 0) 
              addch (mask); 
      ) 
  ) 

  buffer [n] = '\ 0'; 
  addch ( '\ r'); 
  addch ( '\ n');
Somewhere before leaving the program, call the necessary functions of cleaning and restoration of the library.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Hide password in C"
Thread Thread Starter Forum Replies Last Post
After updating McAfee Security Center Password Vault has ERASED all password Marquise Networking & Security 6 05-11-2011 11:22 PM
Windows 7 Starter: Hide router's password mahaFEB Networking & Security 4 08-01-2011 10:16 PM
*!NOT your usual Vista Password Problem - Incorrect Password even every time even after resetting fvuong Vista Help 9 27-10-2010 01:30 PM
Auto-Hide toolbar won't hide? Geoff from LA Vista Help 8 18-10-2009 06:52 AM
backup to a network drive is asking for username and password...whatusername and password? Lisa Hetherington Vista Help 7 04-02-2008 09:05 PM


All times are GMT +5.5. The time now is 01:36 AM.