Asp.Net Identity框架使用哪种算法来加密密码?我有一个场景,安卓,iPhone,网络和桌面使用相同的数据库。这个密码应该是加密的,所以在ASP.NET MVC中,我使用了身份框架来加密密码。现在我需要让算法在所有平台上都能工作。
任何帮助都将不胜感激。
提前谢谢。
发布于 2014-07-15 13:45:41
ASP.NET Identity使用由Rfc2898DeriveBytes实现的Password-Based Key Derivation Function 2 (PBKDF2)。它是一种散列算法。
请注意encryption and hashing are different。
public static string HashPassword(string password)
{
byte[] salt;
byte[] bytes;
if (password == null)
{
throw new ArgumentNullException("password");
}
using (Rfc2898DeriveBytes rfc2898DeriveByte = new Rfc2898DeriveBytes(password, 16, 1000))
{
salt = rfc2898DeriveByte.Salt;
bytes = rfc2898DeriveByte.GetBytes(32);
}
byte[] numArray = new byte[49];
Buffer.BlockCopy(salt, 0, numArray, 1, 16);
Buffer.BlockCopy(bytes, 0, numArray, 17, 32);
return Convert.ToBase64String(numArray);
}发布于 2021-05-11 18:31:46
这取决于所选的兼容模式。
实施详情可在其Github repo中找到
此时此刻,他们支持:
版本2
带HMAC-SHA1的
版本3
带HMAC-SHA256的
https://stackoverflow.com/questions/24750266
复制相似问题