13,347
社区成员




string password = "123456";
int myIterations = 10000;
// Create a byte array to hold the random value.
//byte[] saltBytes = new byte[8];
//using (RNGCryptoServiceProvider rngCsp = new RNGCryptoServiceProvider())
//{
// // Fill the array with a random value.
// rngCsp.GetBytes(saltBytes);
//}
byte[] saltBytes = Convert.FromBase64String("a3xfJQ4X9ynk0kfYt4SPPA==");
Rfc2898DeriveBytes passwordEncryptedBytes = new Rfc2898DeriveBytes(password, saltBytes, myIterations);
string salt = Convert.ToBase64String(saltBytes);
string passwordEncrypted = Convert.ToBase64String(passwordEncryptedBytes.GetBytes(64));
Console.WriteLine(salt);
Console.WriteLine(passwordEncrypted);
Console.ReadLine();