smart-2fa-secure v0.2.4

Advanced Two-Factor Authentication system with enhanced security features

Complex code generation, flexible expiration, and secure delivery via Telegram.

Python 2FA Security Django Redis PyPI

smart-2fa-secure — advanced Two-Factor Authentication system with enhanced security features.

Supports complex code generation with ASCII letters, digits and special characters. Features adjustable TTL (Time-To-Live), Telegram integration with customizable message templates, and secure Redis storage.

  • Complex Code Generation
    • Supports ASCII letters, digits and special characters
    • Customizable code length (default: 6)
  • Flexible Expiration
    • Adjustable TTL (Time-To-Live) for codes
    • Default 60 seconds expiration
  • Secure Delivery
    • Telegram integration with customizable message templates

pip install smart-2fa-secure

from smart_2fa_secure import Smart2FA
from smart_2fa_secure.exceptions import InvalidCodeError

smart_2fa = Smart2FA(
    redis_host="localhost",
    redis_port=6379,
    telegram_token="YOUR_BOT_TOKEN",
    code_ttl=60,
    max_attempts=3,
    code_length=6,
)

# Send verification code
code = smart_2fa.send_code(
    user_id="user1",
    recipient="1234567",
    message="Your code:"
)

# Verify with complex code
try:
    smart_2fa.verify_code("user123", "A1b2@#")
    print("Authentication successful!")
except InvalidCodeError:
    print("Invalid security code!")

Development Dependencies:

pip install pytest
pip install pytest-cov
pip install setuptools
pip install wheel
pip install build
pip install twine

Testing & Build:

# Run tests
pytest tests/ -v

# Run tests with coverage
pytest tests/ -v --cov=smart_2fa_secure --cov-report=html

# Build package
python -m build
# or
python setup.py sdist bdist_wheel

# Upload to PyPI
twine upload dist/*

By using this software, you agree to the full disclaimer terms.

Software provided "AS IS" without warranty. You assume all risks.

Full legal disclaimer: See DISCLAIMER.md

License: BSD 3-Clause License

Links


Created by Alexander Suvorov

Copyright © 2025, Alexander Suvorov