Asp.net Identity使用什么算法来加密密码?

Ram*_*war 8 encryption algorithm asp.net-mvc asp.net-identity-2

Asp.Net Identity框架使用什么样的算法来加密密码?我有一个Android,iPhone,Web和桌面使用相同数据库的场景.此密码应加密,因此ASP.NET MVC我使用Identity框架加密密码.现在我需要算法适用于所有平台.

任何帮助将不胜感激.

提前致谢.

Row*_*man 16

ASP.NET Identity使用基于密码的密钥派生函数2(PBKDF2)实现Rfc2898DeriveBytes.它是一种散列算法.

请注意,加密和散列是不同的.

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);
}
Run Code Online (Sandbox Code Playgroud)

  • 此外,SHA1**是一种哈希算法,**不是加密技术. (7认同)