17 BEGIN_NAMESPACE_CRYPTO
25 static const int InfoPartSize = 7;
26 static const int SaltPartSize = 22;
27 static const int HashPartSize = 31;
28 static const int SaltSize = InfoPartSize + SaltPartSize;
29 static const int HashSize = InfoPartSize + SaltPartSize + HashPartSize;
31 std::random_device randomDevice;
32 std::uniform_int_distribution<int> randomDist;
34 std::vector<char> randBytes(
unsigned int length);
47 std::string
hash(
const std::string& password,
unsigned int rounds = 10);
60 std::string
hash(
const std::string& password, std::string salt,
unsigned int rounds = 10)
const;
69 static bool Verify(
const std::string&
hash,
const std::string& password);
std::string hash(const std::string &password, unsigned int rounds=10)
Compute BCrypt hash of a password using random salt.
Wrapper class for BCrypt password hashing algorithm.
Definition: bcrypt.h:22
std::string generateSalt(unsigned int size)
Generate a random salt string of the specified size.
static bool Verify(const std::string &hash, const std::string &password)
Verifies if the password matches a hash.