{"id":19517346,"url":"https://github.com/anday013/react-native-bcrypt-cpp","last_synced_at":"2025-09-06T11:38:17.693Z","repository":{"id":251971327,"uuid":"839005436","full_name":"anday013/react-native-bcrypt-cpp","owner":"anday013","description":"Next-gen React Native library for Bcrypt hashing, using pure C++ with Turbo Modules and multithreading for superior performance","archived":false,"fork":false,"pushed_at":"2024-08-18T09:56:49.000Z","size":23096,"stargazers_count":36,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T09:11:17.299Z","etag":null,"topics":["bcrypt","cpp","hashing","jsi","multithreading","new-architecture","password","react-native","react-native-bcrypt","react-native-bridgeless","react-native-cpp","react-native-hash","react-native-jsi","react-native-multithreading","react-native-new-architecture","react-native-password","react-native-security","security","turbo-modules"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-native-bcrypt-cpp","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/anday013.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-08-06T19:19:50.000Z","updated_at":"2025-03-28T23:13:06.000Z","dependencies_parsed_at":"2024-08-06T22:57:15.095Z","dependency_job_id":"3738fb6d-1640-48e6-a4fd-e05b3ef24bdd","html_url":"https://github.com/anday013/react-native-bcrypt-cpp","commit_stats":null,"previous_names":["anday013/react-native-bcrypt-cpp"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anday013%2Freact-native-bcrypt-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anday013%2Freact-native-bcrypt-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anday013%2Freact-native-bcrypt-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anday013%2Freact-native-bcrypt-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anday013","download_url":"https://codeload.github.com/anday013/react-native-bcrypt-cpp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250944100,"owners_count":21511692,"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":["bcrypt","cpp","hashing","jsi","multithreading","new-architecture","password","react-native","react-native-bcrypt","react-native-bridgeless","react-native-cpp","react-native-hash","react-native-jsi","react-native-multithreading","react-native-new-architecture","react-native-password","react-native-security","security","turbo-modules"],"created_at":"2024-11-11T00:02:39.622Z","updated_at":"2025-04-26T06:31:18.738Z","avatar_url":"https://github.com/anday013.png","language":"C++","readme":"# react-native-bcrypt-cpp\n\nNext-gen React Native library for Bcrypt hashing using pure C++ with Turbo Modules and multithreading for superior performance.\n\n**_NOTE:_** This library can be used only with New Architecture (more information about New Architecture [here](https://github.com/reactwg/react-native-new-architecture))\n\n## Features\n\n- **50x faster than JS implementation** 🚀\n- **Multithreaded for high performance without blocking the JS thread** 🧵\n- **Seamless integration with Turbo Modules** 🔌\n- **Native C++ hashing for maximum security** 🔒\n- **Supports both asynchronous and synchronous operations** ⚡️\n- **Optimized for React Native's New Architecture** 📱\n\n## Performance\n\nThe C++ implementation of Bcrypt hashing is significantly faster than the JavaScript implementation, especially for high-cost factors. Here are some benchmarks comparing the two implementations:\n\n![Comparisons](./assets/comparisons)\n\n## Demo\n\nAfter running \"Generate Hash\" function on JS side, it blocks JS Thread while the function runs (approximately 14 seconds). On the other hand, the C++ implementation runs the same function in a separate thread, allowing the JS thread to continue executing other tasks without blocking (approximately 0.3 seconds). This demonstrates the superior performance of the C++ implementation over the JavaScript implementation.\n\n|              JavaScript Demo              |                  C++ Demo                   |\n| :---------------------------------------: | :-----------------------------------------: |\n| ![JS Demo](./assets/JS_GENERATE_HASH.gif) | ![C++ Demo](./assets/C++_GENERATE_HASH.gif) |\n|          **JavaScript Hashing**           |               **C++ Hashing**               |\n\n## Installation\n\n```sh\nnpm install react-native-bcrypt-cpp\n```\n\nor\n\n```sh\nyarn add react-native-bcrypt-cpp\n```\n\n### Linking\n\n```sh\ncd ios \u0026\u0026 bundle install \u0026\u0026 RCT_NEW_ARCH_ENABLED=1 bundle exec pod install\n```\n\n## Usage\n\n### Asynchronous Hashing (Multithreaded)\n\n```js\nimport { generateHash, validatePassword } from 'react-native-bcrypt-cpp';\n\n// Generate a hash asynchronously\nconst hash = await generateHash('password', 12);\n\n// Validate a password against a hash\nconst isValid = await validatePassword('password', hash);\n```\n\n### Synchronous Hashing (Single-threaded)\n\n```js\nimport {\n  generateHashSync,\n  validatePasswordSync,\n} from 'react-native-bcrypt-cpp';\n\n// Generate a hash synchronously\nconst hash = generateHashSync('password', 12);\n\n// Validate a password against a hash synchronously\nconst isValid = validatePasswordSync('password', hash);\n```\n\n## API Reference\n\n## API Reference\n\n### `generateHash(password: string, workload: number): Promise\u003cstring\u003e`\n\nAsynchronously generates a Bcrypt hash for the given password with the specified workload factor.\n\n**Parameters:**\n\n- `password` (string): The password to hash.\n- `workload` (number): The cost factor for the hashing algorithm (e.g., 12).\n\n**Returns:**\n\n- A `Promise` that resolves to a `string` containing the generated hash.\n\n### `validatePassword(password: string, hash: string): Promise\u003cboolean\u003e`\n\nAsynchronously validates the given password against the Bcrypt hash.\n\n**Parameters:**\n\n- `password` (string): The password to validate.\n- `hash` (string): The Bcrypt hash to validate against.\n\n**Returns:**\n\n- A `Promise` that resolves to a `boolean` indicating whether the password is valid.\n\n### `generateHashSync(password: string, workload: number): string`\n\nSynchronously generates a Bcrypt hash for the given password with the specified workload factor.\n\n**Parameters:**\n\n- `password` (string): The password to hash.\n- `workload` (number): The cost factor for the hashing algorithm (e.g., 12).\n\n**Returns:**\n\n- A `string` containing the generated hash.\n\n### `validatePasswordSync(password: string, hash: string): boolean`\n\nSynchronously validates the given password against the Bcrypt hash.\n\n**Parameters:**\n\n- `password` (string): The password to validate.\n- `hash` (string): The Bcrypt hash to validate against.\n\n**Returns:**\n\n- A `boolean` indicating whether the password is valid.\n\n## Bcrypt Algorithm Source\n\nThis library implements the Bcrypt hashing algorithm in C++, adapted from the [Bcrypt.cpp project](https://github.com/hilch/Bcrypt.cpp?tab=License-1-ov-file) by Hilko Bengen.\nThis product includes software developed by Niels Provos.\n\n## Contributing\n\nSee the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\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%2Fanday013%2Freact-native-bcrypt-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanday013%2Freact-native-bcrypt-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanday013%2Freact-native-bcrypt-cpp/lists"}