How to hide a password?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Location: Khanom, Nakhon Si Thammarat, Thailand
Contact:

How to hide a password?

Post by paulsr » Sun Aug 26, 2012 11:47 am

Greetings:

I am developing an app which begins with a user having to login with a username and password.

I can't find any way to hide the password, with blobs or asterisks or something.

I've found links to code which is supposed to do this, but haven't managed to find the code itself.

I'm kind of surprised that LiveCode doesn't have an option (maybe in the Inspector) to say "this is a password field."

I've found "ask password" but that's not quite what I want. I rather not have an answer box popping up, after the user has entered a user name.

Can someone steer me in the right direction please...

TIA

--paul

LittleGreyMan
Posts: 49
Joined: Sat Jun 16, 2012 7:57 pm
Location: City of God Lug

Re: How to hide a password?

Post by LittleGreyMan » Sun Aug 26, 2012 12:19 pm

Hi Paul,

AFAIK, ask password is the only build-in command allowing this in LC. If it doesn't suits you, you have to manage it yourself, using a keydown handler.

Maybe somebody has already written such a piece of code and will chime in.

Did you have a look at the User samples?
Best regards,

Didier

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: How to hide a password?

Post by jmburnod » Sun Aug 26, 2012 12:31 pm

Hi Paul,

It seems that is not easy to do it
some experiments here:
http://forums.runrev.com/phpBB2/viewtop ... ord#p56323
Best regards
Jean-Marc
https://alternatic.ch

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: How to hide a password?

Post by dunbarx » Sun Aug 26, 2012 4:57 pm

Hi.

This has come up several times. I can't remember what happened.

Make a field named "f1". Put this into its script:

Code: Select all

on keydown var
   put numToChar(161) after me
   set the currentPassword of me to the currentPassword of me & var
end keydown

on mouseEnter
   put "" into me
   set the currentPassword of me to ""
end mouseEnter
In a button somewhere, place this into its script:

Code: Select all


on mouseup
   if the currentPassword of fld "f1" = the passWordData of fld "f1" then goAheadWithYourStuff
end mouseup
You need to set the passWordData of that field (another custom property) to the string of your choice.

Do you see how it works? Do you see that using the "delete" key is not managed? What are we going to do about that?

Craig Newman

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How to hide a password?

Post by Mark » Sun Aug 26, 2012 5:34 pm

Hi,

It is quite complicated to make a really good password field, but I think I've manage to make something that works. You can find it here, but a donation is required.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

wsamples
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 262
Joined: Mon May 18, 2009 4:12 am

Re: How to hide a password?

Post by wsamples » Sun Aug 26, 2012 6:18 pm

You could look at DropTools. One of the available tools is a password field. It's free and easy to add to your stack.

http://droptools.sonsothunder.com/produ ... ag-pw.irev

http://droptools.sonsothunder.com/moreinfo.irev
http://droptools.sonsothunder.com/all.irev

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Location: Khanom, Nakhon Si Thammarat, Thailand
Contact:

Re: How to hide a password?

Post by paulsr » Mon Aug 27, 2012 4:54 am

wsamples wrote:You could look at DropTools. One of the available tools is a password field. It's free and easy to add to your stack.

http://droptools.sonsothunder.com/produ ... ag-pw.irev

http://droptools.sonsothunder.com/moreinfo.irev
http://droptools.sonsothunder.com/all.irev
Thank you! That was what I found last week, failed to bookmark and couldn't relocate!

--paul

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Location: Khanom, Nakhon Si Thammarat, Thailand
Contact:

Re: How to hide a password?

Post by paulsr » Mon Aug 27, 2012 4:56 am

Oh dear. Looks like I even downloaded it. More coffee needed.

--paul

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Location: Khanom, Nakhon Si Thammarat, Thailand
Contact:

Re: How to hide a password?

Post by paulsr » Mon Aug 27, 2012 10:44 am

Okay, that works a treat.

But, would you know how to clear the displayed password field? If a user enters an incorrect password, I'd like to clear out the asterisks.

I have tried ...

Code: Select all

put empty into fld "aagPasswordField"
but this only clears the display, not the contents of the variable. So when the user enters a new password, it is concatenated onto the old one.

TIA

--paul

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Location: Khanom, Nakhon Si Thammarat, Thailand
Contact:

Re: How to hide a password?

Post by paulsr » Mon Aug 27, 2012 11:51 am

Hmmm, I've just realized that to achieve what I need (YMMV) there's a very simple method...

I don't care about password encryption, I just don't want it to be visible on-screen. So, I created two Text Entry Fields, let's call them PW and AST.

I made them the same size, I placed AST directly on top of PW, and disabled it.

Then I put the flwg code into PW...

Code: Select all

on rawKeyUp
   put "*********************" into t_stars
   put the len of fld "PW" into t_len
   put char 1 to t_len of t_stars into fld "AST"
end rawKeyUp
So the user actually types into PW but only sees the contents of AST, which contains asterisks.

That code could no doubt be more elegant but the solution works for me, and may help someone else.

--paul

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7228
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: How to hide a password?

Post by jacque » Mon Aug 27, 2012 8:24 pm

I've tried all kinds of methods, but the password field I like best right now is this one:

http://runtime-revolution.278305.n4.nab ... 90644.html

This method is very easy to implement, and automatically takes care of everything a user might type into the field including backspaces, select all, delete, typing over a selection, etc. You don't need any code at all for those things, the engine does it for you.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Location: Khanom, Nakhon Si Thammarat, Thailand
Contact:

Re: How to hide a password?

Post by paulsr » Tue Aug 28, 2012 2:40 am

Thank you Jacque, I'll try that...

--paul

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”