Skip to content

Instantly share code, notes, and snippets.

@jchysk
Created August 26, 2015 23:20
Show Gist options
  • Save jchysk/7f7a044e93b4925123f7 to your computer and use it in GitHub Desktop.
Save jchysk/7f7a044e93b4925123f7 to your computer and use it in GitHub Desktop.
Secret to QR Code
"""
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