Set max lenght

Mar 27, 2013 at 5:34 PM
It is possible to set a max length for the overall password?
Coordinator
Mar 28, 2013 at 10:12 AM
Yep!

In the latest version, drill into the settings dialog (the "cog" button next to the custom phrase generator drop down) and there's a min / max range there.

This page has some graphs showing how long the passphrases can be (as an idea for what range you want to choose):
http://readablepassphrase.codeplex.com/wikipage?title=Combination%20Counting
Mar 28, 2013 at 6:13 PM
Thanks.

I'm using the API to hook in (nice API I like it). I saw the bit about setting max length to generate a set of passwords, but I couldn't figure out how to do it for one password. I'm probably just missing something.

I thought perhaps using the PhraseStrength string, but I must admit I couldn't quite get my head around how to set it up using string (though I'm a little tired!).

If you get a chance it would be awesome to have a working example in documentation about how to create PhraseStrength / max length.

thanks again.
Coordinator
Mar 29, 2013 at 10:33 PM
Ahhh, you're using the API, not the GUI! Well, that changes things a bit.

The password length isn't directly controlled in the API. You need to filter the resulting passphrases manually. Here's the relevant code from the console app:
    var phrase = generator.Generate(strength, includeSpaces);
    if (phrase.Length >= minLength && phrase.Length <= maxLength)
        Console.WriteLine(phrase);
If you want to filter based on the number of words, use the Enumerable.Count() LINQ method:
    var phrase = generator.Generate(strength, includeSpaces);
    var wordCount = phrase.Count(c => c == ' ') + 1;
    if (wordCount >= minLength && wordCount <= maxLength)
        Console.WriteLine(phrase);
    
PS: Feel free to browse the source for the console app (via the Source tab or Mercurial). It demonstrates most features of the generator. Also, the test app has a function somewhere in there to dump samples from all the different PhraseStrengths, some examples may help you get your head around them.

Murray
Mar 29, 2013 at 11:03 PM
Cool thanks Ligos, I'll give that a shot when I get back to work. Good plan to take a look at the console app, I'll take a peak.

On Friday, March 29, 2013, ligos wrote:

From: ligos

Ahhh, you're using the API, not the GUI! Well, that changes things a bit.

The password length isn't directly controlled in the API. You need to filter the resulting passphrases manually. Here's the relevant code from the console app:
    var phrase = generator.Generate(strength, includeSpaces);
    if (phrase.Length >= minLength && phrase.Length <= maxLength)
        Console.WriteLine(phrase);
If you want to filter based on the number of words, use the Enumerable.Count() LINQ method:
    var phrase = generator.Generate(strength, includeSpaces);
    var wordCount = phrase.Count(c => c == ' ') + 1;
    if (wordCount >= minLength && wordCount <= maxLength)
        Console.WriteLine(phrase);
    
PS: Feel free to browse the source for the console app (via the Source tab or Mercurial). It demonstrates most features of the generator. Also, the test app has a function somewhere in there to dump samples from all the different PhraseStrengths, some examples may help you get your head around them.

Murray

Read the full discussion online.

To add a post to this discussion, reply to this email ([email removed])

To start a new discussion for this project, email [email removed]

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com