#include <nawa/hashing/HashingEngine/impl/Argon2HashingEngine.h>
Inherits nawa::hashing::HashingEngine.
Definition at line 32 of file Argon2HashingEngine.h.
◆ Algorithm
◆ ~Argon2HashingEngine()
virtual nawa::hashing::Argon2HashingEngine::~Argon2HashingEngine |
( |
| ) |
|
|
virtual |
◆ Argon2HashingEngine()
hashing::Argon2HashingEngine::Argon2HashingEngine |
( |
Algorithm |
algorithm = Algorithm::ARGON2ID , |
|
|
uint32_t |
timeCost = 2 , |
|
|
uint32_t |
memoryCost = (1 << 16) , |
|
|
uint32_t |
parallelism = 1 , |
|
|
std::string |
salt = "" , |
|
|
size_t |
hashLen = 32 |
|
) |
| |
|
explicit |
Create a new Argon2 hash generator and set the parameters.
- Parameters
-
algorithm | The Argon2 flavor to use. |
timeCost | Number of iterations. |
memoryCost | Memory usage in kiB. |
parallelism | Number of threads used. |
salt | User-defined salt. Please leave this empty, a good salt will be generated automatically. |
hashLen | Desired hash lenght, 32 by default. |
Definition at line 50 of file Argon2HashingEngine.cpp.
◆ generateHash()
std::string hashing::Argon2HashingEngine::generateHash |
( |
std::string |
input | ) |
const |
|
overridevirtual |
Generate a hash of the input string with the given salt or, if empty, with a random one, and taking into account the properties.
This function might throw an exception with error code 10 (hash invalid), or 11 (argon2 error).
- Parameters
-
input | The input string to hash. |
- Returns
- An Argon2 hash in standard format (starting with $argon2id$, for example, and in base64 format). The hash itself is, by default, 32 bytes (64 hash characters) long.
Implements nawa::hashing::HashingEngine.
Definition at line 56 of file Argon2HashingEngine.cpp.
◆ verifyHash()
bool hashing::Argon2HashingEngine::verifyHash |
( |
std::string |
input, |
|
|
std::string |
hash |
|
) |
| const |
|
overridevirtual |
Verify if the given Argon2 hash, given in encoded format ("$argon2..."), has been generated using the input string. This function will create a new engine object according to the properties of the encoded string internally. It is designed in a way that it should not be vulnerable to timing attacks.
- Parameters
-
input | The input string. |
hash | The hash to verify. |
- Returns
- True if it matches, false otherwise.
Implements nawa::hashing::HashingEngine.
Definition at line 124 of file Argon2HashingEngine.cpp.
The documentation for this class was generated from the following files: