Readable Passphrase Generator now provides a plugin interface to load custom dictionaries.

Rather than creating your own XML dictionary (which of course you can still do if you want) you create your own dictionary in a database, different XML schema, web service or wherever. Then define a class to load that dictionary into the standard in memory format.

How To

  1. Reference ReadablePassphrase.Words.dll
  2. Implement IDictionaryLoader
    1. This accepts a dictionary of string -> string. Ie: it accepts an already parsed connection string.
    2. Implement whatever mechanism you want to load your dictionary. You can use the MaterialisedWords provided in the main ReadablePassphrase.dll assembly, or implement your own. Either way, your words must inherit from the abstract Word classes in ReadablePassphrase.Words.dll
  3. Your loader can now be used by the console app via the --loaderdll, --loadertype and --loaderargs arguments.
  4. Provide more convenient overloads for your loader if you want to directly call your loader (ie: if you're writing your own app which references ReadablePassphrase.dll.

Further Details

See the ExplicitXmlDictionaryLoader in the main ReadablePassphrase.dll assembly as an example of how to implement a loader, and how I provide a variety of custom overloads for different scenarios (eg: loading from a file, a URL, an arbitrary stream or an XmlReader (the master overload).

An example of how to reference the generator with a custom loader:

    // You could add extra arguments to your loader constructor if you want.
    var loader = new MyCustomLoader();    
    // How you get your dictionary source is, of course, totally up to you.
    var source = GetCustomSource();
    // You can either use the connection string style here.
    // Or your own overload based on the type of GetCustomSource().
    var dict = loader.Load(source);
    // Finally, you need to connect the generator and your newly loaded dictionary.
    var generator = new ReadablePassphraseGenerator();
    // Now you're ready to generate readable passphrases!
    var passphrase = generator.Generate();

An example of how to use a custom loader from the console app (all on one line):

            --loaderdll custom.dll 
            --loadertype Namespace.MyCustomLoader 
            --loaderargs "foo=somewhere;bar=something;"

Last edited Jul 28, 2012 at 1:21 PM by ligos, version 1


No comments yet.