Class BCrypt
- Namespace
- PolarStudioGlobals
- Assembly
- PolarStudioGlobals.dll
This class is a helper for the BCrypt algoritm to securely store password hashes. This algorithm is using a big number of hashing actions, making it compute-intensive. This makes it harder to brute-force a password-hash.
public class BCrypt
- Inheritance
-
BCrypt
- Inherited Members
- Extension Methods
Methods
CheckPassword(string, string)
Check that a plaintext password matches a previously hashed one.
public static bool CheckPassword(string plaintext, string hashed)
Parameters
Returns
- bool
true
if the passwords,false
otherwise.
DefaultLog2Rounds()
Returns the default number of hashes. Is logarithmic, so a value of 13 means 8192 hashes. 14 would cause 16384 hashes. etc.
public int DefaultLog2Rounds()
Returns
GenerateSalt(int)
Generate a salt for use with the BCrypt.HashPassword() method.
public static string GenerateSalt(int logRounds = 13)
Parameters
logRounds
intThe log2 of the number of rounds of hashing to apply. The work factor therefore increases as (2 ** logRounds).
Returns
- string
An encoded salt value.
HashPassword(string, int)
Hash a password using the OpenBSD bcrypt scheme.
public static string HashPassword(string password, int pLogRounds)
Parameters
password
stringThe password to hash.
pLogRounds
intThe number of LogRounds to use. Is logarithmic. Higher numbers cause longer compute times.
Returns
- string
The hashed password.
HashPassword(string, string)
Hash a password using the OpenBSD bcrypt scheme.
public static string HashPassword(string password, string salt = "")
Parameters
password
stringThe password to hash.
salt
stringThe salt to hash with (perhaps generated using
BCrypt.GenerateSalt
).
Returns
- string
The hashed password.