Skip to content

Instantly share code, notes, and snippets.

@nmathewson
Created April 9, 2014 20:10
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 nmathewson/10309480 to your computer and use it in GitHub Desktop.
Save nmathewson/10309480 to your computer and use it in GitHub Desktop.
import binascii
bad_keys = set()
for line in open("vk.txt"):
fp = line.split(",")[2].strip()
bad_keys.add(binascii.a2b_hex(fp.lower()))
bad = None
bw_bad = bw_good = n_bad = n_good = 0
for line in open("mc.txt"):
if line.startswith('r '):
k = binascii.a2b_base64(line.split()[2] + "=")
bad = (k in bad_keys)
if bad:
n_bad += 1
else:
n_good += 1
if line.startswith('w Bandwidth='):
bw = int(line[len('w Bandwidth='):].split()[0])
if bad is None:
print "WTF"
elif bad:
bw_bad += bw
else:
bw_good += bw
bad = None
print "n_bad = %d/%d == %d%%."%(n_bad, n_good+n_bad, (n_bad*100.0)/(n_good+n_bad))
print "bw_bad = %d/%d == %d%%."%(bw_bad, bw_good+bw_bad, (bw_bad*100.0)/(bw_good+bw_bad))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment