Skip to main content

The World's Fastest Random Generator v2

RandQuik v2 Benchmark Stats RandQuik running at full speed on a Macbook laptop, writing /dev/null.

I was disappointed with the sad state of random number generators. Many languages don't ship anything useful and some are stuck with whatever the OS provides. Most existing implementations are slow, often maxing out at a few hundred megabytes per second, which becomes a real bottleneck in high-throughput systems.

Secondly, flaws have been found in popular non-cryptographic algorithms such as Mersenne Twister and PCG-style generators. These issues range from detectable structure to repeating sequences, making them unsuitable for serious or long-running workloads.

The cryptographic alternative is simply better. Proper CSPRNGs avoid these pitfalls entirely and, on modern hardware, can now be faster than legacy non-cryptographic designs. There is little reason left to accept weaker guarantees for worse performance.

This version uses AEGIS, a modern authenticated encryption primitive that leverages AES hardware acceleration. AEGIS provides extremely high throughput while retaining strong cryptographic properties, significantly outperforming our legacy implementation and serving as an ideal foundation for a high-performance CSPRNG.

Quick start

Install UV and install the CLI tool with it:

uv tool install randquik

You can try how it performs on your machine and find the optimal parameters:

randquik --benchmark

Wipe an entire file without altering its size:

randquik -o sensitive.dat

Piping and redirection:

randquik --quiet | hexdump -C | head

Features

  • Blazing-fast CSPRNG built on AEGIS single or multithreaded
  • Deterministic seeding: same seed, same byte stream
  • Seekable random stream and file output
  • Flexible I/O: piping, files, and mmap
  • Built-in benchmarking and dry-run modes
  • Full screen console graphics for speed display

Below are the most important features with example commands.

Performance

You'll be looking at up to 100 GB/s raw generation speed, making this some orders of magnitude faster than your traditional random number generation. Single-threaded performance still is 10-20 times faster than other options that don't have threading.

Your output, e.g. writing a file, will always be the bottle neck, not your random generator, but modern SSDs allow up to 10 GB/s write speeds already.

Size units

Many options such as --len, --seek accept human-readable units. The table uses conventional, capitalized forms (e.g. KiB, MB), but you may write them in lower case and with or without the trailing B (for example 1m or 5gi).

SI unit Binary unit Meaning Bytes factor
100 — 100 bytes 1
1kB 1KiB Kilobyte / kibibyte 1_000 / 1_024
1MB 1MiB Megabyte / mebibyte 1_000_000 / 1_048_576
1GB 1GiB Gigabyte / gibibyte 1_000_000_000 / 1_073_741_824
1TB 1TiB Terabyte / tebibyte 1_000_000_000_000 / 1_099_511_627_776
1PB 1PiB Petabyte / pebibyte 1_000_... / 1_125_...
— 1sect Sectors of output device 512 (typical), 4096 (rarely)

Seeding for repeatable output

You can provide an explicit seed string, always providing the same output, which can be useful e.g. for memory/disk testing where the data needs to be read back and verified.

randquik -l 64MiB -s my-seed-string -o chunk.bin

If no seed is provided, a secure new random one is created and printed on console (unless hidden by -q).

Seekable random stream and output file

It is possible to seek to any byte position in the stream without delay.

  • --iseek: seek the input random stream
  • --oseek: seek in the output file
  • --seek: set both input and output to the same position

Example: resume as if 5 terabytes had already been written, and continue writing to out.dat. The seed from the prior invocation should be included:

randquik --seek 5T --len 1G -s a5Z8Ew1Hfc2VfEtY -o out.dat

Bytes prior to seek position are kept as they were while the file is expanded to fit all the data starting at five terabytes mark (using sparse allocation so it doesn't actually consume 5 terabytes).

Wipe a specific range of a disk or USB drive (using sector numbers e.g. from gdisk):

randquik -oseek 2048sect --len 100MiB -o /dev/sde

Benchmark and dry-run modes

Benchmark different modes and thread counts. Prints the options that perform the best on your system:

randquik --benchmark

To do a single run without actually writing anywhere, use --dry:

randquik --len 50GiB -t8 --dry

Legacy

The original implementation is preserved in the legacy git branch.

That version was once the fastest CSPRNG available, built around ChaCha20 with SIMD Assembly and C code written by me, making it faster than traditional algorithms without such optimizations and faster than the Linux kernel that also uses ChaCha20 to make random numbers. While historically significant, it has been greatly surpassed by the current AEGIS-based design in performance and features.

The legacy branch remains available for reference and benchmarking, but version 2 is the recommended implementation.

Metadata

Release files for randquik 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for randquik 2.1.0
File Size Uploaded Provenance Actions
randquik-2.1.0.tar.gz 33.5 kB Without provenance Details for randquik-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for randquik 2.1.0
File Interpreter ABI Platform Actions
randquik-2.1.0-py3-none-any.whl Python 3 none any Details for randquik-2.1.0-py3-none-any.whl

Total release size: 59.2 kB

Release files / randquik-2.1.0.tar.gz

Download URL randquik-2.1.0.tar.gz
Size 33.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2712e65f544681fc990ae2c0c25a265e85091025dcc1b7737f2430c37484b33c
BLAKE2b-256 checksum
How to use checksums
894ab0b71e1ee7b5cb9cb5777d05119d1a6a950c104faa215422d335da6aee32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / randquik-2.1.0-py3-none-any.whl

Download URL randquik-2.1.0-py3-none-any.whl
Size 25.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
586ab573e713b45b0cd75261b2ade283a7bba4b2f64ac79d4e2711b3d486ccd1
BLAKE2b-256 checksum
How to use checksums
9512d48de8d2fcb45a9e5acda09b2fcdd33df27d8d99a2de3ae2158cb46c3143
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for randquik 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page