Giter Site home page Giter Site logo

onetimepass's Introduction

Versions

Current stable release: onetimepass-v0.2.2.tar.gz otp-status-prod

Current development release: onetimepass-master.tar.gz otp-status-dev

Changelog

Version Date Changes
0.2.2 2013-07-12
  • license clarification,
  • removal of compiled documentation from the sources,
0.2.1 2013-07-12
  • support for unicode secrets,
  • preliminary support for Travis CI,
0.2.0 2013-04-11
  • added compatibility with Python 3.x,
  • removed compatibility with Python 2.5 and earlier,
0.1.2 2013-01-23
  • added automated case fold to secret,
0.1.1 2013-12-20
  • internal code improvements,
  • documentation,
0.1.0 2011-12-19 (initial public release)

What is OneTimePass

OneTimePass (actually onetimepass) is a module for generating one-time passwords, namely HOTPs (HMAC-based one-time passowords) and TOTPs (time-based one-time passwords). They are used eg. within Google Authenticator application for Android or iPhone.

How to install

To install the library, you can either use pip, or just download it separately. Installing in pip is the simplest. Assuming you are installing it system-wide:

$ sudo pip install onetimepass

(if you are installing it in virtualenv, you do not need "sudo" part).

Alternatively, you can follow the download link above and unpack in some directory on your sys.path, or clone it as Git submodule to your own directory.

How to use OneTimePass

You can use this module in the following way:

  1. Install module (download it into your application's directory or into modules directory)

  2. To get time-based token you invoke it like that:

    import onetimepass as otp
    my_secret = 'MFRGGZDFMZTWQ2LK'
    my_token = otp.get_totp(my_secret)
    
  3. To get HMAC-based token you invoke it like that:

    import onetimepass as otp
    my_secret = 'MFRGGZDFMZTWQ2LK'
    my_token = otp.get_hotp(my_secret, intervals_no=3)
    

    where intervals_no is the number of the current trial (if checking on the server, you have to check several values, higher than the last successful one, determined for previous successful authentications).

  4. To check time-based token you invoke it like that:

    import onetimepass as otp
    my_secret = 'MFRGGZDFMZTWQ2LK'
    my_token = 123456 # should be probably from some user's input
    is_valid = otp.valid_totp(token=my_token, secret=my_secret)
    
  5. To check HMAC-based token you invoke it like that:

    import onetimepass as otp
    my_secret = 'MFRGGZDFMZTWQ2LK'
    my_token = 123456 # should be probably from some user's input
    last_used = 5 # store last valid interval somewhere else
    is_valid = otp.valid_hotp(token=my_token, secret=my_secret, last=last_used)
    

    where:

    • last argument (in this case being assigned last_used) is the number of the last successfully checked interval number (as valid_totp() will skip it and start checking from the next interval number)
    • is_valid is being assigned value of False if my_token has not been identified as valid OTP for given secret (my_secret) and checked interval range. If it has been successful, is_valid is assigned a number of the working interval number (it should be saved into the database and supplied to the function as last argument next time the password is being checked, so you cannot use the same token again).

License

License for this library is available in LICENSE.rst file, in the same directory. Online version is available here.

onetimepass's People

Contributors

horizonxp avatar tadeck avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.