Created
August 26, 2015 23:20
-
-
Save jchysk/7f7a044e93b4925123f7 to your computer and use it in GitHub Desktop.
Secret to QR Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Function that takes two values to generate a QR Code that can be scanned with LaunchKey or TOTP holder | |
@param identity: Name and place. E.g. username/Gmail | |
@param secret: The actual TOTP code | |
Saves the image locally as a png | |
Requires PIL (pillow) and qrcode | |
""" | |
def convert(self, identity, secret): | |
import re | |
import qrcode | |
name = re.sub('[^0-9a-zA-Z]+', '_', identity) | |
print name | |
img = qrcode.make("otpauth://totp/" + identity + "?secret=" + secret) | |
img.save(name + ".png") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment