Skip to content

Instantly share code, notes, and snippets.

@arrowrowe
Last active November 26, 2017 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arrowrowe/b4d04f2233a7a070eaec1ff6eb24e4ec to your computer and use it in GitHub Desktop.
Save arrowrowe/b4d04f2233a7a070eaec1ff6eb24e4ec to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from pyqrcode import QRCode
import json
import sys
import base64
def load_json(path):
with open(path, 'r') as r:
return json.loads(r.read())
def to_qrcode(text, white=u'\u2588\u2588', black=' ', quiet=1):
return (QRCode(text).text(quiet)
.replace('0', white)
.replace('1', black))
def to_link(method, password, server, server_port, **kwargs):
return 'ss://' + base64.b64encode(('%s:%s@%s:%s' % (method, password, server, server_port)).encode()).decode()
def main(path):
link = to_link(**load_json(path))
print(link)
print(to_qrcode(link))
if __name__ == '__main__':
main(*sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment