我想证明一个GUID在一个简单的测试程序中并不是唯一的.我希望以下代码运行几个小时,但它不起作用.我怎样才能使它工作?
BigInteger begin = new BigInteger((long)0);
BigInteger end = new BigInteger("340282366920938463463374607431768211456",10); //2^128
for(begin; begin<end; begin++)
Console.WriteLine(System.Guid.NewGuid().ToString());
Run Code Online (Sandbox Code Playgroud)
我正在使用C#.
我刚刚浏览了DavidHayden关于哈希用户密码的文章之一.
真的,我无法得到他想要实现的目标.
这是他的代码:
private static string CreateSalt(int size)
{
//Generate a cryptographic random number.
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
byte[] buff = new byte[size];
rng.GetBytes(buff);
// Return a Base64 string representation of the random number.
return Convert.ToBase64String(buff);
}
private static string CreatePasswordHash(string pwd, string salt)
{
string saltAndPwd = String.Concat(pwd, salt);
string hashedPwd =
FormsAuthentication.HashPasswordForStoringInConfigFile(
saltAndPwd, "sha1");
return hashedPwd;
}
Run Code Online (Sandbox Code Playgroud)
有没有其他C#方法来散列密码并添加盐?