[−][src]Function libreauth::oath::libreauth_totp_generate
#[no_mangle] pub extern "C" fn libreauth_totp_generate(
cfg: *const TOTPcfg,
code: *mut u8
) -> ErrorCode
[C binding] Generate a TOTP code according to the given configuration and stores it in the supplied buffer.
Examples
struct libreauth_totp_cfg cfg;
const char key[] = "12345678901234567890";
char code[DEFAULT_BUFF_LEN + 1] = {0};
uint32_t ret = libreauth_totp_init(&cfg);
if (ret != LIBREAUTH_OATH_SUCCESS) {
// Handle the error.
}
cfg.key = key;
cfg.key_len = strlen(key);
ret = libreauth_totp_generate(&cfg, code);
if (ret != LIBREAUTH_OATH_SUCCESS) {
// Handle the error.
}
printf("TOTP code: %s\n", code);