Skip to main content

Implements two-step verification of HOTP/TOTP

Project description

cryptography has built-in two factor support now.

otpauth is One Time Password Authentication, which is usually called as two steps verification. You may have heard it from Google, Dropbox and etc.

Wheel Status Latest Version Travis CI Status Coverage Status App Veyor CI Status


Installing otpauth is simple with pip:

$ pip install otpauth

or, with easy_install:

$ easy_install otpauth


Generate and validate an otp code is very simple:

>>> from otpauth import OtpAuth
>>> auth = OtpAuth('secret')  # a secret string
>>> auth.hotp()  # generate a count based code, default count is 4
>>> auth.valid_hotp(330810)
>>> auth.hotp(2)  # generate a count based code, count is 2
>>> auth.valid_hotp(720111)
>>> auth.totp()  # generate a time based code
>>> auth.valid_totp(828657)


You can create a QR code for Google Authenticator to scan:

>>> from otpauth import OtpAuth
>>> auth = OtpAuth('secret')  # a secret string
>>> s = auth.to_uri('totp', 'Example:foo@bar.baz', 'Foo')
>>> import qrcode
>>> img = qrcode.make(s)

Download files

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

Files for otpauth, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size otpauth-1.0.1-py2.py3-none-any.whl (5.8 kB) File type Wheel Python version 2.7 Upload date Hashes View hashes
Filename, size otpauth-1.0.1.tar.gz (5.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page