Skip to main content

A simple Python library to generate numeric, alphabetic, or alphanumeric OTPs

Project description

🔐 Python OTP Generator

A simple and flexible One-Time Password (OTP) generator written in Python. Supports numeric, alphabetic, or alphanumeric OTPs with customizable length.


📋 Features

  • Generate OTPs of any length
  • Choose between:
    • Digits only (0-9)
    • Letters only (a-z, A-Z)
    • Alphanumeric (balanced mix of letters and digits)
  • Handles invalid input with user-friendly error messages
  • Randomly shuffles alphanumeric characters for better security

🧠 How It Works

The function generate_otp() takes three parameters:

generate_otp(length, include_letters=True, include_digits=True)

from otp import generate_otp

print(generate_otp(6))                      # e.g., 'd4A1z9' - Alphanumeric (default)
print(generate_otp(6, True, False))         # e.g., 'kYtReX' - Letters only
print(generate_otp(6, False, True))         # e.g., '729184' - Digits only
print(generate_otp(6, False, False))        # Error: At least one of include_letters or include_digits must be True
print(generate_otp())                       # Error: specify a valid length for OTP

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

make_otp-1.0.0.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

make_otp-1.0.0-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

Details for the file make_otp-1.0.0.tar.gz.

File metadata

  • Download URL: make_otp-1.0.0.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for make_otp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8430bfede1f7d48f70ecb4798f12f95b97e14fd3da7bfbd3b9d5b8500c886bc4
MD5 8ac8652bed58df5cf5cad89431a4dd1c
BLAKE2b-256 dcf631fe16ab378c7692ef92b668949a45cf4b0a2cd75d77eab5708c65359cc4

See more details on using hashes here.

File details

Details for the file make_otp-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: make_otp-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 2.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for make_otp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7805b422fe78671e3c89cac66499ec52554136ec714f6c896f0cedb036e67bd8
MD5 2e04ca94b185ce91c3e3e133e55519fa
BLAKE2b-256 8332bef970d39f928358db4a44b271d7592cc4a8d9155d62e42846f115aecf6e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page