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.

SpookyOTP的更多相关文章

随机推荐

  1. Android查缺补漏(IPC篇)-- 进程间通讯之AIDL详解

    本文作者:CodingBlock 文章链接:http://www.cnblogs.com/codingblock/p/8436529.html 进程间通讯篇系列文章目录: Android查缺补漏(IP ...

  2. bzoj1607 / P2926 [USACO08DEC]拍头Patting Heads

    P2926 [USACO08DEC]拍头Patting Heads 把求约数转化为求倍数. 累计每个数出现的个数,然后枚举倍数累加答案. #include<iostream> #inclu ...

  3. Python3.x:基础学习

    Python3.x:基础学习 1,Python有五种标准数据类型 1.数字 2.字符串 3.列表 4.元组 5.字典 (1).数字 数字数据类型存储数字值.当为其分配值时,将创建数字对象. var1 ...

  4. HDU 4745 Two Rabbits(最长回文子序列)

    http://acm.hdu.edu.cn/showproblem.php?pid=4745 题意: 有一个环,现在有两只兔子各从一个点开始起跳,一个沿顺时针,另一个沿逆时针,只能在一圈之内跳,并且每 ...

  5. class []的用法

    span[class='test']    =>匹配所有带有class类名test的span标签 span[class *='test']  =>匹配所有包含了test字符串的class类 ...

  6. sudo环境变量问题;程序库函数寻找

    1. sudo 和 root不完全等效,继承的环境变量不一样,最主要的区别还是输入的密码不同. 2. 使用sudo去执行一个程序时,出于安全的考虑,这个程序将在一个新的.最小化的环境中执行,也就是说, ...

  7. PHPUnit简介及使用(thinkphp5的单元测试安装及使用)

    PHPUnit简介及使用(thinkphp5的单元测试安装及使用) 一.总结 一句话总结:直接google这个phpunit(how to use phpunit),然后去官网看使用样例和手册,那些英 ...

  8. 套用EVAL

    <%#getSimple(setHeight(Eval("File").ToString(), searchTxt, false), 340)%>

  9. axis2 webservice jar包使用情况(转)

    原文地址:axis2 webservice jar包使用情况 今天使用axis2webservice,整理了下jar包,方便以后时候. axis2 webservice 服务端jar包: --> ...

  10. Spring的注解@Qualifier(二十五)

    转载:https://www.cnblogs.com/smileLuckBoy/p/5801678.html 近期在捯饬spring的注解,现将遇到的问题记录下来,以供遇到同样问题的童鞋解决~ 先说明 ...