Netthaw / TOTP-MCU

OTP library for C (All MCU)(Pure C)
MIT License
65 stars 12 forks source link
c esp32 esp8266 mcu msp nrf otp otp-library stm32 totp totp-tokens

TOTP Pure C Library for ALL MCU

Library to generate Time-based One-Time Passwords.

Implements the Time-based One-Time Password algorithm specified in RFC 6238. Supports different time steps and is compatible with tokens that use the same standard (including software ones, like the Google Authenticator app).

Tested on MCUs: MSP430, RP2040

Installation & usage:

First include header to your file

#include <totp.h>

After included, define key ex. Key is MyLegoDoor

If the provided unix timestamp isn't in UTC±0, use setTimezone() before getCodeFromTimestamp() or getCodeFromTimeStruct() to offset the time.

setTimezone(9);                                            // Set timezone +9 Japan

You can see an example in blink.c

Thanks to: