from TotOnline import TotOnline from StartUpTest import StartUPTest class Main: def __init__(self): print("Main class instantiated") if __name__ == "__main__": filename = "resources/Pi_ausgabe_2mal_TimeInSeconds_0_40_asTXT (1).txt" with open(filename, "rb") as f: binary_data = f.read().strip() filename = "resources/Pi_ausgabe_2mal_TimeInSeconds_0_40_asTXT (1).txt" with open(filename, "rb") as f: binary_data2 = f.read().strip() # Example byte sequence representing binary data byte_data = bytes([0b11010001, 0b11000010, 0b11010100, 0b00110110, 0b10010100, 0b11100100, 0b10111111, 0b01000010, 0b01100011, 0b00111000, 0b00100110, 0b10001110, 0b11101000, 0b11100100, 0b10000001, 0b10011011, 0b01111011, 0b11101001, 0b00011010, 0b01001110, 0b00001111, 0b01000010, 0b11111001, 0b10110100, 0b10100000, 0b11101001, 0b00001100, 0b11001011, 0b11101100, 0b01101111, 0b10111000, 0b10010110, 0b11000101, 0b01000101, 0b10101011, 0b01001001, 0b00001100, 0b10010001, 0b11000100, 0b00101000, 0b11010101, 0b10001111, 0b00001000, 0b11000011, 0b10111110, 0b11110111, 0b01001110, 0b11100010, 0b10100000, 0b00001110, 0b00100101, 0b01111111, 0b01111010, 0b10101110, 0b10010110, 0b10101101, 0b01101110, 0b01010011, 0b10000100, 0b00011001, 0b01101110, 0b11000100, 0b11100010]) print(byte_data) # Call the StarUpTest print("StartUp:") result = StartUPTest.monobit_test(byte_data) print("p_value:", result[0]) print("test passed (p_value >= 0.01):", result[1]) # result = StartUPTest.autocorrelation_test(binary_data2) # print("Z_tau:", result[0]) # print("test passed (Z_tau > 2326 and Z_tau < 2674):", result[1]) result = StartUPTest.chi_square(byte_data) print("p_value:", result[0]) print("test passed (p_value >= 0.01):", result[1]) print("Chi2_statistic", result[2]) # Call the TotalFailure-Test print("Total Failure:") result = TotOnline.total_failure_test(byte_data, pattern_length=10) print("p_value:", result[0]) print("test passed (p_value >= 0.01):", result[1]) # Call the Online Test print("Monobit:") result = TotOnline.monobit_test(byte_data) print("p_value:", result[0]) print("test passed (p_value >= 0.01):", result[1]) print("Block Frequency:") result = TotOnline.block_frequency_test(byte_data) print("p_value:", result[0]) print("test passed (p_value >= 0.01):", result[1]) print("Run:") result = TotOnline.run_test(byte_data) print("p_value:", result[0]) print("test passed (p_value >= 0.01):", result[1]) print("Longest Run:") result = TotOnline.longest_one_block_test(byte_data) print("p_value:", result[0]) print("test passed (p_value >= 0.01):", result[1])