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的更多相关文章
随机推荐
- mssql语句递归查找所有下级
if exists (select * from sys.all_objects where name='GetOrgTree') begin drop function GetOrgTree end ...
- Linux内核分析08
进程的切换和系统的一般执行过程 一,进程切换的关键代码switch_to分析 进程调度的时机 中断处理过程(包括时钟中断.I/O中断.系统调用和异常)中,直接调用schedule(),或者返回用户态时 ...
- 20145211MSF基础应用实验
20145211MSF基础应用实验 一.实验博客 ms08_067攻击实验 http://www.cnblogs.com/entropy/p/6690301.html ms12_004漏洞攻击 htt ...
- Linux 实现软件可视化安装(VNC)
(1)光盘挂载或者配置yum源,如果是在虚拟机上练习,可以使用如下命令进行光盘挂载: sudo mkdir /mnt/cdrom sudo mount /dev/cdrom /mnt/cdrom 但是 ...
- mis权限系统
在mis中开发,主要目的是有一个统一的权限管理(即r360.right表),以及一个统一的系统和界面供后台配置管理 1.数据库准备工作: mis后台涉及表: right表是权限操作表,role_rig ...
- TCGA三个在线可视化网站
1.>c-Bioportal: www.cbioportal.org 整合和简化了包括TCGA,ICGC以及GEO等多个癌症基因组数据库的内容,提供友好可视化的界面,可供下载. 主要展示基因的s ...
- ResourceNotFound: rgbd_launch
Checking log directory for disk usage. This may take awhile. Press Ctrl-C to interrupt Done checking ...
- Command(命令)
意图: 将一个请求封装为一个对象,从而使你可用不同的请求对客户进行参数化:对请求排队或记录请求日志,以及支持可撤消的操作. 适用性: 抽象出待执行的动作以参数化某对象,你可用过程语言中的回调(call ...
- 【SQL Server高可用性】数据库复制:SQL Server 2008R2中数据库复制
经常在论坛中看到有人问数据同步的技术,如果只是同步少量的表,那么可以考虑使用链接服务器+触发器,来实现数据同步,但当要同步的数据表比较多,那么可以考虑用数据库复制技术,来实现数据的同步. 一.使用场景 ...
- windows下的IO模型之事件选择(WSAEventSelect)模型
异步选择模型类似的是,它也允许应用程序在一个或多个套接字上,接收以事件为基础的网络事件通知.对于异步选择模型采用的网络事件来说,它们均可原封不动地移植到事件选择模型.事件选择模型和异步选择模型最主要的 ...