Skip to content

Instantly share code, notes, and snippets.

@nelsnelson
Created February 19, 2011 08:49
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 nelsnelson/834938 to your computer and use it in GitHub Desktop.
Save nelsnelson/834938 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
from sys import argv
from string import ascii_letters
from string import digits
from random import choice
from re import findall
n=int(argv[1]); charset=list(ascii_letters+digits+" ")
def generate(n):
return [' '.join(findall(".{2}", ''.join([choice(charset) for x in xrange(17)]).encode("hex"))) for i in xrange(n)]
def decode(samples):
return [''.join([chr(int(x, 16)) for x in a.split()]) for a in samples]
samples = generate(n)
result = decode(samples)
if len(argv) < 2 or argv[2] != "-q":
for s in result:
print s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment