Hash Password in C#? Bcrypt/PBKDF2

前端 未结 9 1026
傲寒
傲寒 2020-12-22 20:06

I looked up msdn and other resources on how to do this but i came up with no clear solutions. This is the best i found http://blogs.msdn.com/b/shawnfa/archive/2004/04/14/gen

9条回答
  •  春和景丽
    2020-12-22 20:40

    PBKDF2

    You were really close actually. The link you have given shows you how you can call the Rfc2898DeriveBytes function to get PBKDF2 hash results. However, you were thrown off by the fact that the example was using the derived key for encryption purposes (the original motivation for PBKDF1 and 2 was to create "key" derivation functions suitable for using as encryption keys). Of course, we don't want to use the output for encryption but as a hash on its own.

    You can try the SimpleCrypto.Net library written for exactly this purpose if you want PBKDF2. If you look at the implementation, you can see that it is actually just a thin wrapper around (you guessed it) Rfc2898DeriveBytes.

    BCrypt

    You can try the C# implementation named (what else) BCrypt.NET if you want to experiment with this variant.

    Disclaimer: I have not used or tested any of the libraries that I have linked to... YMMV

提交回复
热议问题