How to generate random number in c#
For used to Send Random number as Password in Website ,and get random id for new registration
or used for captcha in website easy code
find the below text
For used to Send Random number as Password in Website ,and get random id for new registration
or used for captcha in website easy code
find the below text
public string genpwd()
{
string
password;
int
minPassSize = 6;
int
maxPassSize = 12;
StringBuilder
stringBuilder = new StringBuilder();
char[]
charArray = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()".ToCharArray();
int
newPassLength = new Random().Next(minPassSize,
maxPassSize);
char
character;
Random
rnd = new Random(DateTime.Now.Millisecond);
for (int i = 0; i < newPassLength; i++)
{
character = charArray[rnd.Next(0,
(charArray.Length - 1))];
stringBuilder.Append(character);
}
password = stringBuilder.ToString();
return
password;
}
Comments
Post a Comment
Thank you for your Comment