تابع تولید پسورد تصادفی در سی شارپ c#.net
سلام بر تمامی برنامه نویسان C#.NET !!! در این مطلب کد تولید پسورد تصادفی در سی شارپ رو براتون قرار دادم.امیدوارم که این کد به دردتون بخوره.
public static string RandomPassword()
{
string _allowedChars = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Random randNum = new Random();
char[] chars = new char[6];
int allowedCharCount = _allowedChars.Length;
for (int i = 0; i < 6; i++)
{
chars[i] = _allowedChars[(int)((_allowedChars.Length) * randNum.NextDouble())];
}
return new string(chars);
}
{
string _allowedChars = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Random randNum = new Random();
char[] chars = new char[6];
int allowedCharCount = _allowedChars.Length;
for (int i = 0; i < 6; i++)
{
chars[i] = _allowedChars[(int)((_allowedChars.Length) * randNum.NextDouble())];
}
return new string(chars);
}
برای اطلاعات بیش تر درباره ی کد Random این لینک و این لینک و این لینک را مشاهده کنید.
[/membership]