Monday, January 5, 2009

Genrate Random Password


This fucntion is used for Genrate Password.

pass length of password for example GenrateRandomPassword(8);

for better result we can add timeTick for select integer or we can call to time this fuction recurlsivle
and then get substring portion for final password.

in my earlier post i also upload a dataBAse storeprocedure for caseSenstive password.

public static string GenrateRandomPassword(int PasswordLength)
string listOfCharacter = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789#$&@-";
Random randNum = new Random();
char[] chars = new char[PasswordLength];
int allCharacterCount = listOfCharacter.Length;

for (int i = 0; i < PasswordLength; i++)
chars[i] = listOfCharacter[(int)((listOfCharacter.Length) * randNum.NextDouble())];

return new string(chars);


No comments: