boxx 0.1.8
boxx: ^0.1.8 copied to clipboard
Boxx is your ultimate key-value storage plugin with built-in encryption
ποΈ Boxx #
Secure β’ Simple β’ Fast Flutter Storage #
Store, retrieve, and protect your data effortlessly with AES or Fernet encryption
β¨ Features #
Boxx is a lightweight storage solution with optional encryption built in. Its simple, powerful, & intuitive API gets you up and running in no time.
β
Simple β Easy-to-use key-value interface
β
Secure β Choose between AES-256 or Fernet encryption
β
Fast β Optimized for performance with minimal overhead
β
Versatile β Perfect for configs, secrets, or sensitive data
π Getting Started #
Installation #
Add Boxx to your pubspec.yaml:
dependencies:
boxx: ^0.1.7
## Import
```dart
import 'package:boxx/boxx.dart';
Getting started #
Without Encryption
late Boxx box;
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await initBox();
}
Future<void> initBox() async {
box = Boxx(mode: EncryptionMode.none);
await box.initialize();
}
With Encryption
late Boxx box;
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await initBox();
}
Future<void> initBox() async {
box = Boxx(
mode: EncryptionMode.aes,
encryptionKey: 'your-32-character-encryption-key',
);
await box.initialize();
}
Usage #
Delete Data
await box.delete('UserData');
Retrieve Data
final contents = await box.get('UserData');
Store Data
await box.put('UserData', response.body);
Encryption Utilities
// Encrypt any string
String encrypted = box.encrypt('Hello World');
debugPrint(encrypted);
// Decrypt back to original
String decrypted = box.decrypt(encrypted);
debugPrint(decrypted); // Output: Hello World
π§ API Reference
Core Methods #
| Method | Description | Returns |
|---|---|---|
put(String key, dynamic value) |
Stores data with the given key | Future<void> |
get(String key) |
Retrieves data for the given key | Future<dynamic> |
delete(String key) |
Removes data for the given key | Future<void> |
encrypt(String plaintext) |
Encrypts a string | String |
decrypt(String ciphertext) |
Decrypts an encrypted string | String |
Encryption Modes #
| Mode | Security Level | Key Length | Use Case |
|---|---|---|---|
EncryptionMode.none |
No encryption | - | Non-sensitive data |
EncryptionMode.aes |
AES-256 | 32 chars | Highly sensitive data |
EncryptionMode.fernet |
Fernet | 32 chars | General purpose encryption |
Alternatively, for a more concise version:
π‘ Best Practices #
| Practice | Description | Example |
|---|---|---|
| π Secure Keys | Never hardcode encryption keys | Use environment variables |
| π Proper Init | Always initialize after binding | WidgetsFlutterBinding.ensureInitialized() |
| π‘οΈ Error Handling | Wrap operations in try-catch | try { await box.get(); } catch(e) {} |
| π Data Types | Store JSON-serializable data | Strings, Maps, Lists, numbers |
| π Mode Selection | Choose encryption based on sensitivity | Use AES for sensitive data |
π€ Contributing We welcome contributions! Please feel free to submit issues and pull requests.
π License This project is licensed under the MIT License.