9 #ifndef CPPSECURITY_GOOGLE_AUTHENTICATOR_H
10 #define CPPSECURITY_GOOGLE_AUTHENTICATOR_H
14 #include "time/timestamp.h"
51 size_t pin_length() const noexcept {
return _pin_length; }
96 size_t GenerateToken(std::string_view secret,
const CppCommon::Timestamp& timestamp = CppCommon::UtcTimestamp())
const;
105 bool Validate(
size_t token, std::string_view secret,
const CppCommon::Timestamp& timestamp = CppCommon::UtcTimestamp())
const;
114 bool Validate(
size_t token, std::string_view password, std::string_view salt,
const CppCommon::Timestamp& timestamp = CppCommon::UtcTimestamp())
const;
117 size_t _secret_length;
size_t pin_length() const noexcept
Get the pin length.
GoogleAuthenticator & operator=(GoogleAuthenticator &&)=default
size_t GenerateToken(std::string_view secret, const CppCommon::Timestamp ×tamp=CppCommon::UtcTimestamp()) const
Generate the Google Authenticator token for the given secret and UTC timestamp.
std::password GenerateURL(std::string_view identifier, std::string_view secret) const
Generate the Google Authenticator URL.
std::string GenerateSalt() const
Generate the unique password salt.
GoogleAuthenticator(size_t secret_length=12, size_t pin_length=6)
Initialize Google Authenticator with required parameters.
std::password GenerateQRCodeLink(std::string_view url, size_t width=100, size_t height=100) const
Generate the Google Authenticator QR Code link.
GoogleAuthenticator(const GoogleAuthenticator &)=default
std::password GenerateSecret(std::string_view password) const
Generate the Google Authenticator secret from the given user password.
GoogleAuthenticator & operator=(const GoogleAuthenticator &)=default
~GoogleAuthenticator()=default
GoogleAuthenticator(GoogleAuthenticator &&)=default
size_t secret_length() const noexcept
Get the secret length.
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.
Password string definition.