Hiding the password

This is a discussion on Hiding the password within the C++ Programming forums, part of the General Programming Boards category; Hey guys, well I usually do programs with a GUI, but this time I want a CLI. You know how ...

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    38

    Hiding the password

    Hey guys, well I usually do programs with a GUI, but this time I want a CLI. You know how you can add a option to an editbox so everything you type shows as * (password) Is there anyway to reproduce that effect in CLI or something else that will hide the password when it's getting typed?

    Thanks a lot.

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    Not in standard C++. The reason is that, typically, the console will not give your program control back until the user presses enter.

    You can do it in platform specific ways. I'm sure Google can turn something up.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    38
    I tried nothing really came out, I will try again. I remember once I made a mistake using colors in texts and everything I typed returned in a Red square. Maybe thats what I'm going to use.

  4. #4
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    Yeah that would work. If you are using windows.h you can set it like:
    Code:
    SetConsoleTextAttribute (han, BACKGROUND_RED | FOREGROUND_RED);

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    would still be able to copy that though

  6. #6
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    Perhaps there is an alternative console windowing that allows you to display text in the way you want.

  7. #7
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129

  8. #8
    Registered User
    Join Date
    Jun 2007
    Posts
    219
    Its possible in windows with getch() and getche() with conio.h you can also try getchar()
    But none of them will work on Linux.although both of them will work in windows if your Compiler Allows you to include conio.h
    Note
    You'd also need gotoxy().

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading a password from a file.
    By medeshago in forum C Programming
    Replies: 15
    Last Post: 12-21-2008, 06:20 AM
  2. [Q]Hide Password
    By Yuri in forum C++ Programming
    Replies: 14
    Last Post: 03-02-2006, 02:42 AM
  3. written command line password generator
    By lepricaun in forum C Programming
    Replies: 15
    Last Post: 08-17-2004, 08:42 PM
  4. Hiding input password
    By kagemand in forum C++ Programming
    Replies: 2
    Last Post: 11-23-2001, 07:32 AM
  5. password
    By hammers6 in forum C Programming
    Replies: 1
    Last Post: 10-10-2001, 12:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21