aktualisierter Code

main
Gideon Regehr 2023-05-16 13:46:08 +02:00
parent e29ec9edc8
commit 16234d6bcc
1 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,59 @@
from TotOnline import TotOnline
from StartUpTest import StartUPTest
class Main:
def __init__(self):
print("Main class instantiated")
if __name__ == "__main__":
filename = "resources/data2.txt"
with open(filename, "rb") as f:
binary_data = f.read().strip()
filename = "resources/data2.txt"
with open(filename, "rb") as f:
byte_data = f.read().strip()
# 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.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])