Click here to Skip to main content
Click here to Skip to main content
Go to top

Semantic Password Generator that Uses WordNet

, 5 Oct 2007
Rate this:
Please Sign up or sign in to vote.
C#+IronPython 2+WordNet+Python+.NET = w00t!

Table of Contents

Introduction

Want a cure for password writer's block? Well, here is pswrdgeniron to iron out your password creation blues. The heart of this application is written in Python and Microsoft's IronPython 2.0A4 is its bridge to the .NET world.

pswrdgen

There are many differences between IronPython 1 and 2. As of this writing, IronPython 2 is still Alpha, however it can still get the job done. One of the biggest differences between the two versions is the handling of passing variables between the non-native IronPython objects and the PythonEngine. In version 1 the PythonEngine.Globals method was used to set and get variables created in Python code. That method has been removed in IronPython 2 and in its place is the use of

Microsoft.Scripting.ScriptDomainManager.
CurrentManager.Host.DefaultModule.SetVariable
. Long namespace? Yes it is, but it fits with Microsoft's Dynamic Language Runtime (DLR) model. So what about this pswrdgeniron? Well, let me explain. pswrdgen.py is written in CPython 2.4 and is designed to run on any operating system. It is a CLI app. pswrdgeniron imports all of the methods in pswrdgen and provides a GUI for Windows users.

(Figure 1) Flow of pswrdgen.py, IronPython, and pswrdgeniron

Figure 1 shows the Form1_Load method fire bootstrap() which handles importing the pswrdgen.py via the IronPythonEngine ("pe"). Once this is done, the parallel variables get constructed in pswrdgeniron. bootstrap() also checks and makes sure the user has Python24. It is needed to import the OS module for pswrdgen.py. Within the IronPythonEngine.pe, a pswrdgen.py instance was created named "i". The user may change the values of the settings by modifying the controls in the user interface. Most of the autoupdating of the other controls are dependent upon the minimum length of the password. Once when "Min Length" control is changed, it changes other controls to avoid non-logical settings. For example, if the minimum length of a password is 6, you cannot capitalize more that 6, so 7 will not be listed as a valid choice in the dropdownbox control. When the user activates bRun_Click, "i.run()" is called with IronPythonEngine.pe. pswrdgen.py's "run" method generates just one completed password so this call is looped to GENCOUNT (GENerate password COUNT).

When calling for objects to be returned from the IronPythonEngine, it is necessary to cast the objects back and in some cases return an instance. For example, SWAPS is a PythonDictionary object created from the textbox text from tbSwapSet and needs an instance of the object, so Clone() is called.

SWAPS = (PythonDictionary)pe.EvaluateAs<pythondictionary />(tbSwapSet.Text.Trim()).Clone();

Custom Word files can be added using pswrdgeniron or pswrdgen.py. Using pswrdgeniron involves browsing to the new wordlist file. If the file is valid, it will be sent to the IronPythonEngine and added to i.WORDFILELISTS. There is currently no way to save custom file additions using pswrdgeniron directly. The workaround to do this is to update pswrdgen.py directly. This workaround is described here (Issue 17). All other settings are saved directly to the pswrdgen.py itself. When bSavesettings_Click is fired pe.ExecuteCommand("i._savesettings()") is called and the IronPythonEngine handles opening pswrdgen.py to append the changes to the settings section.

pswrdgen Features

If you believe passwords can be secure and still be remembered by administrators, then you may enjoy using pswrdgen and pswrdgeniron.

  • Automatically chooses fresh nouns from WordNet
  • Random capitalization of characters in chosen words
  • Define your own swapping ruleset to use in chosen words
  • Choose the lengths of your desired passwords
  • Auto-update feature for pswrdgen.py
  • Random character insertion into a chosen word
  • Use custom word list files not just WordNet
  • Save your custom settings (Does not save custom word lists)

If you just wish to run the application, make sure you have downloaded WordNet and .NET 2.0 runtime before running the binary Windows Installation setup. If you wish to work with the source, you will need Microsoft's IronPython 2.0Ax and reference to it and Microsoft.Scripting.

Conclusion

pswrdgeniron is a semantic password generator that uses WordNet, random capitalization, and character swapping. Maybe I didn't search the Internet long enough to find something like this application to generate passwords that I like. This application generates amusing and secure passwords that administrators can remember and it does this at lightning speeds compared to indecisive people like myself. Who knows, you might even discover some words you have forgotten about or learn some new dinosaur names while creating your lists of choices. Prerequisite: WordNet and .NET 2.0 runtime.

References

Updates

  • 9/3/07
    • Article posted - Created and tested on Microsoft's IronPython 2.0A3 (2.0.10724.00) on .NET 2.0.50727.832, Windows XP, MSVS 2005
  • 9/6/07
    • Changed section to C# Programming from Cross Platform
  • 9/18/07
    • Added random insertion
    • Added configuration saving
    • Tested with IronPython 2 Alpha4
  • 9/19/07
    • Uploaded new version 0.3.5 to address IronPython not handling Python25 and/or no Python24 residing on user's computer
  • 10/05/07
    • Uploaded new version 0.4.0
    • Added dropdown combobox for custom Word file integration handling (Words must be in front of each line in the custom word file)
  • 10/07/07
    • Uploaded new version 0.4.1: Fixed two minor GUI bugs

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

JoeSox
Network Administrator
United States United States
Born in Pennsylvania (USA), just north of Philadelphia. Joe has been programming since he was ten[now much older]. He is entirely self-taught programmer, and he is currently working as a Network Administrator (and a bunch of other crap) in Seattle WA. He was previously U.S. Navy Active Reservist for (SPAWAR)
In '98 was honorably discharged from the USN. He served onboard the USS Carl Vinson (94-98) He was lucky enough to drink President Clinton's leftover wine, promoted by his Captain, and flew in a plane off the flightdeck but not all at the same time. His interests, when time allows, are developing
misc apps and Artificial Intelligence proof-of-concept demos that specifically exhibits human behavior. He is a true sports-a-holic, needs plenty of caffeine, and a coding junkie. He also enjoys alternative music and a big Pearl Jam, Nirvana, and new alternative music fan.
 
Joe is an INTP[^] personality type. Joe "sees everything in terms of how it could be improved, or what it could be turned into. INTP's live primarily inside their own minds." INTPs also can have the "greatest precision in thought and language. Can readily discern contradictions and inconsistencies. The world exists primarily to be understood. 1% of the total population" [
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

 
GeneralThis article could be very good if... Pinmemberpbromberg19-Sep-07 14:40 
GeneralRe: This article could be very good if... PinmemberJoeSox19-Sep-07 17:57 
GeneralRe: This article could be very good if... PinmemberBrady Kelly8-Oct-07 22:59 
GeneralRe: This article could be very good if... PinmemberJoeSox9-Oct-07 3:30 
GeneralRe: This article could be very good if... PinmemberJoeSox9-Oct-07 9:11 
GeneralRe: This article could be very good if... PinmemberJoeSox9-Oct-07 10:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 6 Oct 2007
Article Copyright 2007 by JoeSox
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid