login about faq

I would very much like to see the following overloaded method added to the Chilkat.Prng class:

public string RandomPassword(int length, bool mustIncludeDigit, bool mustIncludeUppercase, bool mustIncludeLowercase, string mustHaveOneOf, string excludeChars);

The reason is obviously that the current method

public string RandomPassword(int length, bool mustIncludeDigit, bool upperAndLowercase, string mustHaveOneOf, string excludeChars)

gives the option to require upper- and lower-case characters in the generated string, but does not have an option limit to only upper- or lower-case characters. If upperAndLowercase is set to false, the generated string may contain both upper- and lower-case characters, but it is not guaranteed to have both.

I want to have an option similar to that of the RandomString() method, where I can specify explicitly to include or exclude each case.

asked Nov 13 '15 at 09:29

roan98dk's gravatar image


After some testing and consideration, it may not be as simple as that. At first I read e.g. the argument bool mustIncludeDigit as if it is set to false, the generated string will not contain any digit. But what it really means is true = required, false = optional (not excluded). That however is easy to solve by adding all digits to the argument string excludeChars.

(Nov 13 '15 at 13:02) roan98dk

And after even more testing it appears that the method already appears to handle what I am requesting. Well sort of, because there appears to be a bug in this method that randomly creates string that does not satisfy the criteria, but a simple retry can be used as workaround for now.

Say I want only lower-case characters in the generated string, I simply call RandomPassword(8, false, false, "", "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"). This way no symbols are used, digits now required and excluded, upper-case chars not required and excluded.

(Nov 17 '15 at 04:06) roan98dk
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Nov 13 '15 at 09:29

Seen: 1,417 times

Last updated: Nov 17 '15 at 04:09

powered by OSQA