0
Votes in Release
(breakdown)
Password Generator based on Anagrams

Description


Whenever I needed to create new user accounts, I always struggle with "Which temporary password do I assign that user?" Normally I used just SYS(2015) for a random string, but users don't appreciate those... Then some time ago I stumbled over that Anagram Generator which produces very interesting lists of permutations of the entered characters. Of course a manual copy and paste of those parameters isn't too much fun, thus I had the idea to call that service from a FoxPro form, which is again called from the user maintainance application. Shouldn't be too difficult, eh? Just something for that rest of an evening or so.... And with some initial help from my buddy Bernhard Reiter for the Internet stuff I ended up with this solution.

So, if you modify the sample form "CreatePassword.scx", you'll see some helper objects on that form, the most interesting part here is the
Anagram Class
It has several properties, which are connected to all those textboxes, listbox and spinners. (Depending on your needs you would normally just set those properties once, but for education purposes I added them all...) I use the ControlSources of that controls to directly connect to the properties of the object. And it has two methods:
GetAnagram: This one makes use of the MSXML2 object, (which should be available on any PC which has it's VFP runtime correctly installed). Downloading some Internet files is super easy with that. Interesting parts: The use of TEXTMERGE() and EVL() to assemble the URL with all it's parameters. Also STRCONV() is very handy to convert the returned content from DBCS (UTF-16) to readable content. This HTML-String is then sent to
ParseResult, which uses STREXTRACT() to cut the useful information out of all that ads and formatting stuff. It then cleans the resultset with some help of STRTRAN() etc, and finally converts it into a collection for returning the information back to the caller.

The sample form isn't too complicated: There's just the one "Get!" button, which calls the Thisform.DoYourJob method, which in turn calls the Anagram-object and connects the returned collection with the listbox. The rest is fancy things like Anchoring of the controls, (the Gripper in the down-right corner denotes a resizable form) and saving the various settings of those parameters to an INI-file with the
INI-Saver
This class is a subclass of the Inihandler class. It has a property which just holds a comma-separated list of propertynames to save and restore (the default is the forms top, left, height and width); you just drop that class on a form and that's it: positions saved and restored automagically.
Hmm, where do we save, especially in Vista? I use HOME(7) as general user-related storage area here (see the IniSaver.INIT for setting the filename)
The underlying INIHANDLER class is just a wrapper to the various API calls, which I wrote some eons ago...

So have fun with your new passwords! How do you use it in praxis? You may just DO FORM and enter the First- / Lastname of your new user. Since that sample form is modal, you could call it like a function:
DO FORM CreatePassword WITH User.LastName TO cPassword
Of course you can also drag&drop some selected text to the first textbox, and drag the result back from the listbox to your userform (In that case you have to set the Form.WindowType to Modeless!). And since someone already asked: Yes, you can optionally transfer the input as parameter when calling DO FORM also in modeless mode.

One caveat: If those guys over at WordSmith.org will change their website, then the parsing code will probably fail. Screenscraping is a thing of the past, but since that website doesn't provide a webservice yet, we have to live with that.
And: hey it's just a sample for fun!

Uploaded Rev.2 with some small enhancements...


Files

Source Code AnagramPW.zip
source code, 22K, uploaded Feb 21  - 184 downloads


Work Items

Proposed

= Proposed

Active

= Active

Fixed

= Fixed

Closed

= Closed

There are no work items associated with this release.



Updating...
Page view tracker