Skip to content

Commit

Permalink
more on readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Jun 10, 2013
1 parent 905ccc5 commit 02503da
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,34 @@ To install otpauth, simply::

$ pip install otpauth


Contribute
----------

Read the `Contribution Guide`_.

.. _`Contribution Guide`: https://github.com/lepture/otpauth/blob/master/CONTRIBUTING.rst
Usage
-----

Generate and validate an otp code is very simple::

>>> from otpauth import OtpAuth
>>> auth = OtpAuth('secret') # a secret string
>>> auth.hotp()
330810
>>> auth.valid_hotp(330810)
4
>>> auth.hotp(2)
720111
>>> auth.valid_hotp(720111)
2
>>> auth.totp() # a time based string
828657
>>> auth.valid_totp(828657)
True


Google Authenticator
--------------------

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

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

0 comments on commit 02503da

Please sign in to comment.