Lightweight, cross-platform implementation of HOTP and TOTP in C, designed for embedded systems, desktop, and server applications. It is written in pure C and does not depend on any external libraries.
The user only needs to provide SHA-related methods, as they are wrapped in an abstraction layer. Accordingly, any implementation can be used, such as OpenSSL or hardware-accelerated versions on a supported platform.
This is a simple tool built on top of the cOTP library, which allows you to:
- Generate the current TOTP/HOTP code
- Generate an otpauth URI that can be encoded as a QR code
- Generate current code and otpauth URI:
SECRET=$(openssl rand 32 | base32); ./tool/cotp-tool --algo sha256 -s $SECRET -t totp -p 30 -d 6 -S $(date -u +%s) -u -n example@domain
- Generate a QR code:
qrencode -t png -o code.png "otpauth://totp/example%40domain?secret=VJMODH2ICVHLZK4CRWONBW3ZR7V72PDKLMMOWP6ALMGJGW5QTNWA&period=30&digits=6&algorithm=SHA256"