🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

allsafe-otp

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

allsafe-otp

A simple TOTP + QR code generator package for 2FA

0.1.1
Maintainers
1

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:

  • Install the package (if not already installed):
pip install allsafe-otp
  • 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.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts