<commit_before>Python bindings for OATH Toolkit
================================

This package is a set of Python bindings for the `OATH Toolkit`_ library.
Please note that it is *OATH* (open authentication, e.g., one-time passwords)
and not *OAuth* (an open standard for authorization).

.. image:: https://travis-ci.org/malept/pyoath-toolkit.svg?branch=master
   :alt: Travis CI status, see https://travis-ci.org/malept/pyoath-toolkit

.. _OATH Toolkit: http://www.nongnu.org/oath-toolkit/

Features
--------

* Runs on a variety of Python versions/implementations
* `QR code`_ generator, compatible with apps like `Google Authenticator`_
* Integration with WTForms_
* Integration with Django via ``django-otp``

.. _Google Authenticator: https://en.wikipedia.org/wiki/Google_Authenticator
.. _QR code: https://en.wikipedia.org/wiki/QR_code
.. _WTForms: http://pypi.python.org/pypi/WTForms

Usage
-----

To generate a time-based one-time password (TOTP):

.. code-block:: python

   from oath_toolkit import TOTP
   from time import time

   digits = 6
   time_step = 30
   oath = TOTP(b'secret key', digits, time_step)
   one_time_password = oath.generate(time())

To validate a HMAC-based one-time password (HOTP):

.. code-block:: python

   from oath_toolkit import HOTP
   from oath_toolkit.exc import OATHError

   def verify(otp, counter):
       digits = 6
       oath = HOTP(b'secret key', digits)
       try:
           return oath.verify(otp, counter)
       except OATHError:
           return False

For an explanation of terms like ``time_step`` and ``counter``, refer to the
`API documentation <#docs>`_.

More complex examples can be found in the ``examples/`` directory, which
includes a port of ``oathtool``, a sample Django project, and a simple Flask
app, which shows how WTForms integration works.

.. _docs:

Documentation
-------------

The documentation_ at `Read the Docs`_ contains information such as:

* Requirements and installation instructions
* API documentation
* Contribution guidelines and a list of contributors

.. _documentation: https://pyoath-toolkit.readthedocs.org/
.. _Read the Docs: https://readthedocs.org/

License
-------

Unless otherwise noted in the respective files, the code is licensed under the
Apache License 2.0; see the ``LICENSE`` file for details on the Apache license.
The otherwise-licensed files have the requisite separate license details.
Specifically:

* ``oath_toolkit/django_otp/hotp/tests.py`` and
  ``oath_toolkit/django_otp/totp/tests.py`` are originally licensed under the<commit_msg>Remove duplicate target names from README<commit_after>Python bindings for OATH Toolkit
================================

This package is a set of Python bindings for the `OATH Toolkit`_ library.
Please note that it is *OATH* (open authentication, e.g., one-time passwords)
and not *OAuth* (an open standard for authorization).

.. image:: https://travis-ci.org/malept/pyoath-toolkit.svg?branch=master
   :alt: Travis CI status, see https://travis-ci.org/malept/pyoath-toolkit

.. _OATH Toolkit: http://www.nongnu.org/oath-toolkit/

Features
--------

* Runs on a variety of Python versions/implementations
* `QR code`_ generator, compatible with apps like `Google Authenticator`_
* Integration with WTForms_
* Integration with Django via ``django-otp``

.. _Google Authenticator: https://en.wikipedia.org/wiki/Google_Authenticator
.. _QR code: https://en.wikipedia.org/wiki/QR_code
.. _WTForms: http://pypi.python.org/pypi/WTForms

Usage
-----

To generate a time-based one-time password (TOTP):

.. code-block:: python

   from oath_toolkit import TOTP
   from time import time

   digits = 6
   time_step = 30
   oath = TOTP(b'secret key', digits, time_step)
   one_time_password = oath.generate(time())

To validate a HMAC-based one-time password (HOTP):

.. code-block:: python

   from oath_toolkit import HOTP
   from oath_toolkit.exc import OATHError

   def verify(otp, counter):
       digits = 6
       oath = HOTP(b'secret key', digits)
       try:
           return oath.verify(otp, counter)
       except OATHError:
           return False

For an explanation of terms like ``time_step`` and ``counter``, refer to the
`API documentation <#documentation>`_.

More complex examples can be found in the ``examples/`` directory, which
includes a port of ``oathtool``, a sample Django project, and a simple Flask
app, which shows how WTForms integration works.

Documentation
-------------

The docs_ at `Read the Docs`_ contains information such as:

* Requirements and installation instructions
* API documentation
* Contribution guidelines and a list of contributors

.. _docs: https://pyoath-toolkit.readthedocs.org/
.. _Read the Docs: https://readthedocs.org/

License
-------

Unless otherwise noted in the respective files, the code is licensed under the
Apache License 2.0; see the ``LICENSE`` file for details on the Apache license.
The otherwise-licensed files have the requisite separate license details.
Specifically:

* ``oath_toolkit/django_otp/hotp/tests.py`` and
  ``oath_toolkit/django_otp/totp/tests.py`` are originally licensed under the
{'fraction_non_alphanumeric': 0.1181179226864506, 'fraction_numerical': 0.0023428348301444747, 'mean_word_length': 3.783380018674136, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 12, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1135079', 'n_tokens_mistral': 1618, 'n_tokens_neox': 1534, 'n_words': 535}