C# 生成随机密码
class RandomPassword
{
private string randomChars = "BCDFGHJKMPQRTVWXY2346789";
public string GetRandomPassword(int passwordLen)
{
string password = string.Empty;
int randomNum;
Random random = new Random();
for (int i = 0; i < passwordLen; i++)
{
randomNum = random.Next(randomChars.Length);
password += randomChars[randomNum];
}
return password;
}
}
{
private string randomChars = "BCDFGHJKMPQRTVWXY2346789";
public string GetRandomPassword(int passwordLen)
{
string password = string.Empty;
int randomNum;
Random random = new Random();
for (int i = 0; i < passwordLen; i++)
{
randomNum = random.Next(randomChars.Length);
password += randomChars[randomNum];
}
return password;
}
}