Skip to content

This module generates a time-based one-time password (TOTP) using a custom 5-digit output format and a letter-protocol secret key. The algorithm follows standard TOTP principles (RFC 6238) but adapts them to produce a shorter numeric code suitable for lightweight authentication or device pairing.

License

Notifications You must be signed in to change notification settings

arbdoescode/Time-based-one-time-password

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” TOTP Generator β€” 5-Digit Code (Letter-Protocol Based)

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.


✨ Features

  • 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

βš™οΈ How It Works

  1. 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.

  2. Time Step (30s)
    Current Unix time is divided into 30-second intervals.
    Each interval produces a unique one-time password.

  3. HMAC Calculation
    The time step is hashed with the secret using HMAC-SHA1.

  4. Dynamic Truncation
    The HMAC result is truncated to a 31-bit integer, following TOTP standards.

  5. Final 5-Digit Code
    The value is reduced modulo 100000 to generate the final 5-digit OTP.


πŸ“Œ Example Output

TOTP: 48291 Valid for: 30 seconds


πŸ“¦ Use Cases

  • POS activation & linking
  • Offline device verification
  • Quick identity confirmation
  • Embedded systems with low UI requirements

About

This module generates a time-based one-time password (TOTP) using a custom 5-digit output format and a letter-protocol secret key. The algorithm follows standard TOTP principles (RFC 6238) but adapts them to produce a shorter numeric code suitable for lightweight authentication or device pairing.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages