Skip to main content

Entropy-based random generator using microphone audio to produce real random floats, integers, strings, and choices.

Project description

real-random

Pepy Total Downlods

real-random is a Python package that generates random values using real-world entropy from ambient microphone audio. It converts raw audio noise into cryptographic hashes, which are then transformed into useful random outputs such as:

  • Floating-point numbers in [0, 1)
  • Integers within a range
  • Random selections from sequences
  • Random alphanumeric strings

This provides a non-deterministic alternative to traditional pseudorandom generators.


Installation

pip install real-random

If you plan to build from source:

git clone https://github.com/croketillo/real-random
cd real-random
pip install .

Usage

from real_random import (
    real_random,
    real_random_int,
    real_random_float,
    real_random_choice,
    real_random_string,
)

print(real_random())                          # → 0.72623...
print(real_random_int(1, 10))                 # → 7
print(real_random_float(0.5, 2.5))            # → 1.934...
print(real_random_choice(["red", "blue"]))    # → "blue"
print(real_random_string(8))                  # → "aG9xB2dZ"

How It Works

Captures 1–2 seconds of microphone input (ambient noise).

Normalizes and hashes the audio using SHA-256.

Converts part of the hash into usable randomness.

Uses that base randomness to build higher-level utilities.

If no audio signal is detected (silence), it falls back to generated synthetic noise to ensure entropy.

Requirements

A working microphone or audio input device

Python 3.7+

sounddevice, numpy

On Linux, make sure your user has access to audio input devices (PulseAudio or PipeWire is recommended).

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

real_random-0.1.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

real_random-0.1.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file real_random-0.1.1.tar.gz.

File metadata

  • Download URL: real_random-0.1.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for real_random-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3634011f77f806cdef3eb4b129cf7169f0834224ebc56f28563f896fd71ea94d
MD5 fae04d79576fc85af3b6609e6819217d
BLAKE2b-256 2f9275aaf0a5af2d2b60b46675a182e32aa0f125fb048f0ed3afdea670f76664

See more details on using hashes here.

File details

Details for the file real_random-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: real_random-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for real_random-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 68c395b251cd596d57cc204c6c66a816bad1ae88f59bd56cf035e8746d533c41
MD5 ca091d486cf8ed96df6c2b2dd46e6cf1
BLAKE2b-256 48fbf8ae4ac4e9b6d01116c45bdfa06ccc906b16e4714291640ea1737866f84e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page