#include <iostream>
int main(int argc, char** argv)
{
std::cout << "Password: " << password << std::endl;
std::cout << "Generated secret: " << secret << std::endl;
std::cout << "Generated URL: " << url << std::endl;
std::cout << "Generated QR Code link: " << qr << std::endl;
std::cout << "Please enter Google Authenticator tokens to validate. Enter '0' to exit..." << std::endl;
std::string line;
while (getline(std::cin, line))
{
if (line.empty() || (line == "0"))
break;
size_t token = std::stoi(line);
std::cout << (authenticator.
Validate(token, secret) ?
"Valid" :
"Invalid") << std::endl;
}
return 0;
}
std::password GenerateURL(std::string_view identifier, std::string_view secret) const
Generate the Google Authenticator URL.
std::password GenerateQRCodeLink(std::string_view url, size_t width=100, size_t height=100) const
Generate the Google Authenticator QR Code link.
std::password GenerateSecret(std::string_view password) const
Generate the Google Authenticator secret from the given user password.
bool Validate(size_t token, std::string_view secret, const CppCommon::Timestamp ×tamp=CppCommon::UtcTimestamp()) const
Validate the Google Authenticator token over the given secret and UTC timestamp.
Google Authenticator definition.