9 #ifndef CPPSECURITY_PASSWORD_HASHING_H
10 #define CPPSECURITY_PASSWORD_HASHING_H
48 virtual const std::string&
name()
const = 0;
61 virtual std::pair<std::string, std::string>
GenerateHashAndSalt(std::string_view password)
const;
69 virtual std::string
GenerateHash(std::string_view password, std::string_view salt)
const = 0;
76 virtual std::string
GenerateDigest(std::string_view password)
const;
92 virtual bool Validate(std::string_view password, std::string_view hash, std::string_view salt)
const = 0;
100 virtual bool ValidateDigest(std::string_view password, std::string_view digest)
const;
Password hashing interface.
size_t salt_length() const noexcept
Get the unique password salt length.
virtual std::string GenerateEncodedDigest(std::string_view password) const
Generate the secure Base64 digest string for the given user password.
PasswordHashing(PasswordHashing &&)=default
PasswordHashing & operator=(PasswordHashing &&)=default
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 std::string GenerateSalt() const
Generate the unique password salt.
virtual bool ValidateEncodedDigest(std::string_view password, std::string_view digest) const
Validate the user password over the given secure Base64 digest string.
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 const std::string & name() const =0
Get the password hashing algorithm name.
PasswordHashing(size_t hash_length=32, size_t salt_length=32)
Initialize password hashing with required parameters.
size_t hash_length() const noexcept
Get the strong password hash length.
virtual std::string GenerateDigest(std::string_view password) const
Generate the secure digest string for the given user password.
virtual ~PasswordHashing()=default
PasswordHashing(const PasswordHashing &)=default
virtual bool ValidateDigest(std::string_view password, std::string_view digest) const
Validate the user password over the given secure digest string.
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.
PasswordHashing & operator=(const PasswordHashing &)=default
Password string definition.