Results 1 to 3 of 3

Thread: Hide password in C

  1. #1
    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.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    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 ().

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    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.

Similar Threads

  1. Replies: 6
    Last Post: 05-11-2011, 11:22 PM
  2. Windows 7 Starter: Hide router's password
    By mahaFEB in forum Networking & Security
    Replies: 4
    Last Post: 08-01-2011, 10:16 PM
  3. Replies: 9
    Last Post: 27-10-2010, 01:30 PM
  4. Auto-Hide toolbar won't hide?
    By Geoff from LA in forum Vista Help
    Replies: 8
    Last Post: 18-10-2009, 06:52 AM
  5. Replies: 7
    Last Post: 04-02-2008, 09:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,438,577.26231 seconds with 16 queries