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. “System.Runtime.InteropServices.COMException (0x80070422): 无法启动服务”解决方法

    应用程序中发生了无法处理的异常.如果单击“退出”,应用程序将立即关闭.无法启动服务,原因可能是已被禁用或其相关联设备没有启动.(异常来自HRESULT:0X80070422).点击详细内容:有关调用实 ...

  2. HDU4642

    #include<stdio.h> #include<string.h> int main() { int i,j,n,m; int t; scanf("%d&quo ...

  3. Activiti工作流引擎简介

    Activiti工作流引擎简介 一.概述 Activiti是由Alfresco软件在2010年5月17日发布的业务流程管理(BPM)框架,它是覆盖了业务流程管理,工作流,服务协作等领域的一个开源,灵活 ...

  4. POJ 2407 Relatives(欧拉函数)

    http://poj.org/problem?id=2407 题意: 给出一个n,求小于等于的n的数中与n互质的数有几个. 思路: 欧拉函数的作用就是用来求这个的. #include<iostr ...

  5. 总结关于express vue-cli

    零零散散,拼起来,花了不少时间,这回把一些东西拼一下吧,免得到时又得重头开始,Blog还没弄好,打算用这些重新写一个,稍接不上,就落后了,这是技术,技术是不断更新换代的,明天这个框架,可以后天就有一个 ...

  6. spark 都用了哪些开源东东

    直接上干货 commons-cli http://www.ibm.com/developerworks/cn/java/j-lo-commonscli/ guava http://www.cnblog ...

  7. Linux 常用环境搭建

    已有环境 python 2.6.6 jdk 1.7 —tomcat— —jenkins— —jq— —Python 2.7— —pip— —PIL— —Android SDK— —yum or apt ...

  8. PHP--------微信网页开发实现微信扫码功能

    今天说说微商城项目中用到的扫一扫这个功能,分享一下,希望对各位有所帮助. 前提:要有公众号,和通过微信认证,绑定域名,得到相应信息,appid,appsecret等. 微信开发文档:https://m ...

  9. error processing package oracle-java8-installer问题解决

    ubuntu通过ppa源安装jdk时遇到如下问题: download failedOracle JDK 8 is NOT installed.dpkg: error processing packag ...

  10. (C#基础)深浅拷贝理解

    一方面感觉实在无趣,不知道做什么了,纯粹来个打字练习,于是有了这个. 二方面深感自己C#基础之薄弱,于是对着园友的文章一边看,一边练习,因为很多次看了,没有多久就忘了,还有练习过程中会出现一些问题,这 ...