Secure Password Hashing

前端 未结 9 1377
鱼传尺愫
鱼传尺愫 2020-11-30 08:15

I need to store a hash of a single password in a .Net WinForms application.

What\'s the most secure way to do this?

In particular:

  • Salt, HMAC,
9条回答
  •  一向
    一向 (楼主)
    2020-11-30 08:21

    I can recommend BCrypt.net. Very easy to use and you can tune how long it will take to do the hashing, which is awesome!

    // Pass a logRounds parameter to GenerateSalt to explicitly specify the
    // amount of resources required to check the password. The work factor
    // increases exponentially, so each increment is twice as much work. If
    // omitted, a default of 10 is used.
    string hashed = BCrypt.HashPassword(password, BCrypt.GenerateSalt(12));
    
    // Check the password.
    bool matches = BCrypt.CheckPassword(candidate, hashed);
    

提交回复
热议问题