Click here to Skip to main content
13,300,654 members (52,565 online)
Click here to Skip to main content
Add your own
alternative version


22 bookmarked
Posted 3 Sep 2007

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


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.


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. 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, IronPython, and pswrdgeniron

Figure 1 shows the Form1_Load method fire bootstrap() which handles importing the 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 Within the, a 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, "" is called with'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 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 directly. This workaround is described here (Issue 17). All other settings are saved directly to the itself. When bSavesettings_Click is fired pe.ExecuteCommand("i._savesettings()") is called and the IronPythonEngine handles opening 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
  • 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 </a />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.


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.



  • 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


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


About the Author

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 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, and a coding junkie. He also enjoys alternative music and a big Pearl Jam, Nirvana, new alternative music fan, and the Chainsmokers.

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

You may also be interested in...


Comments and Discussions

GeneralThis article could be very good if... Pin
pbromberg19-Sep-07 15:40
memberpbromberg19-Sep-07 15:40 
GeneralRe: This article could be very good if... Pin
JoeSox19-Sep-07 18:57
memberJoeSox19-Sep-07 18:57 
GeneralRe: This article could be very good if... Pin
Brady Kelly8-Oct-07 23:59
memberBrady Kelly8-Oct-07 23:59 
GeneralRe: This article could be very good if... Pin
JoeSox9-Oct-07 4:30
memberJoeSox9-Oct-07 4:30 
GeneralRe: This article could be very good if... Pin
JoeSox9-Oct-07 10:11
memberJoeSox9-Oct-07 10:11 
GeneralRe: This article could be very good if... Pin
JoeSox9-Oct-07 11:39
memberJoeSox9-Oct-07 11: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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171207.1 | Last Updated 6 Oct 2007
Article Copyright 2007 by JoeSox
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid