Skip to content

Instantly share code, notes, and snippets.

@cr5315
Last active August 29, 2015 14:05
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 cr5315/04c28bdef59e83e038bf to your computer and use it in GitHub Desktop.
Save cr5315/04c28bdef59e83e038bf to your computer and use it in GitHub Desktop.
Sort addresses from vanitygen into folders with the address/privkey in a text file and a QR code
# Requires Pillow and qrcode
# pip install Pillow qrcode
from qrcode import *
from PIL import Image
import os
import errno
def make_data(vanitygen_output_file):
# Each address from vanitygen takes three lines
# The first line is the pattern, which we don't care about
# The second line is the address
# The third line is the privkey
count = 0
addresses = []
try:
with open(vanitygen_output_file, "r") as f:
for index, line in enumerate(f):
if count == 1:
addresses.append(line)
elif count == 2:
# We have what we need for this address
address = addresses[len(addresses) - 1]
address = address[address.find(" ") + 1:].rstrip()
privkey = line[line.find(" ") + 1:].rstrip()
try:
os.makedirs(address)
except OSError as exception:
if exception.errno != errno.EEXIST:
raise
make_txt(address, privkey)
make_qr_code(address)
count = -1
# end if
count += 1
print "Processed %d addresses." % len(addresses)
except:
print "There was an error."
def make_txt(address, privkey):
with open("%s/%s.txt" % (address, address), "w") as f:
f.write(address + "\n")
f.write(privkey + "\n")
def make_qr_code(address):
qr = QRCode(version=5, error_correction=ERROR_CORRECT_L)
qr.add_data(address)
qr.make()
im = qr.make_image()
return im.save("%s/%s.png" % (address, address))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment