-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_entropy_rng.py
More file actions
50 lines (36 loc) · 1.33 KB
/
test_entropy_rng.py
File metadata and controls
50 lines (36 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
"""
Test script for entropy RNG - generates 5 random numbers and exits
"""
import time
from entropy_rng import EntropyRNG
def test_rng():
print("Testing Entropy-based Random Number Generator")
print("=" * 50)
rng = EntropyRNG()
try:
# Start entropy collection
print("Starting entropy collection...")
rng.start_entropy_collection()
print("Collecting entropy from CPU scheduler...")
print("(Note: Mouse movement would add more entropy)")
# Wait for sufficient entropy
while True:
status = rng.get_entropy_status()
total_samples = status['total_samples']
print(f"Entropy samples: {total_samples}")
if total_samples >= 50:
print("Sufficient entropy collected!")
break
time.sleep(0.5)
# Generate test numbers
print("\nGenerating 5 test random numbers:")
print("-" * 30)
for i in range(5):
random_num = rng.generate_random_number()
print(f"Random number {i+1}: {random_num}")
print("\nTest completed successfully!")
finally:
rng.stop_entropy_collection()
if __name__ == "__main__":
test_rng()