Browse files

inflate_code_string now deals with new packing

  • Loading branch information...
1 parent eec42cb commit 430711184cb9a5ab8ad354b905f0492cf80a68f5 Brian Whitman committed May 22, 2011
Showing with 2 additions and 2 deletions.
  1. +2 −2 API/fp.py
View
4 API/fp.py
@@ -57,7 +57,7 @@ def match(self):
def inflate_code_string(s):
""" Takes an uncompressed code string consisting of 0-padded fixed-width
sorted hex and converts it to the standard code string."""
- n = int(len(s) / 13.0) # 8 bytes for hash, 5 bytes for time
+ n = int(len(s) / 10.0) # 5 hex bytes for hash, 5 hex bytes for time (40 bits)
def pairs(l, n=2):
"""Non-overlapping [1,2,3,4] -> [(1,2), (3,4)]"""
@@ -73,7 +73,7 @@ def pairs(l, n=2):
# Parse out n groups of 5 timestamps in hex; then n groups of 8 hash codes in hex.
end_timestamps = n*5
times = [int(''.join(t), 16) for t in pairs(s[:end_timestamps], 5)]
- codes = [int(''.join(t), 16) for t in pairs(s[end_timestamps:], 8)]
+ codes = [int(''.join(t), 16) for t in pairs(s[end_timestamps:], 5)]
assert(len(times) == len(codes)) # these should match up!
return ' '.join('%d %d' % (c, t) for c,t in zip(codes, times))

0 comments on commit 4307111

Please sign in to comment.