{"id":19885652,"url":"https://github.com/asmod4n/mruby-sysrandom","last_synced_at":"2025-03-01T03:47:17.715Z","repository":{"id":76216550,"uuid":"60024388","full_name":"Asmod4n/mruby-sysrandom","owner":"Asmod4n","description":"Secure random number generation for mruby","archived":false,"fork":false,"pushed_at":"2019-06-23T11:23:38.000Z","size":15,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-11T18:47:26.353Z","etag":null,"topics":["mruby","random-number-generators","rng"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Asmod4n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-30T16:33:12.000Z","updated_at":"2019-06-23T11:23:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"7f4acbfa-28ce-4bce-b227-205b2bbd110e","html_url":"https://github.com/Asmod4n/mruby-sysrandom","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-sysrandom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-sysrandom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-sysrandom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-sysrandom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Asmod4n","download_url":"https://codeload.github.com/Asmod4n/mruby-sysrandom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241313181,"owners_count":19942417,"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":["mruby","random-number-generators","rng"],"created_at":"2024-11-12T17:35:12.540Z","updated_at":"2025-03-01T03:47:17.697Z","avatar_url":"https://github.com/Asmod4n.png","language":"C","readme":"# mruby-sysrandom\n\nSecure random number generation for mruby using system RNG facilities e.g. /dev/urandom, getrandom(2)\n\n## Description\n\nIn cryptography circles, [the prevailing advice is to use OS RNG functionality][/dev/urandom],\nnamely `/dev/urandom` or equivalent calls which use an OS-level CSPRNG to\nproduce random numbers.\n\nThis gem provides an easy-to-install repackaging of the `randombytes`\nfunctionality from [libsodium] for the purpose of generating secure random\nnumbers trustworthy for use in cryptographic contexts, such as generating\ncryptographic keys, initialization vectors, or nonces.\n\nThe following random number generators are utilized:\n\n| Platform | RNG                                                    |\n|----------|--------------------------------------------------------|\n| Linux    | [getrandom(2)] if available, otherwise [/dev/urandom]  |\n| Windows  | [RtlGenRandom] CryptGenRandom without CryptoAPI deps   |\n| OpenBSD  | [arc4random(3)] with ChaCha20 CSPRNG (not RC4)         |\n| Others   | [/dev/urandom]                                         |\n\n[emboss]:        https://emboss.github.io/blog/2013/08/21/openssl-prng-is-not-really-fork-safe/\n[bug]:           https://bugs.ruby-lang.org/issues/9569\n[libsodium]:     https://github.com/jedisct1/libsodium\n[getrandom(2)]:  http://man7.org/linux/man-pages/man2/getrandom.2.html\n[/dev/urandom]:  http://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers/\n[RtlGenRandom]:  https://msdn.microsoft.com/en-us/library/windows/desktop/aa387694(v=vs.85).aspx\n[arc4random(3)]: http://man.openbsd.org/arc4random.3\n\n## Usage\n\n```ruby\nSysrandom.random_bytes # returns a 16 byte binary string\n\nSysrandom.random_bytes(64)\n\nSysrandom.random_bytes(\" \" * 10)\n\nSysrandom.random # returns a number\n\nSysrandom.uniform(upper_bound) # returns a number up to upper_bound\n\nSysrandom.base64 # returns a 16 byte binary string as base64\n\nSysrandom.base64(64)\n\nSysrandom.base64(\" \" * 10)\n\nSysrandom.hex # returns a 16 byte binary string as hex\n\nSysrandom.hex(64)\n\nSysrandom.hex(\" \" * 10)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasmod4n%2Fmruby-sysrandom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasmod4n%2Fmruby-sysrandom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasmod4n%2Fmruby-sysrandom/lists"}