Results 1 to 3 of 3

Thread: Portable Console Password Prompt

  1. #1
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Portable Console Password Prompt

    How can I create a C++ Console application, compiled with GCC, portable to Linux and Windows, with a password prompt without echo (does not show the password as you type it)?

    I would like something like those:
    - with stars echo:

    User: bob
    Password: ******

    - or without any echo at all

    User: bob
    Password:

    I googled this for hours without finding any solution that were a Console application (usable with bash, dos, etc) compiled with GCC and portable to Windows and Linux.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Portable Console Password Prompt

    Well... you can't At least if you want it to be secure. Password prompters usually attach directly to the terminal or even bypass the interuption mechanisms present in the system (usually by using some system call, at least under Unix) to avoid keyloggers sniffing the password. If you don't care about security, you can use readline or ncurses libraries.

  3. #3
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Portable Console Password Prompt

    You can't?

    Can't you program this for both OS's separately and then use the preprocessor to select the right version at compile-time? Doesn't Qt do something similar in order to be OS independent?

    Like:

    #if WINDOWS
    // Windows code
    #else
    // Linux code
    #endif

    I don't know the exact syntax.
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.