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