{"id":32629742,"url":"https://github.com/depra-inc/random","last_synced_at":"2025-10-30T22:46:12.545Z","repository":{"id":61438238,"uuid":"547497870","full_name":"Depra-Inc/Random","owner":"Depra-Inc","description":"Service containing a random value generator","archived":false,"fork":false,"pushed_at":"2022-10-19T12:51:19.000Z","size":197,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-22T05:24:50.235Z","etag":null,"topics":["cryptorandom","csharp","pseudorandom","random","random-generation","random-number-generators","randomization","randomizer","saferandom","service","threadsafety"],"latest_commit_sha":null,"homepage":"","language":"C#","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/Depra-Inc.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}},"created_at":"2022-10-07T19:38:17.000Z","updated_at":"2022-10-19T06:48:33.000Z","dependencies_parsed_at":"2023-01-20T08:30:15.749Z","dependency_job_id":null,"html_url":"https://github.com/Depra-Inc/Random","commit_stats":null,"previous_names":["depra-inc/random","depression-aggression/randomservice"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Depra-Inc/Random","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Depra-Inc%2FRandom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Depra-Inc%2FRandom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Depra-Inc%2FRandom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Depra-Inc%2FRandom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Depra-Inc","download_url":"https://codeload.github.com/Depra-Inc/Random/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Depra-Inc%2FRandom/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281896639,"owners_count":26580138,"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","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cryptorandom","csharp","pseudorandom","random","random-generation","random-number-generators","randomization","randomizer","saferandom","service","threadsafety"],"created_at":"2025-10-30T22:46:00.672Z","updated_at":"2025-10-30T22:46:12.536Z","avatar_url":"https://github.com/Depra-Inc.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Random Service\n\nContains a Random Service that provides an **IRandomizer** abstraction whose contract is equivalent to **System.Random**.\n\n## Features\n\n- **New** random number generators based on **System.Random**:\n    - **ConcurrentPseudoRandom** - A random number generator guaranteeing thread safety;\n    - **CryptoRandom** - A random number generator based on the System.Security.Cryptography.RNGCryptoServiceProvider.\n\n- Supported **types**:\n    1. Int32/Int\n    2. Double\n    3. Byte[]\n\n- Supported **types** via **extension** methods:\n    1. SByte\n    2. Byte\n    3. Int16/Short\n    4. UInt16/UShort\n    5. UInt32/UInt\n    6. Int64/Long\n    7. UInt64/ULong\n    8. Float\n    9. Decimal\n    10. Char[]\n    11. String\n    12. Boolean\n    13. Enum\n\n- Extensibility (see **[Depra.Unity.Random](https://github.com/Depression-aggression/Unity-Random)**);\n- Most of the functionality is covered by **unit tests;**\n- Also included are **benchmarks** that may be of interest.\n\n## Usage\n\nTo instantiate a service you need to use the **builder** pattern.\n\nInstance creation with a **custom randomizer**:\n\n```csharp\nvar randomService = new RandomServiceBuilder()\n                .With\u003cint\u003e(new CutomIntRandomizer()) // Or another randomizer\n                .Build();                            // for type Int32\n```\n\nInstantiating with a **collection** of **randomizers**:\n\n```csharp\nvar randomService = new RandomServiceBuilder()\n                .With(new PseudoRandomizers()) // Or another collection of randomizers. \n                .Build();\n\n// You can get randomizers from collections working with System.Random in this way:\nvar intRandomizer = randomService.GetRandomizer(typeof(int))\nintRandomizer = randomService.GetNumberRandomizer\u003cint\u003e();\nvar doubleRandomizer = randomService.GetTypedRandomizer\u003cdouble\u003e();\nvar byteArrayRandomizer = randomService.GetArrayRandomizer\u003cbyte[]\u003e();\n```\n\nWith the help of **extension methods** for randomizers, you can also get random value types that are not supported through System.Random.\nAn example of getting a **random string** using **INumberRandomizer\u003cint\u003e**:\n\n```csharp\nvar intRandomizer = randomService.GetNumberRandomizer\u003cint\u003e();\nvar randUpperCaseString = intRandomizer.NextString(length: 10, includeLowerCase: false);\nvar randString = intRandomizer.NextString(length: 20, allowedCharacters: \"abcdef\");\n```\n\n## Integrations:\n\n- **[Depra.Unity.Random](https://github.com/Depression-aggression/Unity-Random)** - To provide support for UnityEngine.Random.\n\n## Ps\n\nSome extension methods may not perform well and will be improved in future releases.\n\nYour suggestions for improvements are welcome.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdepra-inc%2Frandom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdepra-inc%2Frandom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdepra-inc%2Frandom/lists"}