Go to file
Leopere b26cd18579
Make health endpoint lightweight (no camera open)
Health check no longer opens the camera — it just confirms the server
is running. This prevents blocking when the camera is in use by a
concurrent request or the background startup test.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-15 11:53:14 -05:00
man Camera TRNG: webcam-based true random number generator 2026-02-05 15:46:26 -05:00
scripts Add auto-update on restart, upgrade script, and camera-only tests 2026-02-15 11:16:29 -05:00
src Make health endpoint lightweight (no camera open) 2026-02-15 11:53:14 -05:00
.cursorignore Camera TRNG: webcam-based true random number generator 2026-02-05 15:46:26 -05:00
.gitignore Polish: camera-only entropy, cleaner output, complete docs 2026-02-15 11:08:13 -05:00
.woodpecker.yml bump 2026-02-15 10:27:27 -05:00
Cargo.lock Replace pool with on-demand live camera entropy 2026-02-15 11:47:09 -05:00
Cargo.toml Replace pool with on-demand live camera entropy 2026-02-15 11:47:09 -05:00
Dockerfile Fix Dockerfile build and remove camera device requirement 2026-02-14 21:21:45 -05:00
LICENSE Camera TRNG: webcam-based true random number generator 2026-02-05 15:46:26 -05:00
README.md Polish: camera-only entropy, cleaner output, complete docs 2026-02-15 11:08:13 -05:00
RESEARCH.md Polish: camera-only entropy, cleaner output, complete docs 2026-02-15 11:08:13 -05:00
TECHNICAL.md bump 2026-02-15 10:27:27 -05:00
docker-compose.yml Polish: camera-only entropy, cleaner output, complete docs 2026-02-15 11:08:13 -05:00
openssl-camera-qrng.cnf Camera TRNG: webcam-based true random number generator 2026-02-05 15:46:26 -05:00
skill.md Polish: camera-only entropy, cleaner output, complete docs 2026-02-15 11:08:13 -05:00

README.md

Camera TRNG

TL;DR: Turn any webcam into a true random number generator. Cover the lens, run the server, get random bytes.

What is this?

Your webcam generates electrical noise even when the lens is covered. This noise comes from quantum effects in the sensor. This tool captures that noise and turns it into random numbers - the same approach used by LavaRnd.

Quick Start

1. Install

# Clone and build
git clone https://git.nixc.us/colin/camera-trng.git
cd camera-trng
cargo build --release

2. Cover Your Camera Lens

Use tape, a lens cap, or put the camera in a dark box. The camera should see nothing but blackness.

3. Run

macOS (native camera access via AVFoundation):

./scripts/run-mac.sh

Linux (native):

./target/release/camera-qrng

Linux (Docker with camera device):

docker compose up -d

Server starts at http://localhost:8787

Start with the OS (macOS LaunchAgent):

./scripts/install-launchagent.sh

Runs the compiled binary at login and keeps it running. Logs go to logs/. To remove: ./scripts/uninstall-launchagent.sh.

4. Get Random Bytes

# Get 32 random bytes (hex)
curl "http://localhost:8787/random?bytes=32&hex=true"

# Get 1KB of raw random data
curl "http://localhost:8787/random?bytes=1024" -o random.bin

# Continuous stream
curl -N "http://localhost:8787/stream"

Is it actually random?

Yes. This tool passes all NIST SP 800-22 statistical tests for randomness:

# Run the built-in test suite
./scripts/test-randomness.py --server http://localhost:8787

The output is cryptographic quality - suitable for generating encryption keys, secure tokens, etc.

API

Endpoint Description
GET /random?bytes=N Get N random bytes (max 1MB)
GET /random?bytes=N&hex=true Get N random bytes as hex string
GET /stream Continuous stream of random bytes
GET /stream?bytes=N Stream exactly N bytes then stop
GET /dice?d=6&count=3 Roll quantum-random dice
GET /password?length=24 Generate quantum-random password
GET /coin Quantum coin flip
GET /8ball?question=... Quantum Magic 8 Ball
GET /cameras List available camera devices
GET /health Health check with pool stats
GET /docs API documentation page
GET /.well-known/mcp.json MCP discovery endpoint

Troubleshooting

macOS "Camera in use" error:

./scripts/release-camera.sh
./scripts/run-mac.sh

Docker on macOS: Docker on Mac runs Linux containers and cannot access the Mac camera. Use ./scripts/run-mac.sh instead.

Docker on Linux (explicit device):

docker run -d --device /dev/video0 -p 8787:8787 camera-trng

More Info

  • TECHNICAL.md - Full API docs, CI/CD, configuration options
  • RESEARCH.md - The science behind camera-based random number generation

License

CC-BY 4.0. See LICENSE.