File tree Expand file tree Collapse file tree 6 files changed +20
-24
lines changed
android/src/main/java/com/encryption Expand file tree Collapse file tree 6 files changed +20
-24
lines changed Original file line number Diff line number Diff line change @@ -5,20 +5,35 @@ Encryption
55## Installation
66
77``` sh
8- npm install react-native-encryption
8+ npm install rn-encryption
9+ yarn add rn-encryption
910```
1011
1112## Usage
1213
1314
1415``` js
15- import { multiply } from ' react-native- encryption' ;
16+ import {encrypt , decrypt } from " rn- encryption"
1617
1718// ...
19+ const encryptionKey = " 1234567890123456" ;
1820
19- const result = multiply (3 , 7 );
21+ const handleEncryption = async () => {
22+
23+ try {
24+ const encrypted = await encrypt (" sometexthere" , encryptionKey);
25+
26+ const decrypted = await decrypt (encrypted, encryptionKey);
27+
28+ console .log (` Encrypted: ${ encrypted} \n Decrypted: ${ decrypted} ` );
29+ } catch (err) {
30+ console .log (' An error occurred during encryption/decryption.' );
31+ }
32+ };
2033```
2134
35+ ## I have just started to working on this repo
36+ #I am creating encryption on native side i.e kotlin and objective-C using the turbo modules
2237
2338## Contributing
2439
Original file line number Diff line number Diff line change @@ -16,13 +16,7 @@ class EncryptionModule(reactContext: ReactApplicationContext) :
1616 override fun getName (): String {
1717 return NAME
1818 }
19-
20- // Example method
21- // See https://reactnative.dev/docs/native-modules-android
22- override fun multiply (a : Double , b : Double ): Double {
23- return a * b
24- }
25-
19+
2620 override fun encrypt (data : String , key : String ): String {
2721 return try {
2822 Log .d(TAG , " Starting encryption..." )
Original file line number Diff line number Diff line change 11import { Text , View , StyleSheet } from 'react-native' ;
2- import { multiply } from 'react-native-encryption' ;
3-
4- const result = multiply ( 3 , 7 ) ;
52
63export default function App ( ) {
74 return (
85 < View style = { styles . container } >
9- < Text > Result: { result } </ Text >
6+ < Text > Result</ Text >
107 </ View >
118 ) ;
129}
Original file line number Diff line number Diff line change 55@implementation Encryption
66RCT_EXPORT_MODULE ()
77
8- - (NSNumber *)multiply:(double )a b:(double )b {
9- NSNumber *result = @(a * b);
10-
11- return result;
12- }
13-
148// Method to encrypt data
159- (NSString *)encrypt:(NSString *)data key:(NSString *)key {
1610 NSError *error = nil ;
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ import type { TurboModule } from 'react-native';
22import { TurboModuleRegistry } from 'react-native' ;
33
44export interface Spec extends TurboModule {
5- multiply ( a : number , b : number ) : number ;
65 encrypt ( data : string , key : string ) : string ;
76 decrypt ( data : string , key : string ) : string ;
87}
Original file line number Diff line number Diff line change 11import Encryption from './NativeEncryption' ;
22
3- export function multiply ( a : number , b : number ) : number {
4- return Encryption . multiply ( a , b ) ;
5- }
63export function encrypt ( data : string , key : string ) : string {
74 return Encryption . encrypt ( data , key ) ;
85}
You can’t perform that action at this time.
0 commit comments