auth.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:deb-python-autobahn 作者: openstack 项目源码 文件源码
def qrcode_from_totp(secret, label, issuer):
    if type(secret) != six.text_type:
        raise Exception('secret must be of type unicode, not {}'.format(type(secret)))

    if type(label) != six.text_type:
        raise Exception('label must be of type unicode, not {}'.format(type(label)))

    try:
        import pyqrcode
    except ImportError:
        raise Exception('pyqrcode not installed')

    import io
    buffer = io.BytesIO()

    data = pyqrcode.create(u'otpauth://totp/{}?secret={}&issuer={}'.format(label, secret, issuer))
    data.svg(buffer, omithw=True)

    return buffer.getvalue()


#
# The following code is adapted from the pbkdf2_bin() function
# in here https://github.com/mitsuhiko/python-pbkdf2
# Copyright 2011 by Armin Ronacher. Licensed under BSD license.
# https://github.com/mitsuhiko/python-pbkdf2/blob/master/LICENSE
#
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号