Saturday, February 15, 2014

generate a random password

Challenge: You want to make a random password for a password reset feature in C#. You can make a new Guid and just strip out the hyphens, but you've noticed that you cannot just build a string by returning (several times over) a character based upon a random number. The random numbers in C# are based on the ticks and if you call something that generates a random number ten times in a row back to back you will get the same random number ten times over. Another approach:

  1. Make a Random number using a big range of possible values such as one billion.
  2. Cast the number to a string.
  3. Encrypt the string.

No comments:

Post a Comment