an die Verwendung von Bytes angepasst

main
Gideon Regehr 2023-05-15 15:41:17 +02:00
parent 4f6e19311a
commit d7a618064f
1 changed files with 19 additions and 10 deletions

View File

@ -17,41 +17,50 @@ if __name__ == "__main__":
with open(filename, "rb") as f: with open(filename, "rb") as f:
binary_data2 = f.read().strip() 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 # Call the StarUpTest
print("StartUp:") print("StartUp:")
result = StartUPTest.monobit_test(binary_data2) result = StartUPTest.monobit_test(byte_data)
print("p_value:", result[0]) print("p_value:", result[0])
print("test passed (p_value >= 0.01):", result[1]) print("test passed (p_value >= 0.01):", result[1])
result = StartUPTest.autocorrelation_test(binary_data2) # result = StartUPTest.autocorrelation_test(binary_data2)
print("Z_tau:", result[0]) # print("Z_tau:", result[0])
print("test passed (Z_tau > 2326 and Z_tau < 2674):", result[1]) # 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 # Call the TotalFailure-Test
print("Total Failure:") print("Total Failure:")
result = TotOnline.total_failure_test(binary_data, pattern_length=10) result = TotOnline.total_failure_test(byte_data, pattern_length=10)
print("p_value:", result[0]) print("p_value:", result[0])
print("test passed (p_value >= 0.01):", result[1]) print("test passed (p_value >= 0.01):", result[1])
# Call the Online Test # Call the Online Test
print("Monobit:") print("Monobit:")
result = TotOnline.monobit_test(binary_data) result = TotOnline.monobit_test(byte_data)
print("p_value:", result[0]) print("p_value:", result[0])
print("test passed (p_value >= 0.01):", result[1]) print("test passed (p_value >= 0.01):", result[1])
print("Block Frequency:") print("Block Frequency:")
result = TotOnline.block_frequency_test(binary_data) result = TotOnline.block_frequency_test(byte_data)
print("p_value:", result[0]) print("p_value:", result[0])
print("test passed (p_value >= 0.01):", result[1]) print("test passed (p_value >= 0.01):", result[1])
print("Run:") print("Run:")
result = TotOnline.run_test(binary_data) result = TotOnline.run_test(byte_data)
print("p_value:", result[0]) print("p_value:", result[0])
print("test passed (p_value >= 0.01):", result[1]) print("test passed (p_value >= 0.01):", result[1])
print("Longest Run:") print("Longest Run:")
result = TotOnline.longest_one_block_test(binary_data) result = TotOnline.longest_one_block_test(byte_data)
print("p_value:", result[0]) print("p_value:", result[0])
print("test passed (p_value >= 0.01):", result[1]) print("test passed (p_value >= 0.01):", result[1])