{"id":27337563,"url":"https://github.com/touhidurrr/randomcryp","last_synced_at":"2025-04-12T15:14:12.653Z","repository":{"id":283999788,"uuid":"953524068","full_name":"touhidurrr/randomcryp","owner":"touhidurrr","description":"A cryptographically secure, feature rich, zero dependency, lightweight and browser friendly random number generator library.","archived":false,"fork":false,"pushed_at":"2025-04-11T20:50:10.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T15:14:04.967Z","etag":null,"topics":["browser","bun","cross-platform","crypto","cryptography","deno","friendly","generator","javascript","lightweight","nodejs","number","open-source","package","random","typescript","web","web-crypto","zero-dependency"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/randomcryp","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/touhidurrr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"buy_me_a_coffee":"touhidurrr","patreon":"touhidurRR"}},"created_at":"2025-03-23T15:11:22.000Z","updated_at":"2025-04-11T20:49:12.000Z","dependencies_parsed_at":"2025-04-11T19:40:22.894Z","dependency_job_id":"04c095dc-a6cb-4b2e-a289-acadca4207cf","html_url":"https://github.com/touhidurrr/randomcryp","commit_stats":null,"previous_names":["touhidurrr/randomcryp"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/touhidurrr%2Frandomcryp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/touhidurrr%2Frandomcryp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/touhidurrr%2Frandomcryp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/touhidurrr%2Frandomcryp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/touhidurrr","download_url":"https://codeload.github.com/touhidurrr/randomcryp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586241,"owners_count":21128998,"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":["browser","bun","cross-platform","crypto","cryptography","deno","friendly","generator","javascript","lightweight","nodejs","number","open-source","package","random","typescript","web","web-crypto","zero-dependency"],"created_at":"2025-04-12T15:14:12.036Z","updated_at":"2025-04-12T15:14:12.641Z","avatar_url":"https://github.com/touhidurrr.png","language":"TypeScript","funding_links":["https://buymeacoffee.com/touhidurrr","https://patreon.com/touhidurRR"],"categories":[],"sub_categories":[],"readme":"# randomcryp\n\nA cryptographically secure, feature rich, zero dependency, lightweight and browser friendly random number generator library. Only ~5KB in size.\nUses [Crypto.getRandomValues()](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues) to get its randomness.\nThe spelling is random-creep in case you are wondering.\n\n## Featues\n\n- Lightweight\n- Browser friendly\n- TypeScript definitions\n- Lots of methods and common aliases\n- Batteries Included (Zero dependencies)\n- Supported in all major JavaScript / TypeScript runtimes (Browser, Node, Deno, Bun etc.)\n\n## Install\n\n```bash\nbun add randomcryp # bun\nyarn add randomcryp # yarn\npnpm add randomcryp # pnpm\nnpm install randomcryp # npm\n```\n\n## Usage\n\n```ts\nimport random from \"randomcryp\";\n\nfloat(); // 0.190088246732104\n```\n\nOr,\n\n```ts\nimport { rangeInt } from \"randomcryp\";\n\nrangeInt(1, 10); // 7\n```\n\n#### List of Methods\n\n| Method | Description | Aliases |\n| -- | -- | -- |\n| **`bool(): boolean`** | Generates a random boolean (`true` or `false`). | `bool()` → `true` |\n| **`boolean(): boolean`** | Alias for `bool()`. | `boolean()` → `false` |\n| **`percentage(p: number): boolean`** | Generates `true` at given percentage of time. | `percentage(20)` → `false` |\n| **`probability(p: number): boolean`** | Generates `true` with a given probability `p` and `false` with probability `1-p`. | `probability(0.8)` → `true` |\n| **`uSafeInt(): number`** | Generates a random integer between `0` (inclusive) and `Number.MAX_SAFE_INTEGER` (inclusive). | `uSafeInt()` → `4946544243668033` |\n| **`float(): number`** | Generates a random number between `0` (inclusive) and `1` (exclusive). | `number()` → `0.190088246732104` |\n| **`random(): number`** | Alias for `float()`. | `random()` → `0.9520779718919631` |\n| **`hex(length: number = 8, prefix: boolean = false): string`** | Generates a random hex string of the specified length (default 8). Optionally prefixes with '0x'. | `hex(16)` → `d1ef0149c7849844` |\n| **`choice(arr: ArrayLike\u003cE\u003e): E`** | Selects a random element from an array. | `choice([1, 2, 3, 4, 5])` → `3` |\n| **`pick(arr: ArrayLike\u003cE\u003e): E`** | Alias for `choice()`. | `pick([1, 2, 3, 4, 5])` → `1` |\n| **`shuffle(input: string): string`**, **`shuffle(input: Array\u003cE\u003e): Array\u003cE\u003e`** | Returns a new array or string after shuffling the given array or string randomly. | `shuffle([1, 2, 3, 4, 5])` → `[ 1, 3, 2, 5, 4 ]` |\n| **`range(min: number, max: number): number`** | Generates a random number (not integer) between given `min` (inclusive) and `max` (exclusive). Throws if `min` \u003e `max`. | `range(1, 5)` → `4.103370176158448` |\n| **`rangeInt(min: number, max: number): number`** | Generates a random number (not integer) between given `min` (inclusive) and `max` (exclusive). Throws if `min` \u003e `max`. | `rangeInt(1, 10)` → `8` |\n| **`randInt(min: number, max: number): number`** | Alias for `rangeInt()`. | `randInt(1, 100)` → `35` |\n| **`safeInt(): number`** | Generates a random integer between `Number.MIN_SAFE_INTEGER` (inclusive) and `Number.MAX_SAFE_INTEGER` (inclusive). `+0` and `-0` both can be generated. `54` bits precision. Not recommended for general usage. | `safeInt()` → `-5802548511349229` |\n| **`ifloat(): number`** | Generates a random number between `-1` (inclusive) and `1` (inclusive). Uses `safeInt()` and thus not recommended. | `ifloat()` → `-0.6076475248861822` |\n\n© 2025, Md. Touhidur Rahman.\nLicense: BSD-3-Clause.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftouhidurrr%2Frandomcryp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftouhidurrr%2Frandomcryp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftouhidurrr%2Frandomcryp/lists"}