Consolidate scripts, add requirements.txt, remove dead files

Remove entropy-rng-cam.py and entropy-rng-opencv.py, which were
superseded by entropy.py (args, loop mode, DRBG) and carried the same
unused-entropy bug. Remove the empty 0-byte `file`. Add requirements.txt
with pinned opencv and the FastAPI stack for the upcoming API stage.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Radek
2026-09-02 11:25:20 +01:00
parent 8ac9ab92eb
commit ab70195a07
4 changed files with 5 additions and 74 deletions
-47
View File
@@ -1,47 +0,0 @@
import hashlib
import requests
from io import BytesIO
from PIL import Image
import secrets
def fetch_single_frame(url):
response = requests.get(url, stream=True)
boundary = b'--myboundary'
data = b''
in_frame = False
frame_data = b''
for chunk in response.iter_content(chunk_size=1024):
data += chunk
if not in_frame and boundary in data:
in_frame = True
data = data.split(boundary, 1)[1]
if in_frame and b'Content-Type: image/jpeg' in data:
parts = data.split(b'\r\n\r\n', 1)
if len(parts) > 1:
frame_part = parts[1]
if b'\r\n--myboundary' in frame_part:
frame_data = frame_part.split(b'\r\n--myboundary', 1)[0]
try:
return Image.open(BytesIO(frame_data))
except Exception as e:
print(f"Error processing frame: {e}")
return None
raise ValueError("No valid frame found in the stream.")
def generate_random_numbers(frame, bit_lengths=[16, 32, 64, 128, 256]):
img_bytes = frame.resize((100, 100)).tobytes()
entropy = hashlib.sha256(img_bytes).digest()
# Use secrets.randbits directly
return {length: secrets.randbits(length) for length in bit_lengths}
url = "http://192.168.0.200/mjpg/video.mjpg"
try:
frame = fetch_single_frame(url)
if frame:
random_numbers = generate_random_numbers(frame)
for length, number in random_numbers.items():
print(f"{length}-bit random number: {hex(number)}")
else:
print("Failed to extract a valid frame.")
except Exception as e:
print(f"Error: {e}")
-27
View File
@@ -1,27 +0,0 @@
import cv2
import hashlib
import secrets
def fetch_frame_opencv(url):
cap = cv2.VideoCapture(url)
ret, frame = cap.read()
cap.release()
if not ret:
raise ValueError("Failed to fetch frame.")
return frame
def generate_random_numbers(frame, bit_lengths=[16, 32, 64, 128, 256]):
_, img_encoded = cv2.imencode('.jpg', frame)
img_bytes = img_encoded.tobytes()
entropy = hashlib.sha256(img_bytes).digest()
# Use secrets.randbits directly
return {length: secrets.randbits(length) for length in bit_lengths}
url = "http://192.168.0.200/mjpg/video.mjpg"
try:
frame = fetch_frame_opencv(url)
random_numbers = generate_random_numbers(frame)
for length, number in random_numbers.items():
print(f"{length}-bit random number: {hex(number)}")
except Exception as e:
print(f"Error: {e}")
View File
+5
View File
@@ -0,0 +1,5 @@
# Camera entropy source dependencies
opencv-python>=4.8,<5
# FastAPI stack for the entropy service (added in the API stage)
fastapi>=0.110
uvicorn[standard]>=0.29