Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide password, during entry

Status
Not open for further replies.

mroth36

Programmer
Jul 21, 2005
27
0
0
Hi everyone, I am sure this is something simple but.....
How do you hide a password, when the user is entering it, showing asterick's, like all the software do?

Thank You
 
Thanks for the reply, but I am not using OOP, just '@ say get' to a memory variable (I will post this in the old version forumn, if I need to), I am using version 9.
 
I have vague memories of a horrible technique which used 6 single-character GETS side-by-side and hid each character as it was entered but you'll get a better answer in the FoxPro (old versions 1 to 2.6) forum.

Geoff Franklin
 

You don't even need to post this in the old version forum, just search it - you will find plenty of solutions.
Here are just 3 to mention:
thread182-924678
thread182-657606
thread182-29229

 
Will something like this work for you?

mcnt = 0
mpass = ''
DO WHIL mcnt < 8
mchar = 0
DO WHIL mchar = 0
mchar = INKEY()
ENDDO
DO CASE
CASE mchar = 127 .OR. mchar = 8 && ---(backspace)
IF mcnt > 0
@ 22,31+mcnt SAY " "
mcnt = mcnt - 1
@ 22,31+mcnt SAY ""
mpass = SUBS(mpass,1,LEN(mpass)-1)
ENDIF

CASE mchar = 13 && ---(return)
EXIT

CASE (mchar >= 65 .AND. mchar <= 90) .OR. (mchar >= 97 .AND. mchar <= 122)
mpass = mpass+UPPE(CHR(mchar))
mcnt = mcnt+ 1
@ 22,31+mcnt SAY "*"
ENDCASE
ENDDO

Regards,
Jim
 
THANK YOU AGAIN ALL, IT'S ALLWAYS APPRECIATED!
After thinking about, I came up with the below mentioned simple routine:
=============
@ 10,10 say 'Please Enter Password'
x=0
mpswd=''
DO WHILE .t.
x=x+1
y=ALLTRIM(STR(x))
mps&y=' '
@ 10,x+33 get mps&y
READ
IF mps&y=' '
EXIT
ENDIF
mpswd=mpswd+mps&y
@ 10,x+33 say CHR(INT(RAND()*100)) && or '*'
enddo
==============
Thank You all again.
 

Mroth36,

Just out of curiosity, why are you printing CHR(INT(RAND()*100)) as your password character? I would have thought it would be better for the user if you print a consistent character such as a star.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike, it's just more confusing for a potential hacker. But you are right, I think that the user, will be the biggest confuser, so I will stick, to an asterick!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top