encriptation

Flutter Dart Hive Encrypt

Android iOS Web

encriptation

encriptation is a Flutter/Dart library to securely store and retrieve data using Hive and AES encryption. It works on Android, iOS, Web, Linux, and Windows.

Features

  • Secure storage with AES encryption
  • Easy API for saving, reading, and deleting values
  • Works on all Flutter platforms

Installation

Add the package to your pubspec.yaml:

dependencies:
  encriptation: ^0.0.1

Then run:

flutter pub get

Configuration

  1. Create a .env file in your project root (or in the example/ folder if using the example):
ENCRIPTATION_KEY=12345678901234567890123456789012
  1. Add the .env file to the assets section of your pubspec.yaml:
flutter:
  uses-material-design: true
  assets:
    - .env

Basic Usage

import 'package:encriptation/encriptation.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';

void main() async {
  await dotenv.load(fileName: '.env');
  final secureStorage = SecureStorage(dotenv.env['ENCRIPTATION_KEY']!);

  // Save an encrypted value
  await secureStorage.saveString('key', 'value', encryptValue: true);

  // Read the decrypted value
  final value = await secureStorage.readString('key', encryptedValue: true);
  print(value); // 'value'
}

Store and Read Multiple Values

// Store multiple values
await secureStorage.saveString('key1', 'value1', encryptValue: true);
await secureStorage.saveString('key2', 'value2', encryptValue: true);

// Read multiple values
final v1 = await secureStorage.readString('key1', encryptedValue: true);
final v2 = await secureStorage.readString('key2', encryptedValue: true);

Delete a Value

await SecureStorage.deleteKey('key1');

Example App

See the example/ folder for a complete Flutter app using this library.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributors

Junior García
Junior García

github.com/Juniorwebprogrammer