NAWA 0.9
Web Application Framework for C++
nawa::hashing::HashingEngine Class Referenceabstract

#include <nawa/hashing/HashingEngine/HashingEngine.h>

Inherited by nawa::hashing::Argon2HashingEngine, and nawa::hashing::BcryptHashingEngine.

Public Member Functions

virtual std::string generateHash (std::string input) const =0
 
virtual bool verifyHash (std::string input, std::string hash) const =0
 

Detailed Description

A hashing engine must implement these functions in order to be useful for password hashing. It may store additional information (such as cost and salt) in its object, the user should be able to set them as constructor parameters. It is expected that the salt is automatically generated, giving the user an option to manually specify the salt is optional but recommended.

Definition at line 37 of file HashingEngine.h.

Member Function Documentation

◆ generateHash()

virtual std::string nawa::hashing::HashingEngine::generateHash ( std::string  input) const
pure virtual

Generate a (salted) hash basing on the input (usually the password to be hashed). Throw a nawa::Exception with an error code >=10 in case of failure.

Parameters
inputThe input string (e.g., user password).
Returns
The hash in a standard format, including the salt and all information necessary to check it (e.g., "$2a$10$...").

Implemented in nawa::hashing::Argon2HashingEngine, and nawa::hashing::BcryptHashingEngine.

◆ verifyHash()

virtual bool nawa::hashing::HashingEngine::verifyHash ( std::string  input,
std::string  hash 
) const
pure virtual

Check whether the input string has been used to produce the hash. This function should not need to throw exceptions.

Parameters
inputThe input string (e.g., password the user entered).
hashThe stored hash containing all necessary information.
Returns
True if the input string matches the hash, false otherwise.

Implemented in nawa::hashing::Argon2HashingEngine, and nawa::hashing::BcryptHashingEngine.


The documentation for this class was generated from the following file: