Click here to Skip to main content
15,881,639 members
Articles / Programming Languages / C#
Article

Semantic Password Generator that Uses WordNet

Rate me:
Please Sign up or sign in to vote.
3.93/5 (8 votes)
5 Oct 2007CPOL4 min read 38.1K   758   23   6
C#+IronPython 2+WordNet+Python+.NET = w00t!
Image 1

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.<br />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.

Image 2
(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)


Written By
Chief Technology Officer Earthbotics.com
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, & he is currently working as an IT Manager 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, & a coding junkie. He also enjoys alternative music and a big Pearl Jam, Nirvana, new alternative music fan, and the Alison Wonderland.
He is currently working on earthboticsai.net<> which he says is fun and cool. Cool | :cool: :cheers:

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" [

Comments and Discussions

 
GeneralThis article could be very good if... Pin
pbromberg19-Sep-07 14:40
pbromberg19-Sep-07 14:40 
GeneralRe: This article could be very good if... Pin
JoeSox19-Sep-07 17:57
JoeSox19-Sep-07 17:57 
GeneralRe: This article could be very good if... Pin
Brady Kelly8-Oct-07 22:59
Brady Kelly8-Oct-07 22:59 
GeneralRe: This article could be very good if... Pin
JoeSox9-Oct-07 3:30
JoeSox9-Oct-07 3:30 
GeneralRe: This article could be very good if... Pin
JoeSox9-Oct-07 9:11
JoeSox9-Oct-07 9:11 
GeneralRe: This article could be very good if... Pin
JoeSox9-Oct-07 10:39
JoeSox9-Oct-07 10:39 

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

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