SecurePasswd_MGMT 2026.03.19
A modern, cross-platform password manager and two-factor authenticator (TOTP) designed with state-of-the-art security.
Loading...
Searching...
No Matches
totp.c File Reference
#include <openssl/hmac.h>
#include <openssl/evp.h>
#include <string.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include "totp.h"
Include dependency graph for totp.c:

Functions

static int base32_decode (const uint8_t *encoded, uint8_t *result, int bufSize)
char * generate_totp_code_at_time (const char *base32_secret, time_t current_time)
 Generates a 6-digit TOTP code from a base32-encoded secret for a specific time.
char * generate_totp_code (const char *base32_secret)
 Generates a 6-digit TOTP code from a base32-encoded secret for the current time.

Function Documentation

◆ base32_decode()

int base32_decode ( const uint8_t * encoded,
uint8_t * result,
int bufSize )
static

◆ generate_totp_code()

char * generate_totp_code ( const char * base32_secret)

Generates a 6-digit TOTP code from a base32-encoded secret for the current time.

Parameters
base32_secretThe base32-encoded TOTP secret.
Returns
A dynamically allocated string containing the 6-digit TOTP code. The caller is responsible for freeing this string.

◆ generate_totp_code_at_time()

char * generate_totp_code_at_time ( const char * base32_secret,
time_t current_time )

Generates a 6-digit TOTP code from a base32-encoded secret for a specific time.

Parameters
base32_secretThe base32-encoded TOTP secret.
current_timeThe time to generate the TOTP code for.
Returns
A dynamically allocated string containing the 6-digit TOTP code. The caller is responsible for freeing this string.