@staticmethod<EOL><INDENT>def key56_to_key64(key):<DEDENT>
if len(key) != <NUM_LIT:7>:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>" % len(key))<EOL><DEDENT>new_key = b"<STR_LIT>"<EOL>for i in range(<NUM_LIT:0>, <NUM_LIT:8>):<EOL><INDENT>if i == <NUM_LIT:0>:<EOL><INDENT>new_value = struct.unpack("<STR_LIT:B>", key[i:i+<NUM_LIT:1>])[<NUM_LIT:0>]<EOL><DEDENT>elif i == <NUM_LIT:7>:<EOL><INDENT>new_value = struct.unpack("<STR_LIT:B>", key[<NUM_LIT:6>:<NUM_LIT:7>])[<NUM_LIT:0>]<EOL>new_value = (new_value << <NUM_LIT:1>) & <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>new_value = struct.unpack("<STR_LIT:B>", key[i - <NUM_LIT:1>:i])[<NUM_LIT:0>]<EOL>next_value = struct.unpack("<STR_LIT:B>", key[i:i + <NUM_LIT:1>])[<NUM_LIT:0>]<EOL>new_value = ((new_value << (<NUM_LIT:8> - i)) & <NUM_LIT>) | next_value >> i<EOL><DEDENT>new_value = new_value & ~(<NUM_LIT:1> << <NUM_LIT:0>)<EOL>new_value = new_value | int(not DES.bit_count(new_value) & <NUM_LIT>)<EOL>new_key += struct.pack("<STR_LIT:B>", new_value)<EOL><DEDENT>return new_key<EOL>
This takes in an a bytes string of 7 bytes and converts it to a bytes
string of 8 bytes with the odd parity bit being set to every 8 bits,

For example

b"\x01\x02\x03\x04\x05\x06\x07"
00000001 00000010 00000011 00000100 00000101 00000110 00000111

is converted to

b"\x01\x80\x80\x61\x40\x29\x19\x0E"
00000001 10000000 10000000 01100001 01000000 00101001 00011001 00001110

https://crypto.stackexchange.com/questions/15799/des-with-actual-7-byte-key

:param key: 7-byte string sized key
:return: 8-byte string with the parity bits sets from the 7-byte string