You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
650 B
25 lines
650 B
from cryptography_s_des_exploring.sdes.sdes import apply_table, left_shift, p8_table, p10_table
|
|
|
|
|
|
def generate_subkeys(key: str):
|
|
"""
|
|
Returns generated two subkeys: K1, K2 - from the 10-bit key
|
|
|
|
key is a binary which represented with a 10 character string.
|
|
"""
|
|
|
|
temp = apply_table(key, p10_table)
|
|
left = temp[:5]
|
|
right = temp[5:]
|
|
left = left_shift(left)
|
|
right = left_shift(right)
|
|
key1 = apply_table(left + right, p8_table)
|
|
left = left_shift(left)
|
|
right = left_shift(right)
|
|
left = left_shift(left)
|
|
right = left_shift(right)
|
|
key2 = apply_table(left + right, p8_table)
|
|
|
|
return key1, key2
|
|
|