{"id":20723276,"url":"https://github.com/dhairya0907/react-native-encryption","last_synced_at":"2025-06-29T08:34:58.073Z","repository":{"id":57108141,"uuid":"434961708","full_name":"dhairya0907/react-native-encryption","owner":"dhairya0907","description":"Encryption/Decryption for React Native","archived":false,"fork":false,"pushed_at":"2021-12-08T14:44:57.000Z","size":4426,"stargazers_count":7,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-16T02:32:29.630Z","etag":null,"topics":["decryption","encryption","encryption-decryption","file-encryption","large-files","npm-package","react-native","text-encryption"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@dhairyasharma/react-native-encryption","language":"Swift","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/dhairya0907.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-04T17:10:48.000Z","updated_at":"2024-01-12T07:17:19.000Z","dependencies_parsed_at":"2022-08-20T17:11:14.923Z","dependency_job_id":null,"html_url":"https://github.com/dhairya0907/react-native-encryption","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhairya0907%2Freact-native-encryption","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhairya0907%2Freact-native-encryption/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhairya0907%2Freact-native-encryption/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhairya0907%2Freact-native-encryption/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dhairya0907","download_url":"https://codeload.github.com/dhairya0907/react-native-encryption/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224811027,"owners_count":17373903,"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":["decryption","encryption","encryption-decryption","file-encryption","large-files","npm-package","react-native","text-encryption"],"created_at":"2024-11-17T04:08:10.010Z","updated_at":"2024-11-17T04:08:10.478Z","avatar_url":"https://github.com/dhairya0907.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `@dhairyasharma/react-native-encryption`\n\n![Supports Android, iOS](https://img.shields.io/badge/platforms-android%20|%20ios%20-lightgrey.svg) [ ![MIT License](https://img.shields.io/npm/l/@react-native-community/netinfo.svg) ](/LICENSE) ![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg) [ ![Maintainer](https://img.shields.io/badge/maintainer-dhairya0907-blue) ](https://github.com/dhairya0907) [![Generic badge](https://img.shields.io/badge/version-1.0.0-blue.svg)](https://github.com/dhairya0907/react-native-encryption/releases)\n\n[![Twitter](https://img.shields.io/badge/dhairya__0907-%231DA1F2.svg?style=for-the-badge\u0026logo=Twitter\u0026logoColor=white) ](https://twitter.com/dhairya_0907) [ ![LinkedIn](https://img.shields.io/badge/linkedin-%230077B5.svg?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white) ](https://www.linkedin.com/in/dhairyasharma0907/)\n\n### Encryption/decryption for React Native.\n\n\u0026nbsp;\n\n\n# Benchmark\n\n|                                                                                                                                                                                                           |                                                \n| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| **File Details**                                                                                                                                                                                          |\n| **_File Link_**\u003cbr\u003ehttp://bit.do/benchmarkfile\u003cbr\u003e**_File Size_**\u003cbr\u003e1.09 GB                                                                                                                              |\n| **IOS Benchmark**                                                                                                                                                                                         |\n| **_Average of 100 Encryption_**\u003cbr\u003e4.859 seconds\u003cbr\u003e\u003cbr\u003e**_Average of 100 Decryption_**\u003cbr\u003e5.594 seconds\u003cbr\u003e\u003cbr\u003eCheck Log for all IOS encryption [here](https://github.com/dhairya0907/react-native-encryption/blob/3e267e006f1fd1ed115733da2a86c21437865878/benchmark/IOS_LOGS.txt#L2).\u003cbr\u003eCheck Log for all IOS decryption [here](https://github.com/dhairya0907/react-native-encryption/blob/3e267e006f1fd1ed115733da2a86c21437865878/benchmark/IOS_LOGS.txt#L110).          |\n| **Android Benchmark**                                                                                                                                                                                     |\n| **_Average of 100 Encryption_**\u003cbr\u003e20.373 seconds\u003cbr\u003e\u003cbr\u003e**_Average of 100 Decryption_**\u003cbr\u003e21.908 seconds\u003cbr\u003e\u003cbr\u003eCheck Log for all Android encryption [here](https://github.com/dhairya0907/react-native-encryption/blob/3e267e006f1fd1ed115733da2a86c21437865878/benchmark/ANDROID_LOGS.txt#L2).\u003cbr\u003eCheck Log for all Android decryption [here](https://github.com/dhairya0907/react-native-encryption/blob/3e267e006f1fd1ed115733da2a86c21437865878/benchmark/ANDROID_LOGS.txt#L109). |\n|                                                                                                                                                                                                           | \n\n\u0026nbsp;\n\n# Features\n\n- Encrypt/decrypt any length of text.\n- Encrypt/decrypt any type of file.\n- Encrypt/decrypt any size of file.\n\n\u0026nbsp;\n\n# Getting started\n\nInstall the library using either Yarn:\n\n```\nyarn add @dhairyasharma/react-native-encryption\n```\n\nor npm:\n\n```sh\nnpm install --save @dhairyasharma/react-native-encryption\n```\n\nor git:\n\n```sh\nnpm install git+https://github.com/dhairya0907/react-native-encryption.git\n```\n\n### Using React Native \u003e= 0.60\n\n\u0026nbsp;\nLinking the package manually is not required anymore with [Autolinking](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md).\n\n- **iOS Platform:**\n\n```sh\ncd ios \u0026\u0026 pod install \u0026\u0026 cd ..\n```\n\n- **Android Platform:**\n\n  Does not require any additional steps.\n\n# Usage\n\n## Import the library\n\n```javascript\nimport RNEncryptionModule from \"@dhairyasharma/react-native-encryption\";\n```\n\n## Encrypt Text\n\n```typescript\nRNEncryptionModule.encryptText(\n    plainText,\n    password\n    ).then((res: any) =\u003e {\n        if (res.status == \"success\") {\n            console.log(\"success\", res)\n        } else {\n            Alert.alert(\"Error\", res);\n        }\n        }).catch((err: any) =\u003e {\n            console.log(err);\n        });\n```\n\n- **plainText** : Plain text to be encrypted.\n- **password** : Password to encrypt the plain text.\n\n```javascript\nreturns\n\n// If text encryption is successful, it returns a JSON object with the following structure:\n{\n  \"status\": \"success\",\n  \"encryptedText\": \"encryptedText\",\n  \"iv\": \"iv\",\n  \"salt\": \"salt\"\n}\n\nor\n\n// If text encryption is unsuccessful, it returns a JSON object with the following structure:\n{\n  \"status\": \"Fail\",\n  \"error\": \"error\"\n}\n```\n\n## Decrypt Text\n\n```typescript\nRNEncryptionModule.decryptText(\n    encryptedText,\n    password,\n    iv,\n    salt).then((res: any) =\u003e {\n        if (res.status == \"success\") {\n            console.log(\"success\", res)\n        } else {\n            Alert.alert(\"Error\", res);\n        }\n        }).catch((err: any) =\u003e {\n            console.log(err);\n        });\n```\n\n- **encryptedText** : Cipher text to be decrypted.\n- **password** : Password to decrypt the cipher text.\n- **iv** : Initialization vector from encryptText.\n- **salt** : Salt from encryptText.\n\n```javascript\nreturns\n\n// If text decryption is successful, it returns a JSON object with the following structure:\n{\n  \"status\": \"success\",\n  \"decryptedText\": \"decryptedText\"\n}\n\nor\n\n// If text decryption is unsuccessful, it returns a JSON object with the following structure:\n{\n  \"status\": \"Fail\",\n  \"error\": \"error\"\n}\n```\n\n## Encrypt File\n\n```typescript\n RNEncryptionModule.encryptFile(\n      inputFilePath,\n      outputEncryptedFilePath,\n      password\n    ).then((res: any) =\u003e {\n        if (res.status == \"success\") {\n            console.log(\"success\", res)\n        } else {\n            console.log(\"error\", res);\n        }\n        }).catch((err: any) =\u003e {\n            console.log(err);\n        });\n```\n\n- **inputFilePath** : Path of the file to be encrypted.\n- **outputEncryptedFilePath** : Path of the encrypted file.\n- **password** : Password to encrypt the file.\n\n```javascript\nreturns\n\n// If file encryption is successful, it returns a JSON object with the following structure:\n{\n  \"status\": \"success\",\n  \"iv\": \"iv\",\n  \"salt\": \"salt\"\n\n}\n\nor\n\n// If file encryption is unsuccessful, it returns a JSON object with the following structure:\n{\n  \"status\": \"Fail\",\n  \"error\": \"error\"\n}\n```\n\n## Decrypt File\n\n```typescript\n RNEncryptionModule.decryptFile(\n      encryptedFilePath,\n      outputDecryptedFilePath,\n      password,\n      iv,\n      salt\n    ).then((res: any) =\u003e {\n        if (res.status == \"success\") {\n            console.log(\"success\", res)\n        } else {\n            console.log(\"error\", res);\n        }\n        }).catch((err: any) =\u003e {\n            console.log(err);\n        });\n```\n\n- **encryptedFilePath** : Path of the file to be decrypted.\n- **outputDecryptedFilePath** : Path of the decrypted file.\n- **password** : Password to decrypt the file.\n- **iv** : Initialization vector from encryptFile.\n- **salt** : Salt from encryptFile.\n\n```javascript\nreturns\n\n// If file decryption is successful, it returns a JSON object with the following structure:\n{\n  \"status\": \"success\",\n  \"message\" : \"File decrypted successfully\"\n\n}\n\nor\n\n// If file decryption is unsuccessful, it returns a JSON object with the following structure:\n{\n  \"status\": \"Fail\",\n  \"error\": \"error\"\n}\n```\n\n---\n\n**NOTE**\n\nOn android, Input or Output file path does not support **_content://_**\u0026nbsp; type file path. Please use **_file://_**\u0026nbsp; type file path.\n\nYou can use [react-native-fetch-blob stat](https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#user-content-statpathstringpromisernfetchblobstat) to get original path. See [example](https://github.com/dhairya0907/react-native-encryption/blob/3e267e006f1fd1ed115733da2a86c21437865878/example/src/App.tsx#L115).\n\n**_You will need Files and media permission for this._**\n\n---\n\n\u0026nbsp;\n\n# Acknowledgements\n\n- Inspired by [react-native-aes-gcm-crypto](https://github.com/craftzdog/react-native-aes-gcm-crypto)\n- Module template by [react-native-module-template](https://github.com/demchenkoalex/react-native-module-template)\n- IOS library by [IDZSwiftCommonCrypto](https://github.com/iosdevzone/IDZSwiftCommonCrypto)\n- Android library by [bc-java](https://github.com/bcgit/bc-java) edited using [nodejs-mybc-util](https://github.com/jbuhacoff/nodejs-mybc-util)\n\n\u0026nbsp;\n\n# Author\n\nDhairya Sharma | [@dhairya0907](https://github.com/dhairya0907)\n\n\u0026nbsp;\n\n# License\n\nThe library is released under the MIT license. For more information see [`LICENSE`](/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhairya0907%2Freact-native-encryption","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdhairya0907%2Freact-native-encryption","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhairya0907%2Freact-native-encryption/lists"}