C# 生成随机密码(随机字符串)的代码
2021-06-09 05:04
标签:int seed ring ret string 随机 dom 应该 代码 C# 生成随机密码(随机字符串)的代码 标签:int seed ring ret string 随机 dom 应该 代码 原文地址:https://blog.51cto.com/14149868/2375192 private static int getNewSeed()
{
byte[] rndBytes = new byte[4];
System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider();
rng.GetBytes(rndBytes);
return BitConverter.ToInt32(rndBytes, 0);
static public string GetRandomString(int len)
{
string s = "123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ";
string reValue = string.Empty;
Random rnd = new Random(getNewSeed());
while (reValue.Length