CppSecurity  1.1.1.0
C++ Security Library
password_hashing_bcrypt.h
Go to the documentation of this file.
1 
9 #ifndef CPPSECURITY_PASSWORD_HASHING_BCRYPT_H
10 #define CPPSECURITY_PASSWORD_HASHING_BCRYPT_H
11 
12 #include "password_hashing.h"
13 
14 namespace CppSecurity {
15 
17 
32 {
33 public:
35 
42 
45 
47  size_t workfactor() const noexcept { return _workfactor; }
48 
49  // Implementation of PasswordHashing
50  const std::string& name() const override { return _name; }
51  std::string GenerateSalt() const override;
52  std::string GenerateHash(std::string_view password, std::string_view salt) const override;
53  std::string GenerateDigest(std::string_view password) const override;
54  bool Validate(std::string_view password, std::string_view hash, std::string_view salt) const override;
55  bool ValidateDigest(std::string_view password, std::string_view digest) const override;
56 
57 private:
58  static std::string _name;
59  size_t _workfactor;
60 };
61 
64 } // namespace CppSecurity
65 
66 #endif // CPPSECURITY_PASSWORD_HASHING_BCRYPT_H
'bcrypt' password hashing algorithm
BcryptPasswordHashing & operator=(const BcryptPasswordHashing &)=default
BcryptPasswordHashing(BcryptPasswordHashing &&)=default
bool ValidateDigest(std::string_view password, std::string_view digest) const override
Validate the user password over the given secure digest string.
std::string GenerateDigest(std::string_view password) const override
Generate the secure digest string for the given user password.
std::string GenerateHash(std::string_view password, std::string_view salt) const override
Generate the strong password hash for the given user password and unique salt.
const std::string & name() const override
Get the password hashing algorithm name.
std::string GenerateSalt() const override
Generate the unique password salt.
bool Validate(std::string_view password, std::string_view hash, std::string_view salt) const override
Validate the user password over the given strong password hash and unique salt.
size_t workfactor() const noexcept
Get the work factor.
BcryptPasswordHashing(const BcryptPasswordHashing &)=default
BcryptPasswordHashing(size_t workfactor=4)
Initialize 'bcrypt' password hashing with required parameters.
BcryptPasswordHashing & operator=(BcryptPasswordHashing &&)=default
Password hashing interface.
Password hashing interface definition.