BM>Hi everyone,
BM>Has anyone figured out a nice way to replace characters echoed in
BM>GETs with '*' characters. I want to do this to hide passwords on
BM>screen, but can't figure out how I can mix hidden passwords with a
BM>screen of regular GETs.
BM>Any thoughts appreciated.
BM>Bruce.
The code below is a simple password routine that echoes '*' in place of
characters entered via the keyboard.
set talk off
set escape off
set confirm off
set bell off
set safety off
restore from setup
CLEAR
mpassword=''
mshowpass=''
@ 10,10 say 'Enter password. * will echo. ' GET mshowpass DEFAULT ''
SIZE 1,10 WHEN checkpass()
READ
*!**********************************************************************
*******
*!
*! Procedure: CHECKPASS
*!
*! Called by: PASSWORD.PRG
*!
*!**********************************************************************
*******
PROCEDURE checkpass
for x = 1 to 3
DO WHILE .T.
mkey=INKEY(0)
DO CASE
CASE mkey=13
* enter/return
EXIT
CASE BETWEEN(mkey,48,57)
* is a number
mpassword=mpassword+CHR(mkey)
mshowpass = mshowpass+'*'
CASE BETWEEN(mkey,97,122)
* is lowercase letter
mpassword=mpassword+CHR(mkey)
mshowpass = mshowpass+'*'
CASE BETWEEN(mkey,65,90)
* is uppercase letter
mpassword=mpassword+CHR(mkey)
mshowpass = mshowpass+'*'
CASE mkey=127
* backspace
mpassword=LEFT(mpassword,LEN(mpassword)-1)
mshowpass=LEFT(mshowpass,LEN(mshowpass)-1)
ENDCASE
SHOW GETS
ENDDO
CLEAR READ
* routine to check password
if check(mpassword)=pcheck
* password is valid
wait window 'Your password is valid.' nowait
@ 12, 10 say 'Do you wish to change the password? ' get
mchange default .f.
read
DO WHILE mchange
@ 14, 10 SAY 'Enter the new password ' get newpass
size 1,10 default ''
read
@ 16, 10 say 'Enter the new password again. ' get
newcheck size 1,10 default ''
read
if newpass=newcheck
wait window 'Passwords match ' nowait
pcheck=CHECK(NEWPASS)
SAVE ALL LIKE PCHECK TO SETUP
MCHANGE=.f.
ENDIF
ENDDO
clear
return
ELSE
mpassword =''
mshowpass=''
show gets
WAIT WINDOW 'Invalid password! Try again.' nowait
ENDIF
endfor
quit
PROCEDURE CHECK
PARA MPASSWORD
mpasscheck=''
for z = 1 to len(alltrim(mpassword))
mpasscheck = mpasscheck+ ;
padl(alltrim(str(asc(substr(mpassword,z,1)))),3,'0')
endfor
RETURN MPASSCHECK
Brian.Copeland@encode.com (Brian Copeland)
--- QScan/PCB v1.17b / 01-0313
---------------
* Origin: Encode Online Orillia,Ont.705-327-7629 (1:252/305)
|