{"id":20607068,"url":"https://github.com/pcowgill/crypto-in-react-native","last_synced_at":"2026-05-04T00:32:34.165Z","repository":{"id":93257848,"uuid":"231626625","full_name":"pcowgill/crypto-in-react-native","owner":"pcowgill","description":"Encryption and random numbers for projects made with React Native","archived":false,"fork":false,"pushed_at":"2020-01-03T17:43:02.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-29T12:38:49.328Z","etag":null,"topics":["android","crypto","eject","encryption","expo","ios","mobile","native","random","random-number-generators","react","react-native","tweetnacl"],"latest_commit_sha":null,"homepage":null,"language":null,"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/pcowgill.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["pcowgill"]}},"created_at":"2020-01-03T16:40:06.000Z","updated_at":"2022-01-27T14:50:05.000Z","dependencies_parsed_at":"2023-08-25T06:32:56.959Z","dependency_job_id":null,"html_url":"https://github.com/pcowgill/crypto-in-react-native","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pcowgill/crypto-in-react-native","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcowgill%2Fcrypto-in-react-native","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcowgill%2Fcrypto-in-react-native/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcowgill%2Fcrypto-in-react-native/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcowgill%2Fcrypto-in-react-native/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pcowgill","download_url":"https://codeload.github.com/pcowgill/crypto-in-react-native/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcowgill%2Fcrypto-in-react-native/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32590241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"ssl_error","status_checked_at":"2026-05-03T22:09:10.534Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["android","crypto","eject","encryption","expo","ios","mobile","native","random","random-number-generators","react","react-native","tweetnacl"],"created_at":"2024-11-16T09:35:30.510Z","updated_at":"2026-05-04T00:32:34.157Z","avatar_url":"https://github.com/pcowgill.png","language":null,"funding_links":["https://github.com/sponsors/pcowgill"],"categories":[],"sub_categories":[],"readme":"# Crypto in React Native\nEncryption and random numbers for projects made with React Native\n\n**Note: Still a work-in-progress. Issues and PRs are welcome!**\n\n# Table of Contents\n1. Strategies for using libaries that were made targeting a node or browser environment\n1. To eject or not to eject (from Expo)?\n1. Options for encryption\n1. Options for random number generation\n\n---\n\n### Strategies for using libaries that were made targeting a node or browser environment\nIf you want to use a higher-level library with its own dependencies, it's pretty likely that one of those dependencies was built assuming a node or browser environment (as opposed to a React Native environment), which means it's likely it depends on a method or global variable that is only defined in those environments. For an example that's not particularly crypto-related, node assumes access to the computer's file system with the node core `fs` module.\n\n##### Just don't use such libraries\n\nIf you're making your own library or an app that doesn't have any high-level dependencies, the \"cleanest\" option is to just use dependencies that were built to work in a React Native environment in the first place.\n\n##### `metro.config.js` and `extraNodeModules`\n\nUsing the resolver settings for the `metro` bundler that React Native uses, ensure that a given dep always resolves to a different dep in a React Native environment. The `extraNodeModules` feature in the `metro.config.js` helps with that.\n\n##### `rn-nodeify`\n\n`rn-nodeify` searches through your `node_modules` and recursively modifies the `package.json` for every dep and modifies which packages they depend on in a React Native env. It adds a `shim` file to your project as well for global polyfills like `process` and `Buffer`. With the `hack` flag, needed for some packages like `react-native-randombyte`s, it modifies the code directly if certain regular expressions are matched.\n\nYou'll most likely come across this approach first when searching online, but the more direct approach with `metro.config.js` is easier to reason about from both a security perspective an a DevEx perspective.\n\n---\n\n### To eject or not to eject (from Expo)?\n`react-native-crypto` requires a peer dep of `react-native-randombytes`\n\n`react-native-randombytes` requires ejecting, so unless we can find a replacement for that package, the repo will be an ejected project.\n\nSubbing in `expo-random` as the source of randomness in forks of existing crypto libs seems like a good strategy around this, but handling which methods are sync vs. async is a potential sticking point to work around with that approach. (Many methods in React Native packages are async because they require a round trip across the js/native bridge.) See [this TweetNaCl.js fork](https://github.com/rajtatata/react-native-expo-tweet-nacl#readme) for an example.\n\n---\n\n### Options for encryption\n\n##### Not matching node or web APIs\n\n[`expo-crypto`](https://github.com/expo/expo/tree/master/packages/expo-crypto)\n\n[`tweetnacl-js`](https://github.com/dchest/tweetnacl-js)\n* perhaps subbing in `expo-random` as the source of randomness like was done for [this TweetNaCl.js fork](https://github.com/rajtatata/react-native-expo-tweet-nacl#readme)\n\n##### Matching [node API](https://nodejs.org/docs/latest-v12.x/api/crypto.html)\n\n`react-native-crypto`\n* requires ejecting because it has a peer dep of `react-native-randombytes`\n* installation instructions assume `rn-nodeify` strategy for polyfilling\n\n##### Matching [web API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)\n`// TODO: Add me`\n\n##### Options that may show up when searching online that are no longer actively maintained\n`// TODO: Add me`\n\n---\n\n### Options for random number generation\n\n##### Not matching node or web APIs\n[`expo-random`](https://github.com/expo/expo/tree/master/packages/expo-random)\n\n##### Matching node API\n\n[`react-native-randombytes`](https://github.com/mvayngrib/react-native-randombytes/)\n* requires ejecting\n* installation instructions assume `rn-nodeify` strategy for polyfilling\n\n##### Matching web API\n`// TODO: Add me`\n\n##### Options that may show up when searching online that are no longer actively maintained\n`// TODO: Add me`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpcowgill%2Fcrypto-in-react-native","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpcowgill%2Fcrypto-in-react-native","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpcowgill%2Fcrypto-in-react-native/lists"}