react-native-des-machine 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -17
- package/package.json +27 -4
package/README.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# react-native-des-machine
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/react-native-des-machine)
|
|
4
|
+
[](https://www.npmjs.com/package/react-native-des-machine)
|
|
5
|
+
[](https://github.com/NeRo8/react-native-des-machine/blob/main/LICENSE)
|
|
6
|
+
[](https://reactnative.dev/)
|
|
7
|
+
|
|
3
8
|
A React Native TurboModule that provides DES (Data Encryption Standard) encryption and decryption with support for multiple cipher modes, padding schemes, and output formats.
|
|
4
9
|
|
|
5
10
|
## Features
|
|
@@ -10,6 +15,16 @@ A React Native TurboModule that provides DES (Data Encryption Standard) encrypti
|
|
|
10
15
|
- Output formats: Base64, Hexadecimal
|
|
11
16
|
- Native implementation for both iOS and Android
|
|
12
17
|
- TurboModule support for improved performance
|
|
18
|
+
- Pre-built options arrays for easy UI integration
|
|
19
|
+
- Full TypeScript support
|
|
20
|
+
|
|
21
|
+
## Compatibility
|
|
22
|
+
|
|
23
|
+
| Platform | Minimum Version |
|
|
24
|
+
| ------------ | --------------- |
|
|
25
|
+
| iOS | 13.0+ |
|
|
26
|
+
| Android | API 21+ (5.0) |
|
|
27
|
+
| React Native | 0.71+ |
|
|
13
28
|
|
|
14
29
|
## Installation
|
|
15
30
|
|
|
@@ -42,14 +57,7 @@ No additional setup required. The library auto-links on Android.
|
|
|
42
57
|
### Basic Example
|
|
43
58
|
|
|
44
59
|
```typescript
|
|
45
|
-
import {
|
|
46
|
-
setMachineParams,
|
|
47
|
-
encrypt,
|
|
48
|
-
decrypt,
|
|
49
|
-
Mode,
|
|
50
|
-
Padding,
|
|
51
|
-
Format,
|
|
52
|
-
} from 'react-native-des-machine';
|
|
60
|
+
import { setMachineParams, encrypt, decrypt } from 'react-native-des-machine';
|
|
53
61
|
|
|
54
62
|
// Initialize the DES machine with your encryption key
|
|
55
63
|
setMachineParams({
|
|
@@ -95,13 +103,41 @@ const decrypted = decrypt(encrypted);
|
|
|
95
103
|
console.log('Decrypted:', decrypted);
|
|
96
104
|
```
|
|
97
105
|
|
|
106
|
+
### Using Pre-built Options for UI
|
|
107
|
+
|
|
108
|
+
The library exports pre-built option arrays that can be used directly with dropdown/picker components:
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import {
|
|
112
|
+
modeOptions,
|
|
113
|
+
paddingOptions,
|
|
114
|
+
formatOptions,
|
|
115
|
+
} from 'react-native-des-machine';
|
|
116
|
+
|
|
117
|
+
// modeOptions structure:
|
|
118
|
+
// [
|
|
119
|
+
// { label: 'ECB (Electronic Codebook)', value: 'ECB' },
|
|
120
|
+
// { label: 'CBC (Cipher Block Chaining)', value: 'CBC' },
|
|
121
|
+
// { label: 'CFB (Cipher Feedback)', value: 'CFB' },
|
|
122
|
+
// { label: 'OFB (Output Feedback)', value: 'OFB' },
|
|
123
|
+
// { label: 'CTR (Counter)', value: 'CTR' },
|
|
124
|
+
// ]
|
|
125
|
+
|
|
126
|
+
// Use with React Native Picker or any dropdown component
|
|
127
|
+
<Picker selectedValue={selectedMode} onValueChange={setSelectedMode}>
|
|
128
|
+
{modeOptions.map((option) => (
|
|
129
|
+
<Picker.Item key={option.value} label={option.label} value={option.value} />
|
|
130
|
+
))}
|
|
131
|
+
</Picker>;
|
|
132
|
+
```
|
|
133
|
+
|
|
98
134
|
## API Reference
|
|
99
135
|
|
|
100
|
-
###
|
|
136
|
+
### Functions
|
|
101
137
|
|
|
102
|
-
|
|
138
|
+
#### `setMachineParams(params: DesMachineParams): void`
|
|
103
139
|
|
|
104
|
-
|
|
140
|
+
Initialize the DES machine with encryption parameters. Must be called before `encrypt()` or `decrypt()`.
|
|
105
141
|
|
|
106
142
|
| Parameter | Type | Required | Default | Description |
|
|
107
143
|
| -------------- | ----------------------- | -------- | ---------- | ------------------------------------- |
|
|
@@ -110,7 +146,7 @@ Initialize the DES machine with encryption parameters.
|
|
|
110
146
|
| `padding` | `PaddingEncryptionType` | No | `'PKCS7'` | Padding scheme |
|
|
111
147
|
| `outputFormat` | `OutputFormatType` | No | `'BASE64'` | Output encoding format |
|
|
112
148
|
|
|
113
|
-
|
|
149
|
+
#### `encrypt(text: string): string`
|
|
114
150
|
|
|
115
151
|
Encrypt plaintext using the configured DES parameters.
|
|
116
152
|
|
|
@@ -118,7 +154,7 @@ Encrypt plaintext using the configured DES parameters.
|
|
|
118
154
|
- **Returns:** Encrypted string in the configured output format
|
|
119
155
|
- **Throws:** Error if `setMachineParams()` has not been called
|
|
120
156
|
|
|
121
|
-
|
|
157
|
+
#### `decrypt(text: string): string`
|
|
122
158
|
|
|
123
159
|
Decrypt ciphertext using the configured DES parameters.
|
|
124
160
|
|
|
@@ -126,9 +162,9 @@ Decrypt ciphertext using the configured DES parameters.
|
|
|
126
162
|
- **Returns:** Decrypted plaintext string
|
|
127
163
|
- **Throws:** Error if `setMachineParams()` has not been called
|
|
128
164
|
|
|
129
|
-
|
|
165
|
+
### Constants
|
|
130
166
|
|
|
131
|
-
|
|
167
|
+
#### Mode
|
|
132
168
|
|
|
133
169
|
| Constant | Value | Description |
|
|
134
170
|
| ---------- | ------- | ----------------------------- |
|
|
@@ -138,7 +174,7 @@ Decrypt ciphertext using the configured DES parameters.
|
|
|
138
174
|
| `Mode.OFB` | `'OFB'` | Output Feedback |
|
|
139
175
|
| `Mode.CTR` | `'CTR'` | Counter |
|
|
140
176
|
|
|
141
|
-
|
|
177
|
+
#### Padding
|
|
142
178
|
|
|
143
179
|
| Constant | Value | Description |
|
|
144
180
|
| ------------------ | ------------ | ------------------------ |
|
|
@@ -147,18 +183,46 @@ Decrypt ciphertext using the configured DES parameters.
|
|
|
147
183
|
| `Padding.ZERO` | `'ZERO'` | Zero padding |
|
|
148
184
|
| `Padding.NONE` | `'NONE'` | No padding |
|
|
149
185
|
|
|
150
|
-
|
|
186
|
+
#### Format
|
|
151
187
|
|
|
152
188
|
| Constant | Value | Description |
|
|
153
189
|
| --------------- | ---------- | ------------------------- |
|
|
154
190
|
| `Format.BASE64` | `'BASE64'` | Base64 encoding (default) |
|
|
155
191
|
| `Format.HEX` | `'HEX'` | Hexadecimal encoding |
|
|
156
192
|
|
|
193
|
+
### Pre-built Options Arrays
|
|
194
|
+
|
|
195
|
+
These arrays are useful for building UI components like dropdowns or pickers:
|
|
196
|
+
|
|
197
|
+
| Export | Type | Description |
|
|
198
|
+
| ---------------- | -------------------------------------- | --------------------------- |
|
|
199
|
+
| `modeOptions` | `OptionsList<ModeEncryptionType>[]` | Mode options with labels |
|
|
200
|
+
| `paddingOptions` | `OptionsList<PaddingEncryptionType>[]` | Padding options with labels |
|
|
201
|
+
| `formatOptions` | `OptionsList<OutputFormatType>[]` | Format options with labels |
|
|
202
|
+
|
|
203
|
+
Each option has the structure: `{ label: string, value: string }`
|
|
204
|
+
|
|
157
205
|
## TypeScript Support
|
|
158
206
|
|
|
159
207
|
The library includes full TypeScript definitions:
|
|
160
208
|
|
|
161
209
|
```typescript
|
|
210
|
+
import {
|
|
211
|
+
// Functions
|
|
212
|
+
setMachineParams,
|
|
213
|
+
encrypt,
|
|
214
|
+
decrypt,
|
|
215
|
+
// Constants
|
|
216
|
+
Mode,
|
|
217
|
+
Padding,
|
|
218
|
+
Format,
|
|
219
|
+
// Pre-built options
|
|
220
|
+
modeOptions,
|
|
221
|
+
paddingOptions,
|
|
222
|
+
formatOptions,
|
|
223
|
+
} from 'react-native-des-machine';
|
|
224
|
+
|
|
225
|
+
// Types
|
|
162
226
|
import type {
|
|
163
227
|
DesMachineParams,
|
|
164
228
|
ModeEncryptionType,
|
|
@@ -167,6 +231,23 @@ import type {
|
|
|
167
231
|
} from 'react-native-des-machine';
|
|
168
232
|
```
|
|
169
233
|
|
|
234
|
+
## Complete Exports
|
|
235
|
+
|
|
236
|
+
| Export | Type | Description |
|
|
237
|
+
| ----------------------- | -------- | -------------------------------- |
|
|
238
|
+
| `setMachineParams` | Function | Initialize DES with parameters |
|
|
239
|
+
| `encrypt` | Function | Encrypt plaintext |
|
|
240
|
+
| `decrypt` | Function | Decrypt ciphertext |
|
|
241
|
+
| `Mode` | Constant | Cipher mode constants |
|
|
242
|
+
| `Padding` | Constant | Padding scheme constants |
|
|
243
|
+
| `Format` | Constant | Output format constants |
|
|
244
|
+
| `modeOptions` | Array | Pre-built mode options for UI |
|
|
245
|
+
| `paddingOptions` | Array | Pre-built padding options for UI |
|
|
246
|
+
| `formatOptions` | Array | Pre-built format options for UI |
|
|
247
|
+
| `ModeEncryptionType` | Type | TypeScript type for modes |
|
|
248
|
+
| `PaddingEncryptionType` | Type | TypeScript type for padding |
|
|
249
|
+
| `OutputFormatType` | Type | TypeScript type for formats |
|
|
250
|
+
|
|
170
251
|
## Security Notice
|
|
171
252
|
|
|
172
253
|
DES is considered cryptographically weak by modern standards due to its 56-bit key size. For production applications requiring strong encryption, consider using AES or other modern algorithms. This library is suitable for:
|
|
@@ -181,6 +262,13 @@ DES is considered cryptographically weak by modern standards due to its 56-bit k
|
|
|
181
262
|
- [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request)
|
|
182
263
|
- [Code of conduct](CODE_OF_CONDUCT.md)
|
|
183
264
|
|
|
265
|
+
## Support
|
|
266
|
+
|
|
267
|
+
If you find this library helpful, please consider giving it a star on GitHub!
|
|
268
|
+
|
|
269
|
+
- [Report a bug](https://github.com/NeRo8/react-native-des-machine/issues)
|
|
270
|
+
- [Request a feature](https://github.com/NeRo8/react-native-des-machine/issues)
|
|
271
|
+
|
|
184
272
|
## License
|
|
185
273
|
|
|
186
274
|
MIT
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-des-machine",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "React Native
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "React Native DES encryption and decryption library with TurboModule support. Encrypt and decrypt text using DES algorithm with multiple cipher modes (ECB, CBC, CFB, OFB, CTR), padding schemes (PKCS7, ISO10126, Zero, None), and output formats (Base64, Hex) for iOS and Android.",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -43,7 +43,31 @@
|
|
|
43
43
|
"keywords": [
|
|
44
44
|
"react-native",
|
|
45
45
|
"ios",
|
|
46
|
-
"android"
|
|
46
|
+
"android",
|
|
47
|
+
"des",
|
|
48
|
+
"encryption",
|
|
49
|
+
"decryption",
|
|
50
|
+
"crypto",
|
|
51
|
+
"cryptography",
|
|
52
|
+
"cipher",
|
|
53
|
+
"encrypt",
|
|
54
|
+
"decrypt",
|
|
55
|
+
"security",
|
|
56
|
+
"turbo-module",
|
|
57
|
+
"turbomodule",
|
|
58
|
+
"native-module",
|
|
59
|
+
"des-encryption",
|
|
60
|
+
"des-decryption",
|
|
61
|
+
"ecb",
|
|
62
|
+
"cbc",
|
|
63
|
+
"pkcs7",
|
|
64
|
+
"base64",
|
|
65
|
+
"hex",
|
|
66
|
+
"react-native-encryption",
|
|
67
|
+
"react-native-crypto",
|
|
68
|
+
"react-native-security",
|
|
69
|
+
"mobile-encryption",
|
|
70
|
+
"text-encryption"
|
|
47
71
|
],
|
|
48
72
|
"repository": {
|
|
49
73
|
"type": "git",
|
|
@@ -89,7 +113,6 @@
|
|
|
89
113
|
"workspaces": [
|
|
90
114
|
"example"
|
|
91
115
|
],
|
|
92
|
-
"packageManager": "yarn@4.11.0",
|
|
93
116
|
"react-native-builder-bob": {
|
|
94
117
|
"source": "src",
|
|
95
118
|
"output": "lib",
|