{"id":21561751,"url":"https://github.com/synonymdev/sodium-react-native","last_synced_at":"2026-03-04T03:31:06.381Z","repository":{"id":207409600,"uuid":"719177376","full_name":"synonymdev/sodium-react-native","owner":"synonymdev","description":"React native wrapper for libsodium crypto library","archived":false,"fork":false,"pushed_at":"2024-12-03T11:00:54.000Z","size":26830,"stargazers_count":5,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-18T02:19:45.118Z","etag":null,"topics":["cryptography","libsodium","react-native","sodium"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/synonymdev.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":"2023-11-15T16:06:28.000Z","updated_at":"2024-12-03T11:00:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"cd4d00ac-ac22-4056-b553-908008ef00c2","html_url":"https://github.com/synonymdev/sodium-react-native","commit_stats":null,"previous_names":["pwltr/sodium-react-native","synonymdev/sodium-react-native"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/synonymdev/sodium-react-native","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synonymdev%2Fsodium-react-native","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synonymdev%2Fsodium-react-native/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synonymdev%2Fsodium-react-native/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synonymdev%2Fsodium-react-native/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/synonymdev","download_url":"https://codeload.github.com/synonymdev/sodium-react-native/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synonymdev%2Fsodium-react-native/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30070744,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T03:25:38.285Z","status":"ssl_error","status_checked_at":"2026-03-04T03:25:05.086Z","response_time":59,"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":["cryptography","libsodium","react-native","sodium"],"created_at":"2024-11-24T09:27:53.171Z","updated_at":"2026-03-04T03:31:06.343Z","avatar_url":"https://github.com/synonymdev.png","language":"JavaScript","readme":"# sodium-react-native\n\nA port of Frank Denis' [libsodium](https://libsodium.gitbook.io/doc/) cryptography library for React Native. This library is intended to be a drop-in replacement for pre-existing [NodeJs and JavaScript ports](https://sodium-friends.github.io/docs/docs/getstarted).\n\nOnly a subset of the functions have been exposed, however, contributions are most welcome.\n\n## Notes\n\nThe goal of this project is to be thin, stable, unopionated wrapper around libsodium.\n\nAll methods exposed are more or less a direct translation of the libsodium C API. This means that most data types are buffers and you have to manage allocating return values and passing them in as arguments instead of receiving them as return values.\n\nThis makes this API harder to use than other libsodium wrappers out there, but also means that you'll be able to get a lot of performance / memory improvements as you can do stuff like inline encryption / decryption, re-use buffers etc.\n\n## Installation\n\n```sh\nnpm install sodium-react-native-direct\n```\n\n## Usage\n\n```js\nimport sodium from \"sodium-react-native-direct\";\n\nconst key = sodium_malloc(sodium.crypto_kdf_KEYBYTES)\nconst subkey = sodium_malloc(sodium.crypto_kdf_BYTES_MAX)\nconst ctx = sodium_malloc(sodium.crypto_kdf_CONTEXTBYTES\n\nsodium.crypto_kdf_keygen(key);\nsodium.crypto_kdf_derive_from_key(subkey, 1, ctx, key)\n```\n\n## Use as a drop-in for `sodium-universal`\n\nIn your `metro.config.js` add a mapping to resolve modules:\n\n```js\n...\n\nconst config = {\n  resolver: {\n    extraNodeModules: {\n      'sodium-universal': path.resolve(__dirname, './node_modules/sodium-react-native-direct'),\n    },\n    blacklistRE: exclusionList([\n      /\\/node_modules\\/sodium-universal\\/.*/,\n    ]),\n  },\n};\n```\n\n## API\n\nFull API documentation for each method may be found under the links in each section.\n\n#### `crypto_aead_xchacha20poly1305`\n\n[Authenticated encryption](https://sodium-friends.github.io/docs/docs/aead)\n\n#### Methods\n\n```\n  crypto_aead_xchacha20poly1305_ietf_keygen\n  crypto_aead_xchacha20poly1305_ietf_encrypt\n  crypto_aead_xchacha20poly1305_ietf_decrypt\n\n  crypto_aead_chacha20poly1305_ietf_keygen\n  crypto_aead_chacha20poly1305_ietf_encrypt\n  crypto_aead_chacha20poly1305_ietf_decrypt\n```\n\n#### Constants\n\n```\n  crypto_aead_xchacha20poly1305_ietf_KEYBYTES\n  crypto_aead_xchacha20poly1305_ietf_NPUBBYTES\n  crypto_aead_xchacha20poly1305_ietf_ABYTES\n\n  crypto_aead_chacha20poly1305_ietf_KEYBYTES\n  crypto_aead_chacha20poly1305_ietf_NPUBBYTES\n  crypto_aead_chacha20poly1305_ietf_ABYTES\n```\n\n### Curve arithemetic\n\n[Curve25519 \u0026 Ed25519 arithmetic](https://sodium-friends.github.io/docs/docs/finitefieldarithmetic)\n\n#### Methods\n\n```\n  crypto_core_ed25519_scalar_random\n  crypto_core_ed25519_add\n  crypto_core_ed25519_sub\n  crypto_core_ed25519_from_uniform\n\n  crypto_scalarmult\n  crypto_scalarmult_base\n\n  crypto_scalarmult_ed25519\n  crypto_scalarmult_ed25519_base\n```\n\nClamping involves clearing the lowest 3 bits of the result, ensuring the result lies on the main subgroup of the curve. However, this breaks point inversion which is undesireable for some protcocols. See [here](https://www.jcraige.com/an-explainer-on-ed25519-clamping) for a more detailed explanation.\n\n```\n  crypto_scalarmult_ed25519_noclamp\n  crypto_scalarmult_ed25519_base_noclamp\n```\n\n#### Constants\n\n```\n  crypto_core_ed25519_SCALARBYTES\n  crypto_core_ed25519_BYTES\n  crypto_core_ed25519_UNIFORMBYTES\n\n  crypto_scalarmult_ed25519_BYTES\n  crypto_scalarmult_ed25519_SCALARBYTES\n```\n\n#### `crypto_pwhash`\n\n[Password Hashing](https://sodium-friends.github.io/docs/docs/passwordhashing)\n\n#### Methods\n\n```\n  crypto_pwhash\n  crypto_pwhash_async\n```\n\n#### Constants\n\n```\n  crypto_pwhash_BYTES_MIN\n  crypto_pwhash_BYTES_MAX\n  crypto_pwhash_PASSWD_MIN\n  crypto_pwhash_PASSWD_MAX\n  crypto_pwhash_SALTBYTES\n  crypto_pwhash_OPSLIMIT_MIN\n  crypto_pwhash_OPSLIMIT_MAX\n  crypto_pwhash_MEMLIMIT_MIN\n  crypto_pwhash_MEMLIMIT_MAX\n  crypto_pwhash_ALG_DEFAULT\n  crypto_pwhash_ALG_ARGON2I13\n  crypto_pwhash_ALG_ARGON2ID13\n  crypto_pwhash_BYTES_MIN\n  crypto_pwhash_BYTES_MAX\n  crypto_pwhash_PASSWD_MIN\n  crypto_pwhash_PASSWD_MAX\n  crypto_pwhash_SALTBYTES\n  crypto_pwhash_STRBYTES\n  crypto_pwhash_OPSLIMIT_MIN\n  crypto_pwhash_OPSLIMIT_MAX\n  crypto_pwhash_MEMLIMIT_MIN\n  crypto_pwhash_MEMLIMIT_MAX\n  crypto_pwhash_OPSLIMIT_INTERACTIVE\n  crypto_pwhash_MEMLIMIT_INTERACTIVE\n  crypto_pwhash_OPSLIMIT_MODERATE\n  crypto_pwhash_MEMLIMIT_MODERATE\n  crypto_pwhash_OPSLIMIT_SENSITIVE\n  crypto_pwhash_MEMLIMIT_SENSITIVE\n```\n\n#### `crypto_generichash`\n\n[Blake2b hashing](https://sodium-friends.github.io/docs/docs/generichashing)\n\n#### Methods\n\n```\n  crypto_generichash\n  crypto_generichash_init\n  crypto_generichash_update\n  crypto_generichash_final\n  crypto_generichash_batch\n```\n\n#### Constants\n\n```\n  crypto_generichash_STATEBYTES\n  crypto_generichash_KEYBYTES_MIN\n  crypto_generichash_KEYBYTES_MAX\n  crypto_generichash_BYTES\n  crypto_generichash_BYTES_MIN\n  crypto_generichash_BYTES_MAX\n```\n\n#### `crypto_kx`\n\n[Key exchange](https://sodium-friends.github.io/docs/docs/keyexchange)\n\n#### Methods\n\n```\n  crypto_kx_keypair\n```\n\n#### Constants\n\n```\n  crypto_kx_PUBLICKEYBYTES\n  crypto_kx_SECRETKEYBYTES\n```\n\n#### `crypto_kdf`\n\n[Key derivation](https://sodium-friends.github.io/docs/docs/keyderivation)\n\n#### Methods\n\n```\n  crypto_kdf_keygen\n  crypto_kdf_derive_from_key\n```\n\n#### Constants\n\n```\n  crypto_kdf_KEYBYTES\n  crypto_kdf_BYTES_MIN\n  crypto_kdf_BYTES_MAX\n  crypto_kdf_CONTEXTBYTES\n```\n\n#### `crypto_secretstream_xchacha20poly1305`\n\n[Stream encryption](https://sodium-friends.github.io/docs/docs/streamencryption)\n\n#### Methods\n\n```\n  crypto_secretstream_xchacha20poly1305_keygen\n  crypto_secretstream_xchacha20poly1305_init_push\n  crypto_secretstream_xchacha20poly1305_push\n  crypto_secretstream_xchacha20poly1305_init_pull\n  crypto_secretstream_xchacha20poly1305_pull\n```\n\n#### Constants\n\n```\n  crypto_secretstream_xchacha20poly1305_STATEBYTES\n  crypto_secretstream_xchacha20poly1305_ABYTES\n  crypto_secretstream_xchacha20poly1305_HEADERBYTES\n  crypto_secretstream_xchacha20poly1305_KEYBYTES\n  crypto_secretstream_xchacha20poly1305_TAGBYTES\n  crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX\n\n  crypto_secretstream_xchacha20poly1305_TAG_MESSAGE\n  crypto_secretstream_xchacha20poly1305_TAG_PUSH\n  crypto_secretstream_xchacha20poly1305_TAG_REKEY\n  crypto_secretstream_xchacha20poly1305_TAG_FINAL\n```\n\n#### `crypto_box`\n\n[Sealed box encryption](https://sodium-friends.github.io/docs/docs/sealedboxencryption)\n\n#### Methods\n\n```\n  crypto_box_keypair\n  crypto_box_seal\n  crypto_box_seal_open\n```\n\n#### Constants\n\n```\n  crypto_box_SEALBYTES\n  crypto_box_PUBLICKEYBYTES\n  crypto_box_SECRETKEYBYTES\n  crypto_box_SEEDBYTES\n  crypto_box_NONCEBYTES\n  crypto_box_MACBYTES\n```\n\n#### `crypto_secretbox`\n\n[Secret key box encryption](https://sodium-friends.github.io/docs/docs/secretkeyboxencryption)\n\n#### Methods\n\n```\n  crypto_secretbox_easy\n```\n\n#### `randombytes_buf`\n\n[Generating random data](https://sodium-friends.github.io/docs/docs/generatingrandomdata)\n\n```\n  randombytes_buf\n```\n\n### Padding\n\n[Padding](https://sodium-friends.github.io/docs/docs/padding).\n\n```\n  sodium_pad\n  sodium_unpad\n```\n\n### Utilities\n\nVarious [helpers](https://sodium-friends.github.io/docs/docs/helpers) for securely handling memory.\n\n```\n  sodium_memcmp  // constant time\n  sodium_memzero\n  sodium_free\n  sodium_malloc\n```\n\n## License\n\nMIT\n\n---\n\nMade with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynonymdev%2Fsodium-react-native","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsynonymdev%2Fsodium-react-native","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynonymdev%2Fsodium-react-native/lists"}