cin>>pass; //pass is the user entered word
//user entered word it should appear in "*"....
if (pass!=real)
cout<<"wrong password!!";
else
:
:
Replace Password Entry with Asteriskscreating password related program..
Page 1 of 1
8 Replies - 6981 Views - Last Post: 21 January 2010 - 08:16 AM
Replies To: Replace Password Entry with Asterisks
#2
Re: Replace Password Entry with Asterisks
Posted 20 January 2010 - 07:03 AM
if u use windows and u have conio library try getpass , it wont show the pass, if u want to make ur own function (still if u use windows) try getch, it will get the ASCII and wont echo on screen then u can echo * and reinterpret the ASCII, of course maybe there are better ways to do it. On *nix i dont know sry
#3
Re: Replace Password Entry with Asterisks
Posted 20 January 2010 - 07:23 AM
Just iterate through all 'pass' characters using a for loop, and replace every char with a '*'. Example: a[1] = '*', a[2] = '*' .... a[i] = '*'. It's very simple ...
This post has been edited by sarmanu: 20 January 2010 - 07:23 AM
#4
Re: Replace Password Entry with Asterisks
Posted 20 January 2010 - 10:31 AM
Use getch() and if you want to make it so you can hit enter to end it you will need to have it ignored(its character 13 if you are wondering).
#5
Re: Replace Password Entry with Asterisks
Posted 20 January 2010 - 02:22 PM
heh.. In the Borland Turbo C++ book there's a getche() that may work, get character and echo... But I have done it with getch() and checking for the integer value of 13 in the ascii character. on the visual studio 2010 beta 2 it looks like getche() doesn't have any options for what character to output when it nabs one.
When the user is typing the password I don't think it will show on the screen. That's probably what he/she wants. getch()
puts() is also in there, it lets you type a string and adds the \n to the end...
When the user is typing the password I don't think it will show on the screen. That's probably what he/she wants. getch()
puts() is also in there, it lets you type a string and adds the \n to the end...
This post has been edited by taylorc8: 20 January 2010 - 02:29 PM
#6
Re: Replace Password Entry with Asterisks
Posted 20 January 2010 - 03:58 PM
You'll need to have it cout the stars after the getch manually.
#7
Re: Replace Password Entry with Asterisks
Posted 20 January 2010 - 04:53 PM
I have successfully made such a function which prints Asteriks instead of any input. Backspaces are also handled. In any case as per the rules of dreamincode I cannot hand you the code but I can guide you how I did it:
The basic algo was:
I took an array and put in a password to compare
Then asked the user to enter a password
from the conio.h library you can use the getch() function to take input without the input showing on the output screen.
You can store that input in a temporary variable
Then check to see what that input is
There is another library cctype you can use to check if the entered input is a digit or whatever you can check that here:
http://www.cplusplus...library/cctype/
And well then you can use a couple of if conditions to print whatever you wish a * or & or whatever
Try figuring out the algo for backspaces if you do not get it let me know.
The basic algo was:
I took an array and put in a password to compare
Then asked the user to enter a password
from the conio.h library you can use the getch() function to take input without the input showing on the output screen.
You can store that input in a temporary variable
Then check to see what that input is
There is another library cctype you can use to check if the entered input is a digit or whatever you can check that here:
http://www.cplusplus...library/cctype/
And well then you can use a couple of if conditions to print whatever you wish a * or & or whatever
Try figuring out the algo for backspaces if you do not get it let me know.
#8
Re: Replace Password Entry with Asterisks
Posted 20 January 2010 - 05:24 PM
I do actually believe there will be a snippet on it shortly, hopefully.
#9
Re: Replace Password Entry with Asterisks
Posted 21 January 2010 - 08:16 AM
Thanks a lot to all !!
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote








|