in otp.py [0:0]
def to_words(value):
"Convert a 64-bit value into words, with a parity value."
assert len(value) == 8 # 64 bits, in an 8-byte VALUE
# Parity is the summation of each 2-bit pair. We will mask
# out the lowest 2 bits, so no worries about higher bits.
parity = sum((b >> 6) + (b >> 4) + (b >> 2) + b for b in value)
# collapse the bytes into a single 64-bit integer; fold in parity bits
i64 = int.from_bytes(value, byteorder='big')
i64 = (i64 << 2) | (parity & 0x03)
# and map that integer into words, using the spec's WORDS
return [WORDS[(i64 >> (i*11)) & 0x7FF] for i in (5, 4, 3, 2, 1, 0)]