sprig icon indicating copy to clipboard operation
sprig copied to clipboard

Random Strings functions can't be forced to return a string with a character of each kind

Open juan131 opened this issue 7 years ago • 0 comments

randAlphaNum and randAscii functions can be very helpful to generate random strings. You can choose the length of the string and the kind of characters to use but you can't ensure the string will have all the kind of characters.

There are certain scenarios when you need to ensure that the generated string has at least one character of each kind. E.g. "I want a password that has at least one number and one letter".

I can assume that using a long password both will be generated but they might be not. E.g. "randAlphaNum 10" could generate "AUIjLlmiOk" with no numbers.

What do I expect?

  • randAlphaNum to include both letters and numbers.
  • randAscii to include both letters, numbers and symbols.

It seems that all these functions defined at springs.go are based on randomstringutils.go which do not accept any parameter to modify this behaviour.

juan131 avatar May 08 '18 09:05 juan131