CppSecurity 1.1.2.0
C++ Security Library
Loading...
Searching...
No Matches
password_hashing_scrypt.h
Go to the documentation of this file.
1
9#ifndef CPPSECURITY_PASSWORD_HASHING_SCRYPT_H
10#define CPPSECURITY_PASSWORD_HASHING_SCRYPT_H
11
12#include "password_hashing.h"
13
14namespace CppSecurity {
15
17
27{
28public:
30
37 ScryptPasswordHashing(size_t hash_length = 32, size_t salt_length = 32, uint64_t n = 512, uint32_t r = 8, uint32_t p = 1);
41
44
46 uint64_t n() const noexcept { return _n; }
48 uint32_t r() const noexcept { return _r; }
50 uint32_t p() const noexcept { return _p; }
51
52 // Implementation of PasswordHashing
53 const std::string& name() const override { return _name; }
54 std::string GenerateHash(std::string_view password, std::string_view salt) const override;
55 bool Validate(std::string_view password, std::string_view hash, std::string_view salt) const override;
56
57private:
58 static std::string _name;
59 uint64_t _n;
60 uint32_t _r;
61 uint32_t _p;
62};
63
66} // namespace CppSecurity
67
68#endif // CPPSECURITY_PASSWORD_HASHING_SCRYPT_H
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.
'scrypt' password hashing algorithm
uint32_t r() const noexcept
Get the RAM Cost.
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.
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.
ScryptPasswordHashing(const ScryptPasswordHashing &)=default
ScryptPasswordHashing & operator=(const ScryptPasswordHashing &)=default
ScryptPasswordHashing(ScryptPasswordHashing &&)=default
ScryptPasswordHashing & operator=(ScryptPasswordHashing &&)=default
uint32_t p() const noexcept
Get the degree of parallelism.
uint64_t n() const noexcept
Get the CPU AND RAM cost.
const std::string & name() const override
Get the password hashing algorithm name.
Password hashing interface definition.