嗯,他怎么知道种子的?除非他知道
确切时间
你运行了代码,就是
非常
很难做到。但是如果你需要更强的,你也可以通过
System.Security.Cryptography.RandomNumberGenerator.Create
-比如:
var rng = System.Security.Cryptography.RandomNumberGenerator.Create();
byte[] buffer = new byte[4];
char[] chars = new char[CharactersCount];
for(int i = 0 ; i < chars.Length ; i++)
{
rng.GetBytes(buffer);
int nxt = BitConverter.ToInt32(buffer, 0);
int index = nxt % Alphabet.Length;
if(index < 0) index += Alphabet.Length;
chars[i] = Alphabet[index];
}
string s = new string(chars);