Comment Re:Passwords and so (Score 1) 32
This code doesn't guarentee a certain complexity. In fact, since the alphabet comprises 52 of the 66 characters (assuming 4 symbols), there is a high chance of long strings of letters, therefore resulting in an overall loss of complexity.
Yes, you are correct. But it's just a sample with a basic random string generation idea.
Can be improved...
- One could add more numbers (repeating those) so that statisticly the chance of getting a letter or a number is the same;
- One could check it in the end; If it only contains letters (or high percentage of letters), the function would loop putting some random numbers in between the letters (random positions); Same for strings with only numbers.
- One could simply chose 3 random numbers after the string is generated by the initial loop and insert them in random positions of the generated string.