This module generates a 5-digit Time-Based One-Time Password (TOTP) using a letter-based secret protocol.
It follows standard TOTP logic (RFC 6238) but outputs a shorter numeric code ideal for POS devices, embedded systems, and lightweight authentication.
- Outputs a 5-digit numeric TOTP (
00000β99999) - Uses a letter-protocol secret (AβZ converted to bytes)
- 30-second code validity window
- HMAC-SHA1 hashing with dynamic truncation
- Lightweight and easy to integrate
-
Letter-Protocol Secret
The secret is provided as a sequence of letters (AβZ).
Each letter is converted to a byte and used as the shared secret. -
Time Step (30s)
Current Unix time is divided into 30-second intervals.
Each interval produces a unique one-time password. -
HMAC Calculation
The time step is hashed with the secret usingHMAC-SHA1. -
Dynamic Truncation
The HMAC result is truncated to a 31-bit integer, following TOTP standards. -
Final 5-Digit Code
The value is reduced modulo100000to generate the final 5-digit OTP.
TOTP: 48291 Valid for: 30 seconds
- POS activation & linking
- Offline device verification
- Quick identity confirmation
- Embedded systems with low UI requirements