Board Logo
« Simple Password Masking »

Welcome Guest. Please Login or Register.
Nov 21st, 2009, 9:26pm



Conforums Terms of Service | Membership Rules | Home | Help | Search | Recent Posts | Notification | Format Your Message | Vista/Win7 FAQ

Please use the forums Search feature before asking. For best results select only the categories, which describe your need best.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is to long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.
To register at the Just BASIC Files Archive Site, please follow the instructions given in File Archives - Important Registration Information.

Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Simple Password Masking  (Read 94 times)
jaba
Junior Member
ImageImageImage

member is offline

Avatar




PM

Gender: Male
Posts: 96
xx Simple Password Masking
« Thread started on: Nov 6th, 2009, 2:41pm »

A simple routine that masks the password as user enters it and then confirms it. Doesn't require a lot of code just to display an asterisk.
Code:
nomainwin
password$="secret"

WindowWidth=260
WindowHeight=160

statictext #1.st, "Enter user name and password", 30, 10, 200, 20
textbox #1.tb, 30, 35, 100, 25
textbox #1.tb2, 30, 65, 100, 25
button #1.ok, "   Confirm   ", [maskMe], UL, 135, 65
statictext #1.st2, "", 30, 100, 200, 25
statictext #1.st3, ">>", 18, 100, 11, 25

open "Password Test" for window as #1
#1 "trapclose [quit]"
#1.tb, "!setfocus";
#1.tb2, "!font symbol 6";

[askMe]
#1.tb2, ""
wait

[maskMe]
#1.tb2, "!setfocus"
#1.tb2, "!contents? pass$"
fl=len(pass$)
if right$(pass$, 2)=chr$(13) then
    pass$=left$(pass$, fl)
end if

if pass$=password$ then
    #1.st2, "Password confirmed"
    else
    #1.st2, "Incorrect. Enter new password" :goto [askMe]
end if
wait

[quit]
close #1
end
 

This may not be too secure, but it should work fine for games and simple programs requiring a password to continue.
User IP Logged

cundo
ThreadRestoreGroup


member is offline

Avatar




PM

Gender: Male
Posts: 887
xx Re: Simple Password Masking
« Reply #1 on: Nov 7th, 2009, 2:59pm »

This one uses a graphicbox to display random data
Code:
nomainwin
mypass$="secret"
ForegroundColor$ = "BLACK" : BackgroundColor$= "BUTTONFACE"
WindowWidth=380 : WindowHeight=130
textbox #1.tb1, 30, 35, 100, 25

'the graphicbox that displays the random symbols
graphicbox #1.gbx, 132, 35, 100, 25

TextboxColor$ = "BLACK"
' this hidden textbox is going to take the user input.
textbox #1.tb2, 30, -100, 100, 25

' a default button recieves input from the Enter Key
button #1.default, "Accept", [check], UL, 242, 35,100,25

open "The Password is ";CHR$(39);"secret";CHR$(39) for dialog_nf as #1
#1 "trapclose [quit]"
#1 "Font Courier_new 10"
#1.gbx "Font Courier_new 7 19 bold"
#1.gbx, "color red; backcolor white"
#1.gbx, "down ; fill white ; flush "
#1.tb1, "!setfocus"
#1.gbx, "when leftButtonDown [lbd]"

wait

[lbd]
    #1.tb2 "!setFocus"
    #1.tb1 "!contents? nameText$"
    #1.gbx "fill white"
[simtb]
Timer 0
     #1.tb2 "!contents? verify$"
     ToDsp$ =""
     For i = 1 To Len(verify$)
        t$ = CHR$( int( rnd(0)*10 ) + 48)
        ToDsp$ = ToDsp$;t$;" "
     Next
    #1.gbx "place 1 13"
    #1.gbx "|";ToDsp$;space$(10)
    #1.gbx "discard"

Timer 100, [simtb]
wait

[check]
#1.gbx "cls" : #1.tb2 ""
Timer 0
if verify$=mypass$ then
     great = 1
     goto [quit]
end if

#1.gbx "place 1 13;cls;fill white"
#1.gbx "|Wrong Pass!"
playwave "no_wave_here"
#1.tb1, "!setfocus"
wait

[quit]
if great then notice "YEAH!";CHR$(13);"The Password is correct!"
close #1
END

 
There is a problem, sometimes the textboxes do not accept input. ???
« Last Edit: Nov 7th, 2009, 2:59pm by cundo » User IP Logged

cundo aka MSlayer
Stefan Pendl
Administrator
ImageImageImageImageImage

member is offline

Avatar

Let's talk JB ...


PM

Gender: Male
Posts: 2158
xx Re: Simple Password Masking
« Reply #2 on: Nov 8th, 2009, 04:48am »

on Nov 7th, 2009, 2:59pm, cundo wrote:
This one uses a graphicbox to display random data

---snip

There is a problem, sometimes the textboxes do not accept input. huh


Make sure to set the focus to the next control just before the WAIT command, else it can happen, that the control will loose focus, because you are accessing a different control from within your code.
User IP Logged

Stefan

Any code I post can be used by others in their own projects, there is no need to ask for permission, just give credit if you like

Just BASIC 1.01, Windows Vista Home Premium SP2, AMD Turion X2 RM-70 2GHz, 4GB RAM
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Help | Search | Recent Posts | Notification | Format Your Message | Vista/Win7 FAQ


New Monthly Ad-Free Plan!

$6.99 Gets 50,000 Ad-Free Pageviews!
| Free Shoutboxes | Hookah |

This Board Hosted For FREE By Conforums ©
Get Your Own Free Message Board!