Menu

How can I prompt for a password?

2001-03-27
2012-09-26
  • Nobody/Anonymous

    I am writing a program which I need to prompt for a password.  I do not want the users password to be echoed to the screen.  I've tried getch, which my book says does not echo to the screen, but it does.  How can I prompt for text and not have the text written to the screen?

     
    • Curtis Sutter

      Curtis Sutter - 2002-08-21

      What compilier are you running?  getch() should work.  Whereas getche() will echo.  Send you code to curtis8@hotmail.com

      Curtis

       
    • Nobody/Anonymous

      ok, you need to get a book..  make sure it is one with input and output streams to the console screen.  You have to manipulate the iostream to read the character, store in a string, then replace the typed character with for instance '*' as a standard password char.  or you could completely stop it from showing anything on the screen.. I would post code, but if you look it up for yourself, you will actually learn it, rather than just copy and paste.

       
      • Nobody/Anonymous

        But take care. With this simplified approach it is fairly easy for someone with WORDPAD to edit the EXE file looking for nice words such as the password.

        e.g. You may have an 'if' statement to check that the password is correct such as:

        if (strcmp(psswd, "MyPass") == 0) {} ....

        The "MyPass" will show up in the EXE file like a Chernobyl-ian dog in the dark!

        I am sure that there are some crypto libs around but I am not and expert and therefore not able to point you in the right direction.

        Just wanted to let you know about the security issue.

        BlakJak :]

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.