CppSecurity  1.1.1.0
C++ Security Library
password_generator.cpp

Password generator example

#include <iostream>
int main(int argc, char** argv)
{
// Generate passwords
std::cout << "Generate '" << genertor.flags() << "' password: " << genertor.Generate() << std::endl;
std::cout << "Generate '" << genertor.flags() << "' password: " << genertor.Generate() << std::endl;
std::cout << "Generate '" << genertor.flags() << "' password: " << genertor.Generate() << std::endl;
// Validate passwords
std::cout << "Validate 'SomeCoolPaSsw0rd' password: " << (genertor.Validate("SomeCoolPaSsw0rd") ? "valid" : "invalid") << std::endl;
std::cout << "Validate 'NotCoolPaSsw[0]rd' password: " << (genertor.Validate("NotCoolPaSsw[0]rd") ? "valid" : "invalid") << std::endl;
std::cout << "Validate 'NotCoolPaSsw[0]rd' password: " << (genertor.Validate("NotCoolPaSsw0rd") ? "valid" : "invalid") << std::endl;
return 0;
}
virtual std::password Generate() const
Generate the strong password with the current password requirements.
virtual bool Validate(std::string_view password) const
Validate the given password with the current password requirements.
PasswordFlags flags() const noexcept
Get the password flags.
Password generator definition.