react-native-aes-lite 1.0.7 → 1.0.9

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 CHANGED
@@ -1,18 +1,209 @@
1
1
 
2
- # react-native-aes-lite
2
+ # 📦 react-native-aes-lite
3
3
 
4
- ## Install
4
+ [![npm version](https://img.shields.io/npm/v/react-native-aes-lite.svg?color=blue)](https://www.npmjs.com/package/react-native-aes-lite)
5
+ [![platforms](https://img.shields.io/badge/platform-react%20native%20%7C%20expo-green)]()
6
+ [![license](https://img.shields.io/npm/l/react-native-aes-lite.svg)]()
7
+ [![typescript](https://img.shields.io/badge/types-yes-blue)]()
5
8
 
6
- ## npm i react-native-aes-lite
9
+ Lightweight AES encryption/decryption utility for React Native and Expo. No native modules, no linking — just pure JavaScript.
7
10
 
11
+ ---
12
+
13
+ ## 📖 Overview
14
+
15
+ react-native-aes-lite provides simple AES block-based text encryption and decryption using a 128-bit key. It is ideal for app-side data scrambling, offline encoding, demos, and educational use.
16
+
17
+ ✔ Encrypt text → hex
18
+ ✔ Decrypt hex → text
19
+ ✔ Generate AES keys
20
+ ✔ Works offline
21
+ ✔ No native dependencies
22
+ ✔ React Native CLI support
23
+ ✔ Expo app support
24
+ ✔ Expo web support
25
+
26
+ ---
27
+
28
+ ## 🚨 Security Warning
29
+
30
+ This library is not suitable for securing sensitive data.
31
+
32
+ It does not implement:
33
+
34
+ - IV / salt
35
+ - AES-GCM
36
+ - AES-CBC
37
+ - key derivation
38
+ - authenticated encryption
39
+ - secure storage
40
+
41
+ If you need production-grade crypto → use a native AES solution.
42
+
43
+ ---
44
+
45
+ ## 📦 Install
46
+
47
+ ```sh
48
+ npm install react-native-aes-lite
49
+ ```
50
+
51
+ or
52
+
53
+ ```sh
54
+ yarn add react-native-aes-lite
55
+ ```
56
+
57
+ ---
58
+
59
+ ## 🚀 Usage
8
60
 
9
- ## Usage
10
61
  ```js
11
62
  import { AES, generateKey } from "react-native-aes-lite";
12
63
 
13
64
  const aes = new AES();
14
65
  const key = generateKey("hex", { length: 16 });
15
- const encrypted = aes.encrypt("hello", key);
66
+
67
+ const encrypted = aes.encrypt("hello world", key);
68
+ console.log("Encrypted:", encrypted);
69
+
16
70
  const decrypted = aes.decrypt(encrypted, key);
71
+ console.log("Decrypted:", decrypted);
72
+ ```
73
+
74
+ Example output:
75
+
76
+ ```
77
+ Encrypted: f52066d59d6c581c3918e652efe8cb45
78
+ Decrypted: hello world
79
+ ```
80
+
81
+ ---
82
+
83
+ ## 🔑 Key Generation
84
+
85
+ ```js
86
+ const key = generateKey("hex", { length: 16 });
87
+ ```
88
+
89
+ Formats supported:
90
+ - hex (recommended)
91
+ - base64
92
+ - ascii
93
+
94
+ Key lengths:
95
+ - 16 bytes (AES-128)
96
+ - 24 bytes (AES-192)
97
+ - 32 bytes (AES-256)
98
+
99
+ ---
100
+
101
+ ## 📘 API Reference
102
+
103
+ ### class AES
104
+
105
+ ```ts
106
+ new AES()
107
+ encrypt(text: string, key: string): string
108
+ decrypt(cipherHex: string, key: string): string
109
+ ```
110
+
111
+ ### generateKey(format?, options?)
112
+
113
+ ```ts
114
+ generateKey(
115
+ format?: "hex" | "base64" | "ascii",
116
+ options?: { length?: number; readable?: boolean }
117
+ ): string
118
+ ```
119
+
120
+ ---
121
+
122
+ ## 📌 Example: Saving encrypted text
123
+
124
+ ```js
125
+ const aes = new AES();
126
+ const key = generateKey("hex");
127
+
128
+ const token = "USER_SESSION_XYZ";
129
+ const encrypted = aes.encrypt(token, key);
130
+
131
+ await AsyncStorage.setItem("token", encrypted);
132
+
133
+ const stored = await AsyncStorage.getItem("token");
134
+ const decrypted = aes.decrypt(stored, key);
135
+ ```
136
+
137
+ ---
138
+
139
+ ## ⚡ Performance Notes
140
+
141
+ AES operations are synchronous.
142
+ Works best for short strings.
143
+
144
+ | Device | Speed |
145
+ |--------|-------|
146
+ | New iOS / Android | fast |
147
+ | Mid-range phones | good |
148
+ | Old hardware | slower |
149
+
150
+ Not recommended for large blobs.
151
+
152
+ ---
153
+
154
+ ## 🧭 Roadmap
155
+
156
+ Planned:
157
+ - AES-256 support
158
+ - Async API
159
+ - CBC mode
160
+ - IV generation
161
+ - UTF-8 optimization
162
+ - bundle size reduction
163
+
164
+ Not planned:
165
+ - secure storage
166
+ - authenticated encryption
167
+ - native rewrite
168
+
169
+ ---
170
+
171
+ ## 🧩 Platform Support
172
+
173
+ | Platform | Status |
174
+ |------------------|--------|
175
+ | React Native CLI | ✅ |
176
+ | Expo app | ✅ |
177
+ | Expo web | ✅ |
178
+ | Expo Snack | ❌ (npm modules unsupported) |
179
+ | TypeScript | ⚠ static warnings may appear |
180
+
181
+ ---
182
+
183
+ ## ⚠ Expo Snack
184
+
185
+ Expo Snack does not support npm installation, so this package cannot run inside Snack. Use Expo locally instead:
186
+
187
+ ```sh
188
+ expo start
189
+ ```
190
+
191
+ ---
192
+
193
+ ## 🐞 Troubleshooting
194
+
195
+ ### Error: AES is not a constructor
196
+ Use default import fallback:
197
+
198
+ ```js
199
+ import aesKit from "react-native-aes-lite";
200
+ const { AES } = aesKit;
201
+ ```
202
+
203
+ ### TS2305 — generateKey missing
204
+ Ensure latest version is installed.
17
205
 
206
+ ---
18
207
 
208
+ ## 📜 License
209
+ MIT © 2025 Ammachi
package/dist/index.d.ts CHANGED
@@ -1,4 +1,16 @@
1
1
  export class AES {
2
2
  encrypt(text: string, key: string): string;
3
- decrypt(hex: string, key: string): string;
3
+ decrypt(cipherHex: string, key: string): string;
4
4
  }
5
+
6
+ export function generateKey(
7
+ format?: string,
8
+ options?: { length?: number; readable?: boolean }
9
+ ): string;
10
+
11
+ declare const _default: {
12
+ AES: typeof AES;
13
+ generateKey: typeof generateKey;
14
+ };
15
+
16
+ export default _default;
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "react-native-aes-lite",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "AES encryption for React Native + Expo Web",
5
5
  "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
6
7
  "files": [
7
8
  "dist"
8
9
  ],