什么是ASP.NET成员资格使用默认的哈希算法? [英] What is default hash algorithm that ASP.NET membership uses?

查看:117
本文介绍了什么是ASP.NET成员资格使用默认的哈希算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是ASP.NET成员资格使用默认的哈希算法?我能怎样改变?

What is default hash algorithm that ASP.NET membership uses? And how can I change it?

推荐答案

在的,因为事实上,谷歌搜索成员提供散列算法变成了这个答案的第一个结果,那将可以推断福音,它理应我警告有关使用成员资格提供这样使用哈希像SHA-1,MD5等混淆在数据库中的密码乡亲。

Do not use the Membership Provider as-is because it is horridly inadequate in terms of protecting user's passwords

In light of the fact that googling "membership provider hashing algorithm" turns up this answer as the first result, and the gospel that will be inferred, it behoves me to warn folks about using the Membership Provider like this and using hashes like SHA-1, MD5 etc to obfuscate passwords in databases.

使用像bcrypt,scrypt或密钥导出函数(如果你需要符合FIPS )PBKDF2 有一张因素足以必要的哈希时间一个密码,以尽可能接近1000MS以上。

Use a key-derivation function like bcrypt, scrypt or (if you need FIPS compliance) PBKDF2 with a work factor sufficient to necessitate the hashing time for a single password to be as close to 1000ms or more.

哈希是很容易蛮力这些天,数据泄露的例子充裕在最近的历史。以prevent在接下来的黑客对引擎收录结束了你的用户的密码,确保密码与需要的足够长的时间来计算!

Hashes are easy to brute force these days with ample examples of data breaches in recent history. To prevent your user's passwords from ending up on pastebin in the next hack, ensure that passwords are hashed with a function that takes a sufficiently long time to compute!

相反成员资格提供程序,尽量 IdentityReboot 或的新的微软实现,在关于特洛伊亨特会谈最少的。

Instead of Membership Provider, try IdentityReboot or the newer implementations from Microsoft that Troy Hunt talks about at the least.

这也是有趣的是,上面我所提到的相同的谷歌搜索结果找到的教程显示乡亲preciously多么容易蛮力使用流行的工具,如JTR或Hashcat这些密码哈希值。在定制GPU钻机,SHA1可以在href=\"https://gist.github.com/epixoip/63c2ad11baf7bbd57544\" rel=\"nofollow\">的48867惊人的速度每秒<百万哈希/ EM>!有了自由字典如 RockYou的或类似,一个积极的人,与你的数据库将很快拥有大多数用户的密码。作为开发人员,这是你的道德责任,采取必要措施,以保护用户密码的安全性。

It's also interesting that on the same google results mentioned above I find a tutorial showing folks preciously how easy it is to brute force these password hashes using popular tools like JtR or Hashcat. On a custom GPU rig, SHA1 can be cracked at a staggering rate of 48867 million hashes per second! With a free dictionary like rockyou or the like, a motivated person with your database will very quickly have most of your users passwords. As a developer, it's your ethical responsibility to do what is necessary to protect the security of your users' passwords.

默认散列是SHA1,但他们也食盐它,它的base64:

The default hashing is SHA1 but they also salt it and base64 it:

public string EncodePassword(string pass, string salt)
{
    byte[] bytes = Encoding.Unicode.GetBytes(pass);
    byte[] src = Encoding.Unicode.GetBytes(salt);
    byte[] dst = new byte[src.Length + bytes.Length];
    Buffer.BlockCopy(src, 0, dst, 0, src.Length);
    Buffer.BlockCopy(bytes, 0, dst, src.Length, bytes.Length);
    HashAlgorithm algorithm = HashAlgorithm.Create("SHA1");
    byte[] inArray = algorithm.ComputeHash(dst);
    return Convert.ToBase64String(inArray);
}

如果您想了解更多关于如何去改变它我还需要找到(除非使用自定义提供商见下文),但是SHA-1是pretty好现在。如果您正在寻找从此这些家伙扭转或查找做了一些工作: HTTP: //forums.asp.net/p/1336657/2899172.aspx

If you want to know more about how to change it I still need to find out (unless using custom provider see below) however SHA-1 is pretty good for now. If you are looking to reverse it or lookup from this these guys did some work on that: http://forums.asp.net/p/1336657/2899172.aspx

这太问题将有助于扭转或复制这个技术,如果这是可能需要的东西。 <一href=\"http://stackoverflow.com/questions/530426/reimplement-asp-net-membership-and-user-password-hashing-in-ruby\">Reimplement ASP.NET成员资格和用户密码哈希在Ruby中

This SO question will help in reversing or duplicating this technique if that is what might be needed. Reimplement ASP.NET Membership and User Password Hashing in Ruby

如果您正在自定义提供您可以创建散列算法和加密算法和方法。

If you are making a custom provider you can create your hashing and encryption algorithms and methods.

private byte[] ConvertPasswordForStorage(string Password)
      {
         System.Text.UnicodeEncoding ue = 
      new System.Text.UnicodeEncoding();
         byte[] uePassword = ue.GetBytes(Password);
         byte[] RetVal = null;
         switch (_PasswordFormat)
         {
            case MembershipPasswordFormat.Clear:
               RetVal = uePassword;
               break;
            case MembershipPasswordFormat.Hashed:

               HMACSHA1 SHA1KeyedHasher = new HMACSHA1();
               SHA1KeyedHasher.Key = _ValidationKey;
               RetVal = SHA1KeyedHasher.ComputeHash(uePassword);
               break;
            case MembershipPasswordFormat.Encrypted:
               TripleDESCryptoServiceProvider tripleDes = new 
       TripleDESCryptoServiceProvider();
               tripleDes.Key = _DecryptionKey;
               tripleDes.IV = new byte[8];
               MemoryStream mStreamEnc = new MemoryStream();
               CryptoStream cryptoStream = new CryptoStream(mStreamEnc, 
        tripleDes.CreateEncryptor(), 
      CryptoStreamMode.Write);

               cryptoStream.Write(uePassword, 0, uePassword.Length);
               cryptoStream.FlushFinalBlock();
               RetVal = mStreamEnc.ToArray();
               cryptoStream.Close();
               break;

         }
         return RetVal;
      }

private string GetHumanReadablePassword(byte[] StoredPassword)
      {
         System.Text.UnicodeEncoding ue = new System.Text.UnicodeEncoding();
         string RetVal = null;
         switch (_PasswordFormat)
         {
            case MembershipPasswordFormat.Clear:
               RetVal = ue.GetString(StoredPassword);
               break;
            case MembershipPasswordFormat.Hashed:
               throw new ApplicationException(
        "Password cannot be recovered from a hashed format");

            case MembershipPasswordFormat.Encrypted:
               TripleDESCryptoServiceProvider tripleDes = 
        new TripleDESCryptoServiceProvider();
               tripleDes.Key = _DecryptionKey;
               tripleDes.IV = new byte[8];
               CryptoStream cryptoStream = 
        new CryptoStream(new MemoryStream(StoredPassword), 
      tripleDes.CreateDecryptor(), CryptoStreamMode.Read);
               MemoryStream msPasswordDec = new MemoryStream();
               int BytesRead = 0;
               byte[] Buffer = new byte[32];
               while ((BytesRead = cryptoStream.Read(Buffer, 0, 32)) > 0)
               {
                  msPasswordDec.Write(Buffer, 0, BytesRead);

               }
               cryptoStream.Close();

               RetVal = ue.GetString(msPasswordDec.ToArray());
               msPasswordDec.Close();
               break;
         }
         return RetVal;
      }

http://msdn.microsoft.com/en-us/library/ aa479048.aspx

这篇关于什么是ASP.NET成员资格使用默认的哈希算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆