Password hashing interface.
More...
#include <password_hashing.h>
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: