CppSecurity 1.1.2.0
C++ Security Library
Loading...
Searching...
No Matches
password_hashing_argon2.h
Go to the documentation of this file.
1
9#ifndef CPPSECURITY_PASSWORD_HASHING_ARGON2_H
10#define CPPSECURITY_PASSWORD_HASHING_ARGON2_H
11
12#include "password_hashing.h"
13
14namespace CppSecurity {
15
17
31{
32public:
34
41 Argon2dPasswordHashing(size_t hash_length = 32, size_t salt_length = 32, uint32_t t = 3, uint32_t m = 512, uint32_t p = 1);
45
48
50 uint32_t t() const noexcept { return _t; }
52 uint32_t m() const noexcept { return _m; }
54 uint32_t p() const noexcept { return _p; }
55
56 // Implementation of PasswordHashing
57 const std::string& name() const override { return _name; }
58 std::string GenerateHash(std::string_view password, std::string_view salt) const override;
59 bool Validate(std::string_view password, std::string_view hash, std::string_view salt) const override;
60
61private:
62 static std::string _name;
63 uint32_t _t;
64 uint32_t _m;
65 uint32_t _p;
66};
67
69
83{
84public:
86
87 // Implementation of PasswordHashing
88 const std::string& name() const override { return _name; }
89 std::string GenerateHash(std::string_view password, std::string_view salt) const override;
90 bool Validate(std::string_view password, std::string_view hash, std::string_view salt) const override;
91
92private:
93 static std::string _name;
94};
95
97
112{
113public:
115
116 // Implementation of PasswordHashing
117 const std::string& name() const override { return _name; }
118 std::string GenerateHash(std::string_view password, std::string_view salt) const override;
119 bool Validate(std::string_view password, std::string_view hash, std::string_view salt) const override;
120
121private:
122 static std::string _name;
123};
124
127} // namespace CppSecurity
128
129#endif // CPPSECURITY_PASSWORD_HASHING_ARGON2_H
'Argon2d' password hashing algorithm
Argon2dPasswordHashing & operator=(Argon2dPasswordHashing &&)=default
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.
Argon2dPasswordHashing(const Argon2dPasswordHashing &)=default
Argon2dPasswordHashing(size_t hash_length=32, size_t salt_length=32, uint32_t t=3, uint32_t m=512, uint32_t p=1)
Initialize 'Argon2' password hashing with required parameters.
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.
uint32_t p() const noexcept
Get the degree of parallelism.
const std::string & name() const override
Get the password hashing algorithm name.
uint32_t t() const noexcept
Get the number of iterations.
uint32_t m() const noexcept
Get the memory usage in kibibytes.
Argon2dPasswordHashing & operator=(const Argon2dPasswordHashing &)=default
Argon2dPasswordHashing(Argon2dPasswordHashing &&)=default
'Argon2i' password hashing algorithm
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.
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.
'Argon2id' password hashing algorithm
const std::string & name() const override
Get the password hashing algorithm name.
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.
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.
Password hashing interface.
size_t salt_length() const noexcept
Get the unique password salt length.
size_t hash_length() const noexcept
Get the strong password hash length.
Password hashing interface definition.