English 中文(简体)
Is SHA512Managed considered the best one-way hash available in .NET 3.5 for security?
原标题:

Three SHA512Managed related questions:

  1. Is SHA512Managed considered the best one-way hash available in .NET 3.5 for security?
  2. What Salt size should be used with SHA512Managed? The application is for strong passwords with at least 8 characters.
  3. Is 512 overkill compared to 256 for small strings?
最佳回答
  1. Sha512Managed does not depend on system calls, and has the largest hash size of the built-in hashes. If you re not optimizing for anything else, it would be considered the most secure.

  2. For password cracking purposes, a salt essentially increases the size of the password. Though bigger is better, anything beyond the number of bits of the password itself is largely wasted. So, for a min 8 ASCII character password, you might go for a 64 bit salt.

  3. Yes and no. It s overkill for modern technology; the size of the strings are irrelevant. If you need your passwords to be secure for the next 100 years, well, go for 512.

A reference: http://www.codeproject.com/KB/security/Cryptography_NET.aspx

问题回答

Ben s answer is incorrect, you should not be using SHA* functions to hash passwords. You should be using a hash function that is specifically designed for hashing passwords, such as PBKDF2, BCrypt or SCrypt. Min s answer and comments are correct.

Since you want to use standard .NET library I suggest Rfc2898DeriveBytes which is an implementation of PBKDF2.

http://msdn.microsoft.com/en-us/library/system.security.cryptography.rfc2898derivebytes.aspx

If you re looking for preventing brute force attacks take a loot at bcrypt or scrypt. They re designed to be algorithmically slow. So even if an attacker did get a hold of the password database, calculating everything would take forever.

http://derekslager.com/blog/posts/2007/10/bcrypt-dotnet-strong-password-hashing-for-dotnet-and-mono.ashx

http://www.tarsnap.com/scrypt.html





相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签