Skip to content

Commit 5b3918c

Browse files
committed
example method removed and readme updated
1 parent 78293a4 commit 5b3918c

File tree

6 files changed

+20
-24
lines changed

6 files changed

+20
-24
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff 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}\nDecrypted: ${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

android/src/main/java/com/encryption/EncryptionModule.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff 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...")

example/src/App.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import { Text, View, StyleSheet } from 'react-native';
2-
import { multiply } from 'react-native-encryption';
3-
4-
const result = multiply(3, 7);
52

63
export default function App() {
74
return (
85
<View style={styles.container}>
9-
<Text>Result: {result}</Text>
6+
<Text>Result</Text>
107
</View>
118
);
129
}

ios/Encryption.mm

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55
@implementation Encryption
66
RCT_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;

src/NativeEncryption.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { TurboModule } from 'react-native';
22
import { TurboModuleRegistry } from 'react-native';
33

44
export 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
}

src/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import Encryption from './NativeEncryption';
22

3-
export function multiply(a: number, b: number): number {
4-
return Encryption.multiply(a, b);
5-
}
63
export function encrypt(data: string, key: string): string {
74
return Encryption.encrypt(data, key);
85
}

0 commit comments

Comments
 (0)