{"id":21974396,"url":"https://github.com/kore-koi/react-native-get-random-values","last_synced_at":"2025-04-28T15:36:21.009Z","repository":{"id":257807448,"uuid":"820494702","full_name":"kore-koi/react-native-get-random-values","owner":"kore-koi","description":"⚡️ A fast implementation of `crypto.getRandomValues` for React Native","archived":false,"fork":false,"pushed_at":"2024-10-04T10:43:41.000Z","size":5255,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-29T08:46:09.299Z","etag":null,"topics":["android","crypto","ios","javascript","native-module","polyfill","random","react-native","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@korekoi/react-native-get-random-values","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kore-koi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-26T15:22:00.000Z","updated_at":"2024-12-21T18:53:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"3e55735d-80cb-4219-99fe-f4ed5e42a952","html_url":"https://github.com/kore-koi/react-native-get-random-values","commit_stats":null,"previous_names":["kore-koi/react-native-get-random-values"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kore-koi%2Freact-native-get-random-values","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kore-koi%2Freact-native-get-random-values/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kore-koi%2Freact-native-get-random-values/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kore-koi%2Freact-native-get-random-values/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kore-koi","download_url":"https://codeload.github.com/kore-koi/react-native-get-random-values/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251339554,"owners_count":21573745,"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":["android","crypto","ios","javascript","native-module","polyfill","random","react-native","typescript"],"created_at":"2024-11-29T15:45:11.019Z","updated_at":"2025-04-28T15:36:20.982Z","avatar_url":"https://github.com/kore-koi.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca\u003e\n  \u003cpicture\u003e\n    \u003cimg alt=\"@kore-koi/react-native-get-random-values\" src=\".github/assets/banner.svg\"/\u003e\n  \u003c/picture\u003e\n\u003c/a\u003e\n\n---\n\n[![NPM Version](https://img.shields.io/npm/v/@korekoi/react-native-get-random-values?color=blue\u0026style=flat-square)](https://www.npmjs.com/package/@korekoi/react-native-get-random-values)\n\n### Features\n\n- 🫳 Drop-in replacement for `crypto.getRandomValues`\n- ⚡ Uses JSI for faster operations  between Native and JS\n- 🔒 Native C++ secure randomization using [libsodium](https://github.com/jedisct1/libsodium)\n\n### Installation\n\n```sh\nnpm install @korekoi/react-native-get-random-values\n```\n\n#### Dependencies\n\nThis library needs these dependencies to be installed in your project before you can use it:\n\n```sh\nnpm install react-native-nitro-modules\n```\n\n### Usage\n\n```typescript\nimport \"@korekoi/react-native-get-random-values\"\n\nconst array = new Uint8Array(32);\nglobal.crypto.getRandomValues(array);\n```\n\n\n\u003e See the [example app](./example/)\n\n### How does it compare to other alternatives?\n\nThe most downloaded and probably the only available library to polyfill this method (until now) has been [LinusU/react-native-get-random-values](https://github.com/LinusU/react-native-get-random-values), but our solution has a couple improvements:\n\n- **JSI**, Native and JavaScript communicate through a memory reference and not by serializing data in Base64 back-and-forth, which results in faster operations\n- Randomization is made using [libsodium](https://github.com/jedisct1/libsodium) for both iOS and Android\n  - instead of [Java SecureRandom](https://docs.oracle.com/javase/8/docs/api/java/security/SecureRandom.html) for Android and [Objective-C SecRandomCopyBytes](https://developer.apple.com/documentation/security/secrandomcopybytes(_:_:_:)?language=objc) or [Swift SecRandomCopyBytes](https://developer.apple.com/documentation/security/secrandomcopybytes(_:_:_:)) for iOS\n\n### Benchmark\n\nPercentage represents how much faster JSI is compared to B64\n\n| iOS                                                                          | iOS Simulator                                                               | Android                    |\n| ---------------------------------------------------------------------------- | --------------------------------------------------------------------------- | -------------------------- |\n| \u003cimg alt=\"iPhone 13 Benchmark\" src=\".github/assets/iphone13_benchmark.png\"/\u003e | \u003cimg alt=\"Simulator Benchmark\" src=\".github/assets/sim_benchmark.png\"/\u003e     | Feel free to open an issue |\n| iPhone 13 on iOS 17                                                          | iPhone 16 Pro Simulator, iOS 18, running on an MacBook Air M1 2020 16GB ram |                            |\n| 10k loops at 65535 bytes with Base 64 crashed the app                        |                                                                             |                            |\n\n\n### Notes\n\n- [Get started with the development of the module](./docs/getting-started.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkore-koi%2Freact-native-get-random-values","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkore-koi%2Freact-native-get-random-values","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkore-koi%2Freact-native-get-random-values/lists"}