Skip to main content

A simple TOTP + QR code generator package for 2FA

Project description

allsafe-otp

Project Overview

allsafe-otp is a simple Python package for generating Time-Based One-Time Passwords (TOTP) and QR codes for two-factor authentication (2FA). It allows you to easily create secure OTPs and generate QR codes that can be scanned with Google Authenticator or other 2FA apps.

Features

  • Generate secure TOTP codes using the HMAC-SHA1 algorithm.
  • Create scannable QR codes for Google Authenticator or any 2FA app.
  • Easy to integrate into your Python projects.

Installation

pip install allsafe-otp

Usage

1. Generate a TOTP Code

from allsafe_otp.totp import generate_otp

secret = "JBSWY3DPEHPK3PXP"  # Your base32 secret
otp = generate_otp(secret)
print(f"Generated OTP: {otp}")

2. Generate a QR Code for Google Authenticator

from allsafe_otp.generate_qr import generate_qr_code

otp_url = "otpauth://totp/MyApp:daniel@allsafe.com?secret=JBSWY3DPEHPK3PXP&issuer=MyApp"
generate_qr_code(otp_url)

Testing

To test the package:

  1. Install the package (if not already installed):
pip install allsafe-otp
  1. Create a test script (test.py):
from allsafe_otp.totp import generate_otp
from allsafe_otp.generate_qr import generate_qr_code

secret = "JBSWY3DPEHPK3PXP"
print("Generated OTP from Python:", generate_otp(secret))

otp_url = "otpauth://totp/MyApp:daniel@allsafe.com?secret=JBSWY3DPEHPK3PXP&issuer=MyApp"
generate_qr_code(otp_url)

Project Structure

allsafe-otp/
├── allsafe_otp/
│   ├── __init__.py
│   ├── generate_qr.py
│   └── totp.py
├── setup.py
└── README.md

Contributing

Feel free to open issues or submit pull requests.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

allsafe_otp-0.1.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

allsafe_otp-0.1.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file allsafe_otp-0.1.1.tar.gz.

File metadata

  • Download URL: allsafe_otp-0.1.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for allsafe_otp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2977ac158a0b7c368e63d1c183b60c861719fd0baa6b4de3d9871e02c87ad3a0
MD5 2956b1829d3e0f44a8d977f53566b40f
BLAKE2b-256 b3f3d7e25125df854d7a09f4c5d5d8c5123f4cdb9247ccfc0b206e3f86d533ce

See more details on using hashes here.

File details

Details for the file allsafe_otp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: allsafe_otp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for allsafe_otp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c4218e86c79278fd27377835c62d825f2204e0c0f2b1b5aabd490986a67a4de9
MD5 cdcdea467d9a56bb44581b1e5ef83c52
BLAKE2b-256 95cd8f5db6e3615ba7e710f6a3e992819f4da851fa29aaa6dd2baacfaa469b6d

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