CppSecurity  1.1.1.0
C++ Security Library
password_hashing_bcrypt.cpp

'bcrypt' password hashing example

#include <iostream>
int main(int argc, char** argv)
{
// Show the password
std::password password = (argc > 1) ? argv[1] : "passw0rd";
std::cout << "Password: " << password << std::endl;
// Generate the digest
std::string digest = bcrypt.GenerateEncodedDigest(password);
std::cout << "Generated digest: " << digest << std::endl;
// Validate the digest
std::cout << "Validate digest: " << (bcrypt.ValidateEncodedDigest(password, digest) ? "valid" : "invalid") << std::endl;
return 0;
}
'bcrypt' password hashing algorithm
virtual std::string GenerateEncodedDigest(std::string_view password) const
Generate the secure Base64 digest string for the given user password.
virtual bool ValidateEncodedDigest(std::string_view password, std::string_view digest) const
Validate the user password over the given secure Base64 digest string.
Password string.
Definition: password.h:53
'bcrypt' password hashing algorithm definition