BCrypt.NetBCrypt
Namespace: BCrypt.Net
Assembly: AerospikeClient (in AerospikeClient.dll) Version: 3.9.16.1 (3.9.16.1)
public sealed class BCrypt
The BCrypt type exposes the following members.
Name | Description | |
---|---|---|
![]() | BCrypt | Initializes a new instance of the BCrypt class |
Name | Description | |
---|---|---|
![]() ![]() | GenerateSalt |
Generate a salt for use with the HashPassword(String, String) method
selecting a reasonable default for the number of hashing rounds to apply.
|
![]() ![]() | GenerateSalt(Int32) |
Generate a salt for use with the HashPassword(String, String) method.
|
![]() ![]() | HashPassword(String) |
Hash a password using the OpenBSD bcrypt scheme and a salt generated by GenerateSalt.
|
![]() ![]() | HashPassword(String, Int32) |
Hash a password using the OpenBSD bcrypt scheme and a salt generated by GenerateSalt(Int32) using the given workFactor.
|
![]() ![]() | HashPassword(String, String) | Hash a password using the OpenBSD bcrypt scheme. |
![]() ![]() | HashString(String) |
Hash a string using the OpenBSD bcrypt scheme and a salt generated by GenerateSalt.
|
![]() ![]() | HashString(String, Int32) |
Hash a string using the OpenBSD bcrypt scheme and a salt generated by GenerateSalt.
|
![]() ![]() | Verify |
Verifies that the hash of the given text matches the provided
hash |
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 HashPassword(String) method with a random salt, like this:
string pw_hash = BCrypt.HashPassword(plain_password);
To check whether a plaintext password matches one that has been hashed previously, use the Verify(String, String) 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.