{"id":17396818,"url":"https://github.com/faern/rng-cli","last_synced_at":"2025-09-20T23:32:54.375Z","repository":{"id":57661301,"uuid":"196871579","full_name":"faern/rng-cli","owner":"faern","description":"A random data generator CLI tool. Prints an infinite stream of data generated from a selected PRNG algorithm to stdout","archived":false,"fork":false,"pushed_at":"2021-11-24T22:19:46.000Z","size":29,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-17T15:44:20.484Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/faern.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-14T18:46:31.000Z","updated_at":"2024-07-05T15:17:16.000Z","dependencies_parsed_at":"2022-09-06T01:30:28.574Z","dependency_job_id":null,"html_url":"https://github.com/faern/rng-cli","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faern%2Frng-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faern%2Frng-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faern%2Frng-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faern%2Frng-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/faern","download_url":"https://codeload.github.com/faern/rng-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233694821,"owners_count":18715508,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-16T13:13:10.373Z","updated_at":"2025-09-20T23:32:54.105Z","avatar_url":"https://github.com/faern.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rng - A random number generator CLI tool.\n\nContains a number of (pseudo) random number generator algorithms. Given one of these it writes an\ninfinite stream of bytes generated from that algorithm to stdout.\n\nIn unix terms it can be viewed as the equivalent of `cat /dev/urandom` but with a\nselection of different (mostly user-space) PRNG algorithms to choose from. This is usually way\nfaster than `/dev/urandom` but can also provide lower entropy output, depending on which algorithm\nis chosen.\n\nThis tool is more or less a CLI frontend for the awesome `rand` crate.\n\n# How to use\n\n```\nrng [--seed \u003cseed\u003e] [--max threads] [--verbose] [\u003calgorithm\u003e]\n```\n\nIf no arguments are given it uses the default algorithm and seeds it from the operating system.\nYou might want to change the algorithm in order to fit your needs. Maybe you need a faster algorithm\nthat is not cryptographically secure for example.\n\nThe `--seed \u003cseed\u003e` argument initializes the random number algorithm with the given `\u003cseed\u003e` instead\nof obtaining some entropy from the operating system. You don't want to use this for any\ncryptographical purposes. Giving a seed can be useful when you need determinism and must be able\nto produce identical data over multiple runs.\n\nThe `--max-threads` argument sets an upper limit on how many threads the tool can use in\nmultithreaded mode. By default this is set to the number of hardware threads available on\nthe system. The exception is when `--seed` is specified or the algorithm is \"os\", then the\ntool always runs in single-threaded mode.\n\n## Example\n\nWe try using the PCG algoritm a few times. Here we see that without a seed it produces different\noutput each time, and with a seed it produces the same data as long as the seed is the same.\n\n```bash\n$ rng pcg | dd count=1024 | shasum\nae148d8b54ee544a50833c2a6915b0fca4cb95ed -\n$ rng pcg | dd count=1024 | shasum\n65a5651a2b1201adbe8bf60d9f7a2b940f6e188b -\n$ rng pcg --seed 6 | dd count=1024 | shasum\nfc14baccbc847339408457335dc67bc4c9785185 -\n$ rng pcg --seed 6 | dd count=1024 | shasum\nfc14baccbc847339408457335dc67bc4c9785185 -\n$ rng pcg --seed 7 | dd count=1024 | shasum\nc7a169d195c395867396d16d70c1a3c19f63b5cc -\n```\n\n# Why?\n\nThis tool was invented because I needed to benchmark IO (both filesystem and network) on Linux.\nReading from `/dev/urandom` was too slow, the machine spent too much time computing the actual data\nand too little time performing the IO I wanted to test. On the other hand, getting data from\n`/dev/zero` is fast! But any compression (common in both network protocols and filesystems) will be\nable to optimize this stream down to almost nothing. And again, the actual IO is not being properly\nbenchmarked.\n\nSo what I needed was a very fast stream of incompressible data. The `rand` crate provides a unified\ninterface to a number of different random number algorithms. Some of them suiting my use case.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaern%2Frng-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffaern%2Frng-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaern%2Frng-cli/lists"}