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第七章读书笔记
Vim编辑器 Vim 仅仅通过键盘来在插入和执行命令等多种模式之间切换.这使得Vim可以不用进行菜单或者鼠标操作,并且最小化组合键的操作,对文字录入员或者程序员可以大大增强速度和效率. CHAPTER ...
- 彻底搞懂DOM事件处理(零)引子
通过合理使用JavaScript,可以为网站用户提供更好的交互体验.这主要是因为JavaScript能够让网站对用户的各种操作及时做出"反馈".这种"反馈"使网 ...
- 编译 Tensorflow 1.10 + CUDA9.2 + MKL【转】
本文转自:https://www.solarck.com/compile-tensorflow-gpu.html 我的电脑系统是基于 Archlinux 的 Manjaro,软件包更新的比较激进,很早 ...
- 将vi打造成IDE
一.环境 发行版:Ubuntu 18.04 LTS 代号:bionic 内核版本:4.15.0-33-generic 二.步骤 2.1 准备工作 sudo apt-get install python ...
- office的project的激活码
8XWTK-7DBPM-B32R2-V86MX-BTP8PMVR3D-9XVBT-TBWY8-W3793-FR7C326K3G-RGBT2-7W74V-4JQ42-KHXQWD4HF2-HMRGR-R ...
- python 随机整数
# Program to generate a random number between and # import the random module import random print(ran ...
- 递归--练习9--noi8758 2的幂次方表示
递归--练习9--noi8758 2的幂次方表示 一.心得 找准子问题就好 二.题目 8758:2的幂次方表示 总时间限制: 1000ms 内存限制: 65536kB 描述 任何一个正整数都可以用 ...
- rails安装使用版本控制器的原因。
使用版本控制器的原因: 你没有系统根权限,所以你没有别的选择 你想要分开运行几个rails 系统 ,并且这几个rails有不同的Ruby版本.使用RVM就可以轻松做到. 没有什么新鲜的先安装xcode ...
- Gitea docker-compose.yaml
docker-compose.yaml version: "2" networks: gitea: external: false services: server: image: ...
- idea中解决Git反复输入代码的问题
打开git终端,或者idea中的插件终端,输入命令: git config --global credential.helper store 借用一下别人的图不要介意哈.......... 执行上述命 ...