Simple to use library for generating TOTP
Just:
#include "totp.min.hpp"
And use functions:
std::string totp::generateSecret(std::string password);
Generating secret using init string or password and encodes it in base32
std::string totp::generateTOTP(std::string secret, int period = 30, int digits = 6);
Generate TOTP using existing secret, also you can define update period and number of digits
std::string totp::generateURL(std::string secret, std::string username, std::string issuer, std::string application = "");
Generate URL using data to make QR code and simplify scan on mobile devices
std::string totp::generateQR_URL(std::string secret, std::string username, std::string issuer, std::string application = "");
Generate QR code URL
int totp::time_until_new_period(int period);
Get time in seconds until new period
Go to the gtotp folder and:
make
Copy libtotp.a to your folder and compile it with your project Also do not forget to install OpenSSL headers by installing libssl-dev package:
sudo apt-get install libssl-dev
And link your project with -lcrypto flag:
g++ test.cpp libtotp.a -o test -lcrypto