Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Complexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def linear_complexity_test(binary_data:str, verbose=False, block_size=500):

return (p_value, (p_value >= 0.01))
else:
return (-1.0, False)
return (0.0, False, 'Error: Not enough data to run this test. Minimum input length is {} bits (2 blocks of {}).'.format(2 * block_size, block_size))

@staticmethod
def berlekamp_massey_algorithm(block_data):
Expand Down
2 changes: 1 addition & 1 deletion Matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ def binary_matrix_rank_text(binary_data:str, verbose=False, rows_in_matrix = 32,

return (p_value, (p_value >= 0.01))
else:
return (-1.0, False)
return (0.0, False, 'Error: Not enough data to run this test. Minimum input length is 1024 bits (32x32 matrix).')
4 changes: 4 additions & 0 deletions RandomExcursions.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def random_excursions_test(binary_data:str, verbose=False, state=1):
cycles.append(cumulative_sum[position[pos]:position[pos + 1] + 1])
num_cycles = len(cycles)

if num_cycles == 0:
states = ['-4', '-3', '-2', '-1', '+1', '+2', '+3', '+4']
return [(states[i], x_values[i], 0.0, 0.0, False) for i in range(len(x_values))]

state_count = []
for cycle in cycles:
# Determine the number of times each cycle visits each state
Expand Down
4 changes: 4 additions & 0 deletions Spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def spectral_test(binary_data:str, verbose=False):
:return: (p_value, bool) A tuple which contain the p_value and result of frequency_test(True or False)
"""
length_of_binary_data = len(binary_data)

if length_of_binary_data < 1000:
return (0.0, False, 'Error: Not enough data to run this test. Minimum input length is 1000 bits.')

plus_one_minus_one = []

# Step 1 - The zeros and ones of the input sequence (ε) are converted to values of –1 and +1
Expand Down
8 changes: 8 additions & 0 deletions TemplateMatching.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def non_overlapping_test(binary_data:str, verbose=False, template_pattern='00000

length_of_binary = len(binary_data)
pattern_size = len(template_pattern)

if length_of_binary < block * pattern_size:
return (0.0, False, 'Error: Not enough data to run this test. Minimum input length is {} bits.'.format(block * pattern_size))

block_size = floor(length_of_binary / block)
pattern_counts = zeros(block)

Expand Down Expand Up @@ -89,6 +93,10 @@ def overlapping_patterns(binary_data:str, verbose=False, pattern_size=9, block_s
:return: (p_value, bool) A tuple which contain the p_value and result of frequency_test(True or False)
"""
length_of_binary_data = len(binary_data)

if length_of_binary_data < block_size:
return (0.0, False, 'Error: Not enough data to run this test. Minimum input length is {} bits.'.format(block_size))

pattern = ''
for count in range(pattern_size):
pattern += '1'
Expand Down
Loading