zoukankan      html  css  js  c++  java
  • SpookyOTP

    https://pypi.python.org/pypi/SpookyOTP/1.1.1

    SpookyOTP 1.1.1

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

    SpookyOTP
    =========

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

    Description
    ===========

    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](https://github.com/google/google-authenticator/wiki/Key-Uri-Format)

    Example
    =======
    from spookyotp import (get_random_secret, TOTP, from_uri)

    secret = get_random_secret(n_bytes=10)
    totp = TOTP(secret, 'Example', 'user@example.org')
    totp.save_qr_code('qr.png')

    # you can now load the QR code with your app of choice
    code = input("Enter code: ") # or raw_input in Python 2
    matches = totp.compare(code)
    if matches:
    print("Correct!")
    else:
    print("Incorrect.")

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

    from spookyotp import (get_random_secret, TOTP, from_uri, HOTP)
    
    
    def GenQR():
        """
        生成二维码图片
        :return:
        """
        secret = get_random_secret(n_bytes=10)
        print(secret)
        totp = TOTP(secret, 'Example', 'user@example.org')
        totp.save_qr_code('qr.png') # 生成二维码图片,并保存为当前目录,文件名为qr.png
    
    def Verifier():
        """
        验证
        :return:
        """
        secret = get_random_secret(n_bytes=10)
        totp = TOTP(secret, 'Example', 'user@example.org')
        code = input("Enter code: ") # or raw_input in Python 2
        matches = totp.compare(code)
        if matches:
            print("Correct!")
        else:
            print("Incorrect.")
    
    Verifier()


    Why Spooky?
    ===========

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

  • 相关阅读:
    SQL查询效率注意事项 2011.12.27
    MSSQL2005数据库快照(SNAPSHOT)初探
    恢复Intellij idea删除的文件
    因样式冲突引起的div消失问题
    C# 用面向对象的思想去编程
    C# Combobox联动
    C#端加载数据库,Combobox与Node控件绑定数据源demo示例
    数据库无法打开到SQL Server连接
    SQLServer2008 远程过程调用失败
    将.db文件导入SQLServer2008数据库
  • 原文地址:https://www.cnblogs.com/linkenpark/p/7508247.html
Copyright © 2011-2022 走看看