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. bzoj2721 / P1445 [Violet]樱花

    P1445 [Violet]樱花 显然$x,y>n$ 那么我们可以设$a=n!,y=a+t(t>0)$ 再对原式通分一下$a(a+t)+ax=x(a+t)$ $a^{2}+at+ax=ax ...

  2. poj3071 Football(概率dp)

    poj3071 Football 题意:有2^n支球队比赛,每次和相邻的球队踢,两两淘汰,给定任意两支球队相互踢赢的概率,求最后哪只球队最可能夺冠. 我们可以十分显然(大雾)地列出转移方程(设$f[ ...

  3. CUDA、tensorflow与cuDNN的版本匹配问题【转】

    本文转载自:https://blog.csdn.net/MahoneSun/article/details/80809042 一.问题现象 CUDA.tensorflow 与 cuDNN有版本匹配的问 ...

  4. jquery获取服务器控件Label的值

    首先引入js文件:<script type="text/javascript" src="js/jquery-1.8.3.js"></scri ...

  5. hadoop经典案例

    hadoop经典案例http://blog.csdn.net/column/details/sparkhadoopdemo.html

  6. python 读空的json文件

    读空的json文件,python2和python3 的错误提示是不一样的 python2: ValueError: No JSON object could be decoded python3: j ...

  7. css输入框的圆角

    转载:http://jingyan.baidu.com/article/73c3ce28f0b38fe50343d926.html 1.原理是四张圆角的图片放在四个角上,就是圆角矩形的四个角,但这种方 ...

  8. Cool Auto-Suggest 插件使用方法

    刚入职的时候公司主管曾经让我用Cool Auto-Suggest 插件写过后台管理页面内的自动填充及搜索功能. 其实这个插件的使用很简单,网上也有相应的翻译文档,但是明显的机翻看着无法忍受.我写一下使 ...

  9. Rails 5 Test Prescriptions 第4章 什么制造了伟大的测试

    伴随着程序成长,测试变长,复杂性增加,如何更高效的写测试,对以后开发不会造成麻烦. 测试本身没发被测试,所以一定要清楚,可控.不要加循环,不要过于复杂的自动编程. Cost and Value 成本和 ...

  10. 解决mysql安装报错:无法启动此程序,因为计算机丢失MSVCP120.dll

    问题一: 因为装的是新系统,所以遇到mysql启动报错:无法启动此程序,因为计算机丢失MSVCP120.dll 后来参考这篇文章https://blog.csdn.net/huacode/articl ...