diff --git a/thesethreewords.py b/thesethreewords.py index 357423d..b3d8c2d 100644 --- a/thesethreewords.py +++ b/thesethreewords.py @@ -165,7 +165,7 @@ class WordHasher(object): return N - def to_rugbits(self, integer): + def to_rugbits_old(self, integer): """Convert a 45bit `integer` to a list of 3rugbits A rugbit is like a byte but with 15bits instead of eight. @@ -176,6 +176,17 @@ class WordHasher(object): integer & fifteen_bits] return rugbits + def to_rugbits(self, integer): + """Convert a 45bit `integer` to a list of 3rugbits + + A rugbit is like a byte but with 15bits instead of eight. + """ + fifteen_bits = 0b111111111111111 + rugbits = [(integer >> 30) & fifteen_bits, + (integer >> 15) & fifteen_bits, + integer & fifteen_bits] + return rugbits + def rugbits_to_int(self, rugbits): """Convert a list of `rugbits` to an integer""" assert len(rugbits) == 3