MODULE: Password v0.5 BETA - Masked text boxes for password input.

Started by monkey0506, Sun 04/12/2011 05:58:04

Previous topic - Next topic

monkey0506

Hi folks. Well, seeing as it's December 3rd (for a whole 18 minutes more in my timezone :P) I figured I'd better go ahead and release something. You know, coz it's December 3rd. International You May As Well Go Ahead And Release Something Day.

On somewhat of a whim I figured I'd see if I could mask the text in an AGS TextBox without utterly obliterating the existing text. From there I got a bit more ambitious, and after several hours trying to convert a rather simple C++ MD5 algorithm into AGS code, I decided to postpone the hashing portion of the module for now and just get some feedback on what I've done so far.

What I've done so far is this.

  • Created a struct called Password. You can create instances (as many as you want!) of this struct. Of course, unless they're linked to a TextBox control they're not really doing much for you.

    Password password;

  • Linkage between instances of the struct and the built-in AGS TextBox controls is done via Password.Control.

    password.Control = txtPassword;

    NOTE: You can only link a TextBox to one instance of the struct at any time (it is tracked internally, and is updated if the reference is removed). If you try to link the same TextBox to multiple Passwords (simultaneously, if one reference is removed you can link the TextBox to another Password), you will experience a fatal run-time error.


  • As soon as the control has been linked to an instance of the password struct, its text immediately becomes masked. All further input to the TextBox will also be masked.


  • You can specify an alternate character to mask the password (other than an asterisk) via Password.MaskChar.

    password.MaskChar = '~';

    This will make every character in the TextBox appear as a tilde instead of an asterisk.

  • You can read the actual text from the password field at any time thanks to Password.Text.

    if (password.Text == "SWORDFISH") Display("ACCESS GRANTED!");

  • If you need to set the password text from the script, you can do that by setting Password.Text directly, or by calling TextBox.SetPasswordText.

    password.Text = "SWOR";
    txtPassword.SetPasswordText("SWORF");

    NOTE: If you set the TextBox.Text of a control that is currently linked as a password, you will invalidate the internal cache of what has been typed in, and you will not be able to recover the entered text properly.

  • At any time if you want to unmask a TextBox, this can be done by simply setting Password.Control to null.

    password.Control = null;

I'll continue trying to figure out why my MD5 hashes are coming out as something utterly different to MD5 hashes, but I thought I'd go ahead and get this out there to see what people think.

Practical Usage Examples:

  • In-game password masking.
  • Password-protected save games (ask me how! :=)
  • Obfuscating the name of your players' save games, to make them really upset! 8)
  • Take over the world!
  • Something else!

Download

P.S. Sometimes BBCode can be a pain in the neck!

Joseph DiPerla

Joseph DiPerla--- http://www.adventurestockpile.com
Play my Star Wars MMORPG: http://sw-bfs.com
See my Fiverr page for translation and other services: https://www.fiverr.com/josephdiperla
Google Plus Adventure Community: https://plus.google.com/communities/116504865864458899575

monkey0506

I like finding ways of circumnavigating the whole "no pointers to custom structs" issue, because seriously they would have been useful here. But I think I managed to get by pretty good thanks to the fact that there's a limited number of TextBox controls in the game at any given time anyway (which allowed me to create a managed set of IDs for the struct instances you're creating without you having to call a silly Init function).

I have noticed that there's a very slight delay between the actual keyboard input and when the module is intercepting it, so the characters may flash on-screen (very, very, very briefly), but given that it would only be the exact character the player is typing at that moment, and it's only visible for a fraction of a second, I'd say it's negligible. I doubt password security is a top priority for AGS games. ::)

Hopefully someone will actually find this useful. In any case, it was a fun little technical experiment on several fronts. :D

Ghost

Hmm, good job indeed. I get a very brief flash, but that disappears as soon as I use windowed mode. Thumbs up.

dbuske

What if your blessings come through raindrops
What if your healing comes through tears...

monkey0506

The link has been updated. Host removed the "ing" suffix from the main domain my site is hosted under (although they still own both domains).

SMF spam blocked by CleanTalk