DEV Community

Dilanka Rathnasiri
Dilanka Rathnasiri

Posted on

πŸ” OTP CLI Utils β€” A Simple and Powerful CLI tool for TOTP Codes

Hello everyone πŸ‘‹

I recently built a new Python CLI tool called OTP CLI Utils β€” a lightweight command-line utility to generate, validate, and manage Time-based One-Time Password (TOTP) codes. If you use Google Authenticator or work with 2FA systems, this tool can make your developer workflow a lot smoother.

πŸ”— GitHub: https://github.com/dilanka-rathnasiri/otp-cli-utils
πŸ”— PyPI: https://pypi.org/project/otp-cli-utils


πŸš€ What It Does

OTP CLI Utils provides a simple interface to handle everything related to TOTP (used in 2FA systems). You can:

  • πŸ”‘ Generate current OTP codes from a secret
  • βœ… Validate OTP codes against a secret
  • πŸ”„ Generate secure random OTP secrets
  • πŸ“± Create Google Authenticator compatible QR codes
  • 🧰 All from your command line, no web tools or GUIs needed

βš™οΈ Installation

You can install it easily from PyPI:

pip install otp-cli-utils
Enter fullscreen mode Exit fullscreen mode

πŸ’‘ Usage Examples

πŸ”Ή Generate the Current OTP Code

otp-cli-utils get-otp <secret>
Enter fullscreen mode Exit fullscreen mode

Example:

otp-cli-utils get-otp ABCDEF1234567890
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Validate an OTP

Check if an OTP code is valid for a given secret.

otp-cli-utils validate <secret> <otp> [--window-count <count> | --time-period <seconds>]
Enter fullscreen mode Exit fullscreen mode

Examples:

otp-cli-utils validate ABCDEF1234567890 123456
otp-cli-utils validate ABCDEF1234567890 123456 --window-count 2
otp-cli-utils validate ABCDEF1234567890 123456 --time-period 120
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Generate a New OTP Secret

otp-cli-utils generate-secret
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Create a QR Code for Google Authenticator

Easily generate a QR code image to scan directly with authenticator apps.

otp-cli-utils generate-secret-qr-code "user@example.com" "GitHub" github_2fa
Enter fullscreen mode Exit fullscreen mode

🀝 Contribute

Contributions, ideas, and feedback are welcome!
Check out the project on GitHub and feel free to open an issue or PR.


🧾 License

Released under the MIT License β€” completely open source.

Top comments (0)