Skip to content

Instantly share code, notes, and snippets.

@jclement
Created April 29, 2013 20:54
Show Gist options
  • Select an option

  • Save jclement/5484698 to your computer and use it in GitHub Desktop.

Select an option

Save jclement/5484698 to your computer and use it in GitHub Desktop.
Crappy code to split a GPG key in 3 giant QR codes
#!/usr/bin/env python
import os
import sys
LINE_COUNT =40
def dumpLines(basename, segment, lines):
fn ='%s_%02d.png' % (basename, segment)
print fn
f = os.popen("qrencode -o \"%s\" " % fn,'w')
f.write("%02d\n" % segment)
for ln in lines:
f.write(ln.strip() + "\n")
f.close();
return fn;
if __name__=='__main__':
if len(sys.argv) <> 2:
print "Syntax: %s outfile << strings" % sys.argv[0]
basename = sys.argv[1]
lines = sys.stdin.readlines()
seg = 0
f = open(basename + '.html','w')
f.write('<html><body>')
while len(lines) > 0:
seg = seg +1;
chunk = lines[:LINE_COUNT]
lines = lines[LINE_COUNT:]
fn = dumpLines(basename, seg, chunk);
f.write('<img src="%s" /><br/>' % fn);
f.write('</body></html>')
f.close();
@jclement
Copy link
Copy Markdown
Author

Note: Having difficulty scanning these QR codes. Likely more smaller QR codes would work better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment