Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

A lightweight Python 2/3 package for handling HOTP/TOTP (Google Authenticator) authentication.

Project description


Lightweight Python package for TOTP/HOTP (Google Authenticator) codes


This is a lightweight package for generating TOTP and HOTP codes used for two-factor authentication. They can be used with Google Authenticator or FreeOTP.

Some features (such as using different hashing algorithms or displaying more than 6 digits) do not work with Google Authenticator.

URIs generated (and QR codes encoding them) follow the Google Authenticator format


from spookyotp import (get_random_secret, TOTP, from_uri)

secret = get_random_secret(n_bytes=10)
totp = TOTP(secret, 'Example', '')

# you can now load the QR code with your app of choice
code = input("Enter code: ")  # or raw_input in Python 2
matches =
if matches:

# serialization and deserialization is supported via URI
uri = totp.get_uri()
new_totp = from_uri(uri)

Why Spooky?

I created the git repo on Halloween, and there is already a project called PyOTP.

Project details

Download files

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

Files for SpookyOTP, version 1.1.4
Filename, size File type Python version Upload date Hashes
Filename, size SpookyOTP-1.1.4-py2.py3-none-any.whl (7.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size SpookyOTP-1.1.4-py3.7.egg (13.5 kB) File type Egg Python version 3.7 Upload date Hashes View
Filename, size SpookyOTP-1.1.4.tar.gz (7.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page