{"id":26555278,"url":"https://github.com/sorairolake/randgen","last_synced_at":"2025-06-27T11:32:55.595Z","repository":{"id":281662441,"uuid":"945994753","full_name":"sorairolake/randgen","owner":"sorairolake","description":"Generate pseudo-random bytes","archived":false,"fork":false,"pushed_at":"2025-06-22T12:32:26.000Z","size":298,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-06-22T13:33:26.036Z","etag":null,"topics":["cli","command-line","command-line-tool","generator","random","random-generation","rust","rust-lang","terminal","tool"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sorairolake.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.adoc","contributing":"CONTRIBUTING.adoc","funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.adoc","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-10T12:57:34.000Z","updated_at":"2025-06-22T12:32:23.000Z","dependencies_parsed_at":"2025-04-28T22:37:06.373Z","dependency_job_id":"d857a686-8d7a-44d6-b71a-a5758348ff3e","html_url":"https://github.com/sorairolake/randgen","commit_stats":null,"previous_names":["sorairolake/randgen"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/sorairolake/randgen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorairolake%2Frandgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorairolake%2Frandgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorairolake%2Frandgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorairolake%2Frandgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sorairolake","download_url":"https://codeload.github.com/sorairolake/randgen/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorairolake%2Frandgen/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261302639,"owners_count":23138184,"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":["cli","command-line","command-line-tool","generator","random","random-generation","rust","rust-lang","terminal","tool"],"created_at":"2025-03-22T10:25:47.990Z","updated_at":"2025-06-27T11:32:55.584Z","avatar_url":"https://github.com/sorairolake.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nSPDX-FileCopyrightText: 2025 Shun Sakai\n\nSPDX-License-Identifier: CC-BY-4.0\n--\u003e\n\n# randgen\n\n[![CI][ci-badge]][ci-url]\n[![Version][version-badge]][version-url]\n![MSRV][msrv-badge]\n![License][license-badge]\n\n**randgen** is a tool which generates random bytes using a pseudorandom number\ngenerator (PRNG).\n\n![Demo animation](assets/demo.gif)\n\n## Installation\n\n### From source\n\n```sh\ncargo install randgen\n```\n\n### From binaries\n\nThe [release page] contains pre-built binaries for Linux, macOS and Windows.\n\n### How to build\n\nPlease see [BUILD.adoc].\n\n## Usage\n\n### Basic usage\n\nGenerate 1 KiB of random bytes:\n\n```sh\nrandgen 1KiB\n```\n\n### Output formats\n\nThe following output formats are available:\n\n- `raw` (encode the generated bytes as raw bytes)\n- `base64` (encode the generated bytes as [base64])\n- `base64url` (encode the generated bytes as [URL-safe base64])\n- `hex` (encode the generated bytes as hex string)\n\n\u003e [!TIP]\n\u003e The result is output on a single line, so there is no line wrapping.\n\nThe default output format is `raw`. To change this, use `-f` option.\n\n```sh\nrandgen -f base64 256\n```\n\nThis has the same result as:\n\n```sh\nrandgen 256 | base64 -w 0\n```\n\n### Supported PRNGs and CSPRNGs\n\nSupported PRNGs are:\n\n- [ISAAC] RNGs (if enabled at compile time)\n- [Mersenne Twister] RNGs (if enabled at compile time)\n- [PCG] RNGs (if enabled at compile time)\n- [SFC] RNGs (if enabled at compile time)\n- [Xorshift] family\n  - SplitMix64 RNG\n  - Xorshift RNG (if enabled at compile time)\n  - xoroshiro RNGs\n  - xoshiro RNGs\n\nSupported CSPRNGs are:\n\n- [ChaCha]-based RNGs\n- [HC-128]-based RNG (if enabled at compile time)\n\nThe default RNG is `chacha12`. To change this, use `-r` option.\n\n```sh\nrandgen -r pcg64 \"2 MB\"\n```\n\n### Providing a random seed\n\n`-s` option allows you to specify a 64-bit unsigned integer random seed to be\nused when creating a new PRNG. If this option is not specified, the RNG seeded\nvia random data from system sources such as the [`getrandom`] system call on\nLinux.\n\n```sh\n$ randgen -f hex -r sfc32 -s 8 32B\n24f48cd0c3f6a1c6e8d7b4dcff9578864aced749e4eb1805dfba8b6e21d0cba0\n```\n\nThis has the same result as:\n\n```sh\n$ randgen -r sfc32 -s 8 32B | xxd -c 0 -p\n24f48cd0c3f6a1c6e8d7b4dcff9578864aced749e4eb1805dfba8b6e21d0cba0\n```\n\n### Print the progress bar\n\nWhen `-p` option is specified, `randgen` will print information showing the\nprogress of the generation of random bytes.\n\n```sh\nrandgen -p 4GiB \u003e /dev/null\n```\n\nThis is similar to the following example which uses [`pv(1)`]:\n\n```sh\nrandgen 4GiB | pv -s 4G \u003e /dev/null\n```\n\n### Generate shell completion\n\n`--generate-completion` option generates shell completions to standard output.\n\nThe following shells are supported:\n\n- `bash`\n- `elvish`\n- `fish`\n- `nushell`\n- `powershell`\n- `zsh`\n\nExample:\n\n```sh\nrandgen --generate-completion bash \u003e randgen.bash\n```\n\n### Integration with other programs\n\n#### Encode the generated bytes\n\nTo encode the generated bytes into an output format not supported by `randgen`,\npipe the output of `randgen` to the input of another program.\n\nFor example, to encode the generated bytes as [base32]:\n\n```sh\n$ randgen -s 16 32B | base32\nDYQZ33GRHUR5WIFRSBZVQ3ZPEFZASXB3SNTRUHR3NPITZBMDPZXQ====\n```\n\n#### Line wrapping\n\n`randgen` does not wrap lines of the result.\n\nTo wrap lines of the result:\n\n```sh\n$ randgen -f base64url -s 256 128B | fold -w 76\n0X82yjVU1_JLdDU07ywJ_7CAJBwRTEVS_i1-kRgR6HQsb9jFyQNuiFIBmrTucpwt-CZjZj90JYjE\n6D2erJEn6f8ju9KBmLraVj55I9KQRxhh2BmJMrovQhEK9nU3Ysn-mOURovtVCE45dqKyWTHuWLV2\nHr1yramxGwVm88LXhA8=\n```\n\nThis has the same result as:\n\n```sh\n$ randgen -s 256 128B | basenc --base64url\n0X82yjVU1_JLdDU07ywJ_7CAJBwRTEVS_i1-kRgR6HQsb9jFyQNuiFIBmrTucpwt-CZjZj90JYjE\n6D2erJEn6f8ju9KBmLraVj55I9KQRxhh2BmJMrovQhEK9nU3Ysn-mOURovtVCE45dqKyWTHuWLV2\nHr1yramxGwVm88LXhA8=\n```\n\n### Comparison with similar things\n\nThe following generates 64 KiB of random bytes and encodes it as base64:\n\n```sh\nrandgen -f base64 64KiB\n```\n\nThis section describes how to do the same thing with other things.\n\n#### OpenSSL\n\n[`openssl-rand(1ssl)`] can be used for this purpose.\n\n```sh\nopenssl rand -base64 64K\n```\n\n#### GnuPG\n\n[`gpg --gen-random`] can be used for this purpose.\n\n```sh\ngpg --gen-random 1 65536 | base64\n```\n\n#### Kernel random number source devices\n\n[`random(4)`] (`/dev/random` and `/dev/urandom`) can be used for this purpose.\n\n```sh\nhead -c 65536 /dev/random | base64\n```\n\n\u003e [!CAUTION]\n\u003e Unlike `randgen`, these things wrap lines of the result.\n\n## Command-line options\n\nPlease see the following:\n\n- [`randgen(1)`]\n\n## Source code\n\nThe upstream repository is available at\n\u003chttps://github.com/sorairolake/randgen.git\u003e.\n\n## Changelog\n\nPlease see [CHANGELOG.adoc].\n\n## Contributing\n\nPlease see [CONTRIBUTING.adoc].\n\n## License\n\nCopyright (C) 2025 Shun Sakai (see [AUTHORS.adoc])\n\n1.  This program is distributed under the terms of either the _Apache License\n    2.0_ or the _MIT License_.\n2.  Some files are distributed under the terms of the _Creative Commons\n    Attribution 4.0 International Public License_.\n\nThis project is compliant with version 3.3 of the [_REUSE Specification_]. See\ncopyright notices of individual files for more details on copyright and\nlicensing information.\n\n[ci-badge]: https://img.shields.io/github/actions/workflow/status/sorairolake/randgen/CI.yaml?branch=develop\u0026style=for-the-badge\u0026logo=github\u0026label=CI\n[ci-url]: https://github.com/sorairolake/randgen/actions?query=branch%3Adevelop+workflow%3ACI++\n[version-badge]: https://img.shields.io/crates/v/randgen?style=for-the-badge\u0026logo=rust\n[version-url]: https://crates.io/crates/randgen\n[msrv-badge]: https://img.shields.io/crates/msrv/randgen?style=for-the-badge\u0026logo=rust\n[license-badge]: https://img.shields.io/crates/l/randgen?style=for-the-badge\n[release page]: https://github.com/sorairolake/randgen/releases\n[BUILD.adoc]: BUILD.adoc\n[base64]: https://datatracker.ietf.org/doc/html/rfc4648#section-4\n[URL-safe base64]: https://datatracker.ietf.org/doc/html/rfc4648#section-5\n[ISAAC]: https://www.burtleburtle.net/bob/rand/isaacafa.html\n[Mersenne Twister]: https://www.math.sci.hiroshima-u.ac.jp/m-mat/MT/emt.html\n[PCG]: https://www.pcg-random.org/\n[SFC]: https://pracrand.sourceforge.net/RNG_engines.txt\n[Xorshift]: https://prng.di.unimi.it/\n[ChaCha]: https://cr.yp.to/chacha.html\n[HC-128]: https://en.wikipedia.org/wiki/HC-128\n[`getrandom`]: https://man7.org/linux/man-pages/man2/getrandom.2.html\n[`pv(1)`]: https://www.ivarch.com/programs/quickref/pv.shtml\n[base32]: https://datatracker.ietf.org/doc/html/rfc4648#section-6\n[`openssl-rand(1ssl)`]: https://docs.openssl.org/3.4/man1/openssl-rand/\n[`gpg --gen-random`]: https://gnupg.org/documentation/manuals/gnupg24/gpg.1.html\n[`random(4)`]: https://man7.org/linux/man-pages/man4/random.4.html\n[`randgen(1)`]: docs/man/man1/randgen.1.adoc\n[CHANGELOG.adoc]: CHANGELOG.adoc\n[CONTRIBUTING.adoc]: CONTRIBUTING.adoc\n[AUTHORS.adoc]: AUTHORS.adoc\n[_REUSE Specification_]: https://reuse.software/spec-3.3/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsorairolake%2Frandgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsorairolake%2Frandgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsorairolake%2Frandgen/lists"}