The Programmator

Generate a password with a set of allowed characters

Today, I came across a situation where I had to generate a password using only a limited set of allowed characters. Since I didn’t really want to reinvent the wheel, I resorted to the System.Web.Security.Membership class which exposes a GeneratePassword method. Unfortunately, you can’t give it a list of characters to select from.

Venturing into the internets, I ran into this neat script that allows you to pass in a level of complexity. I haven’t investigated the method’s performance thoroughly. It does the job just nicely!

Happy coding!

Like what you read? Maybe your friends do too! Share this article:

Leave a Reply

Tags: , , ,