Password hashing interface.
More...
#include <password_hashing.h>
|
| PasswordHashing (size_t hash_length=32, size_t salt_length=32) |
| Initialize password hashing with required parameters.
|
|
| PasswordHashing (const PasswordHashing &)=default |
|
| PasswordHashing (PasswordHashing &&)=default |
|
virtual | ~PasswordHashing ()=default |
|
PasswordHashing & | operator= (const PasswordHashing &)=default |
|
PasswordHashing & | operator= (PasswordHashing &&)=default |
|
size_t | hash_length () const noexcept |
| Get the strong password hash length.
|
|
size_t | salt_length () const noexcept |
| Get the unique password salt length.
|
|
virtual const std::string & | name () const =0 |
| Get the password hashing algorithm name.
|
|
virtual std::string | GenerateSalt () const |
| Generate the unique password salt.
|
|
virtual std::pair< std::string, std::string > | GenerateHashAndSalt (std::string_view password) const |
| Generate the strong password hash and unique salt for the given user password.
|
|
virtual std::string | GenerateHash (std::string_view password, std::string_view salt) const =0 |
| Generate the strong password hash for the given user password and unique salt.
|
|
virtual std::string | GenerateDigest (std::string_view password) const |
| Generate the secure digest string for the given user password.
|
|
virtual std::string | GenerateEncodedDigest (std::string_view password) const |
| Generate the secure Base64 digest string for the given user password.
|
|
virtual bool | Validate (std::string_view password, std::string_view hash, std::string_view salt) const =0 |
| Validate the user password over the given strong password hash and unique salt.
|
|
virtual bool | ValidateDigest (std::string_view password, std::string_view digest) const |
| Validate the user password over the given secure digest string.
|
|
virtual bool | ValidateEncodedDigest (std::string_view password, std::string_view digest) const |
| Validate the user password over the given secure Base64 digest string.
|
|
Password hashing interface.
Password hashing interface allows to generate strong password hash and salt to protect plain passwords from database access attack and validate the given password over the generated hash and salt.
https://en.wikipedia.org/wiki/Key_derivation_function
Thread-safe.
Definition at line 26 of file password_hashing.h.
◆ PasswordHashing() [1/3]
CppSecurity::PasswordHashing::PasswordHashing |
( |
size_t |
hash_length = 32 , |
|
|
size_t |
salt_length = 32 |
|
) |
| |
Initialize password hashing with required parameters.
- Parameters
-
hash_length | - Strong password hash length (default is 32) |
salt_length | - Unique password salt length (default is 32) |
Definition at line 19 of file password_hashing.cpp.
◆ PasswordHashing() [2/3]
◆ PasswordHashing() [3/3]
◆ ~PasswordHashing()
virtual CppSecurity::PasswordHashing::~PasswordHashing |
( |
| ) |
|
|
virtualdefault |
◆ GenerateDigest()
std::string CppSecurity::PasswordHashing::GenerateDigest |
( |
std::string_view |
password | ) |
const |
|
virtual |
◆ GenerateEncodedDigest()
std::string CppSecurity::PasswordHashing::GenerateEncodedDigest |
( |
std::string_view |
password | ) |
const |
|
virtual |
◆ GenerateHash()
virtual std::string CppSecurity::PasswordHashing::GenerateHash |
( |
std::string_view |
password, |
|
|
std::string_view |
salt |
|
) |
| const |
|
pure virtual |
◆ GenerateHashAndSalt()
std::pair< std::string, std::string > CppSecurity::PasswordHashing::GenerateHashAndSalt |
( |
std::string_view |
password | ) |
const |
|
virtual |
Generate the strong password hash and unique salt for the given user password.
- Parameters
-
- Returns
- Strong password hash and unique salt
Definition at line 38 of file password_hashing.cpp.
◆ GenerateSalt()
std::string CppSecurity::PasswordHashing::GenerateSalt |
( |
| ) |
const |
|
virtual |
◆ hash_length()
size_t CppSecurity::PasswordHashing::hash_length |
( |
| ) |
const |
|
inlinenoexcept |
◆ name()
virtual const std::string & CppSecurity::PasswordHashing::name |
( |
| ) |
const |
|
pure virtual |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ salt_length()
size_t CppSecurity::PasswordHashing::salt_length |
( |
| ) |
const |
|
inlinenoexcept |
◆ Validate()
virtual bool CppSecurity::PasswordHashing::Validate |
( |
std::string_view |
password, |
|
|
std::string_view |
hash, |
|
|
std::string_view |
salt |
|
) |
| const |
|
pure virtual |
◆ ValidateDigest()
bool CppSecurity::PasswordHashing::ValidateDigest |
( |
std::string_view |
password, |
|
|
std::string_view |
digest |
|
) |
| const |
|
virtual |
Validate the user password over the given secure digest string.
- Parameters
-
password | - User password |
digest | - Secure digest string |
- Returns
- 'true' if the given user password is valid, 'false' if the given user password is invalid
Reimplemented in CppSecurity::BcryptPasswordHashing.
Definition at line 57 of file password_hashing.cpp.
◆ ValidateEncodedDigest()
bool CppSecurity::PasswordHashing::ValidateEncodedDigest |
( |
std::string_view |
password, |
|
|
std::string_view |
digest |
|
) |
| const |
|
virtual |
The documentation for this class was generated from the following files: