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.
SpookyOTP的更多相关文章
随机推荐
- linux wa%过高,iostat查看io状况
命令总结: 1. top/vmstat 发现 wa%过高,vmstat b >1: 参考文章: 1. 关于Linux系统指令 top 之 %wa 占用高,用`iostat`探个究竟 最近测试一项 ...
- UVaLive4992:Jungle Outpost
传送门 半平面交. 首先,由显然成立法可以证明炸连续的几个总比分散火力效果更佳. 所以二分答案,转化为判定问题,即间隔$ans$个点的连线的半平面交是否为空. 半平面交判定即可. 时间复杂度:$O(N ...
- SqlBulkCopy 批量导入数据 转换表字段类型
在使用SqlBulkCopy导入数据时,要有一个跟数据库里面同样的DataTable 要赋值表名 要求每个列跟数据库中列同名,并且列的类型要赋值跟数据库中列的类型对应的NET类型 要求数据库中为Nul ...
- Matlab绘图基础——用print函数批量保存图片到文件(Print figure or save to file)
一.用法解析 1.1. 分辨率-rnumber 1.2. 输出图片的“格式”formats 二.用法示例 2.1. 设置输出图片的“图像纵横比” 2.2. Batch Processing(图片保存 ...
- trim()不兼容ie的问题及解决方法
当输入 src.trim();时,ie浏览器不支持此属性和方法,解决方法: //ie兼容trim方法if(!String.prototype.trim) { String.prototype.trim ...
- Yii关键概念
basic/ 应用根目录 composer.json Composer 配置文件, 描述包信息 config/ 包含应用配置及其它配置 console.php 控制台应用配置信息 web.php We ...
- 介绍一个python视频处理库:moviepy
由于博客园的插件和我自己博客的插件不一致,代码以及视频插入转换很麻烦,所以还是我原来博客的地址查看吧. 介绍一个python视频处理库:moviepy
- MySQL分页查询大数据量优化方法
方法1: 直接使用数据库提供的SQL语句 语句样式: MySQL中,可用如下方法: SELECT * FROM 表名称 LIMIT M,N适应场景: 适用于数据量较少的情况(元组百/千级)原因/缺点: ...
- Html中文字过多,单行超出和多行超出显示省略号
本博客主要介绍 前端开发中文本过多,以省略号显示. 效果如图: 单行: <!--单行--> <p class="pl">这个属 ...
- 【MySQL】经典数据库SQL语句编写练习题——SQL语句扫盲
[MySQL]数据库原理复习——SQL语言 对基本的SQL语句编写的练习题,其中的题目的答案可能会有多种书写方式. 1.题目1 1.1 关系模式 学生student:SNO:学号,SNAME:姓名,A ...