From 97d833349c888c152ed84a6c201c89d161282498 Mon Sep 17 00:00:00 2001 From: Patrick Mueller Date: Fri, 22 Oct 2021 12:43:19 +0200 Subject: [PATCH] #10: Adding missing method docs --- chapter_three/Lineares-Schieberegister.py | 10 +++++++++- utils/CipherUtils.py | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/chapter_three/Lineares-Schieberegister.py b/chapter_three/Lineares-Schieberegister.py index 6acb1f2..d212828 100644 --- a/chapter_three/Lineares-Schieberegister.py +++ b/chapter_three/Lineares-Schieberegister.py @@ -5,7 +5,15 @@ INIT_STATE = [0, 1, 1, 0] COEFFICIENTS = [1, 1, 1, 0] -def create_shift_register(init_state: list, coefficients: list): +def create_shift_register(init_state: [int], coefficients: [int]) -> [int]: + """ + Creates and returns the maximum bit stream for the given input state via a linear shift register. + Especially the coefficients are important as choosing the correct ones for any given shift register length + will provide the maximum amount of bits before they repeat + :param init_state: The initial bits in the shift register + :param coefficients: The coefficients of every field in the shift register + :return: The maximum length bit stream generated by the linear shift register + """ return_list = [] current_state = init_state.copy() current_state_list = [current_state.copy()] diff --git a/utils/CipherUtils.py b/utils/CipherUtils.py index 2671530..bebc63e 100644 --- a/utils/CipherUtils.py +++ b/utils/CipherUtils.py @@ -93,7 +93,15 @@ def shift_char(char, incrementation: int = 1): return str(new_char_in_bytes)[2] -def xor_two_lists(clear_list, key_list): +def xor_two_lists(clear_list: [int], key_list: [int]) -> [int]: + """ + XORs every element of the first given list with the corresponding element of the 2nd list. + If the 2nd list is shorter than the first one, the XORing starts at the first element of the + 2nd list again once all elements have been used and so on. + :param clear_list: The first list + :param key_list: The second list. This list may be shorter or longer than the first one, doesn't matter + :return: A list containing the XORed elements. + """ xored_list = [] for x in range(len(clear_list)):