473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to take passwords input as ****** or just nothing

Hello,
I am making a console application in C++ where I have to take username and password as input from user.
I want that when password is taken, it should not be shown on screen, i.e. it is either shown as asterix(*******) or just no movement of cursor.

Please Reply
Pawan
Mar 10 '07 #1
6 10175
horace1
1,510 Expert 1GB
Hello,
I am making a console application in C++ where I have to take username and password as input from user.
I want that when password is taken, it should not be shown on screen, i.e. it is either shown as asterix(*******) or just no movement of cursor.

Please Reply
Pawan
some windows compilers have a header file <conio.h> with a function getch() which reads a character from the keyboard without echo .
Mar 10 '07 #2
vermarajeev
180 100+
some windows compilers have a header file <conio.h> with a function getch() which reads a character from the keyboard without echo .
Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.    char ch;
  4.    string password;
  5.    while ( (ch = getch()) != '\r' )
  6.    {  
  7.          password.push_back(ch);
  8.    }
  9.    cout<< "You entered :"<< password<<endl;
  10.    return 0;
  11. }
You can use above code for windows, For Linux, there is something called getpass( char* ); type man getpass on console to see how it works.
Mar 12 '07 #3
Hello,
I am making a console application in C++ where I have to take username and password as input from user.
I want that when password is taken, it should not be shown on screen, i.e. it is either shown as asterix(*******) or just no movement of cursor.

Please Reply
Pawan
use getpass function
or print *** using getch and putch in a for loop
Mar 13 '07 #4
use getpass function
or print *** using getch and putch in a for loop
What is this getpass() function, I didnt find it anywhere!
Pawan
Mar 18 '07 #5
Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.    char ch;
  4.    string password;
  5.    while ( (ch = getch()) != '\r' )
  6.    {  
  7.          password.push_back(ch);
  8.    }
  9.    cout<< "You entered :"<< password<<endl;
  10.    return 0;
  11. }
You can use above code for windows, For Linux, there is something called getpass( char* ); type man getpass on console to see how it works.
Thanks, it worked.
Pawan
Mar 18 '07 #6
nice. it works perfectly!!! thx, i've been searchin ds codes for ages..
Mar 19 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Miranda | last post by:
Hi, I have a ASP/vbscript program that generates random passwords. The problem is I need to insert those passwords into an Access database of 327 clients. I have the random password program...
12
by: Andrew DeFaria | last post by:
I am developing a database application in which I store usernames and passwords. Naturally I want to store the passwords in an encrypted form. However, just like you see in many web applications, I...
1
by: Paradigm | last post by:
I want to store some passwords in a MySQL table. Is there any way of preventing someone using say COntrolcentre from viewing the passwords.
10
by: Dino M. Buljubasic | last post by:
Hi, I am using MD5 to hash my passwords and add them to database as hashed. I have noticed though that some passwords don't get recognized and I suppose that it happen because hashing might...
15
by: Joshua Kendall | last post by:
I have a script in which it keeps opening the same form instead of only one instance. I also need help with a form that has a password. Where do I put the actual password? can I use a database for...
6
by: Jan | last post by:
Hi: I have created a secured database for a client. For various reasons, I don't want the client to have full persmissions for the database; they aren't in the admins group. I have instead tried...
5
by: k.i.n.g. | last post by:
Hi, I have a csv file which in taken as the input file for adding users in my linux mail server with the format userid,fullname,passwword,dateofbith Now I have to write a script to generate...
19
by: Cord-Heinrich Pahlmann | last post by:
Hi, I have written a tool wich de/encrypts a few of my forum and bloggin-Passwords. My question is how secure it is. The following describes how I have encrypted my passwords. When I log in,...
1
by: Laurie Comerford | last post by:
Hi, I'm using this very simple code to open a web site and it works perfectly. The site requires that I enter a User Name and password. I'd like to send those with the application but after...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.