BCrypt implements OpenBSD-style Blowfish password hashing using the scheme described in "A Future- Adaptable Password Scheme" by Niels Provos and David Mazieres.
This password hashing system tries to thwart off-line password cracking using a computationally-intensive hashing algorithm, based on Bruce Schneier's Blowfish cipher. The work factor of the algorithm is parameterised, so it can be increased as computers get faster.
Usage is really simple. To hash a password for the first time, call the
string pw_hash = BCrypt.HashPassword(plain_password);
To check whether a plaintext password matches one that has been hashed previously, use the Verify method:
if (BCrypt.Verify(candidate_password, stored_hash)) Console.WriteLine("It matches"); else Console.WriteLine("It does not match");
The GenerateSalt() method takes an optional parameter (workFactor) that determines the computational complexity of the hashing:
string strong_salt = BCrypt.GenerateSalt(10); string stronger_salt = BCrypt.GenerateSalt(12);
The amount of work increases exponentially (2^workFactor), so each increment is twice as much work. The default workFactor is 10, and the valid range is 4 to 31.