Search packages, repositories and app categories

Package detailsv3.0.1

encrypted_shared_preferences

This plugin stores Shared Preferences as encrypted values on device storage.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
7K
Likes
84
Pub points
140

Install package

flutter pub add encrypted_shared_preferences

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

EncryptedSharedPreferences is a Flutter plugin that securely stores key-value pairs by encrypting data before saving it to device storage. It extends the functionality of SharedPreferences with end-to-end encryption, ensuring sensitive information like tokens, passwords, or user preferences remain protected from unauthorized access. The plugin uses strong encryption algorithms and integrates seamlessly with Android, iOS, Web, macOS, Windows, and Linux platforms. Ideal for apps requiring secure local data persistence without exposing credentials.

Use cases

  • Storing authentication tokens
  • Saving user preferences securely
  • Protecting sensitive app data
  • Secure session management
  • Encrypting API keys
  • Local data protection in regulated environments

Key features

  • End-to-end encryption
  • Cross-platform support
  • Seamless integration with SharedPreferences
  • Secure key management
  • Supports all major desktop and mobile platforms
  • Easy-to-use API

Suitable for

  • Apps handling sensitive user data
  • Compliance-focused applications
  • Authentication systems
  • Privacy-centric apps
  • Mobile-first applications
  • Secure configuration storage

Considerations

  • Requires proper key handling
  • May have performance overhead due to encryption
  • Not suitable for large datasets
  • Depends on platform-specific security features
  • Needs careful implementation to avoid key leakage
  • Limited debugging capabilities due to encrypted format

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Encrypted Shared Preferences

Pub

This plugin stores Shared Preferences as encrypted values. It is decrypted when retrieved. You could use this side by side with regular Shared Preferences.

Usage

Instantiate class:
EncryptedSharedPreferences encryptedSharedPreferences = EncryptedSharedPreferences();
Save value:
encryptedSharedPreferences.setString('sample', 'Hello, World!').then((bool success) {
    if (success) {
        print('success');
    } else {
        print('fail');
    }
});
Retrieve value:
encryptedSharedPreferences.getString('sample').then((String value) {
    print(value); /// Prints Hello, World!
});
Remove value:
encryptedSharedPreferences.remove('sample').then((bool success) {
    if (success) {
        print('success');
    } else {
        print('fail');
    }
});
Clear values:
/// Clears all values, including those you saved using regular Shared Preferences.
encryptedSharedPreferences.clear().then((bool success) {
    if (success) {
        print('success');
    } else {
        print('fail');
    }
});
Reload
encryptedSharedPreferences.reload();
Optional: Pass custom SharedPreferences instance
/// You can pass a custom SharedPreferences instance (e.g. A newer version of SharedPreferences)
final prefs = await SharedPreferences.getInstance();
EncryptedSharedPreferences encryptedSharedPreferences = EncryptedSharedPreferences(prefs: prefs);
Access internal SharedPreferences instance
// You can access the internal SharedPreferences instance to invoke methods not exposed by regular EncryptedSharedPreferences
SharedPreferences instance = await encryptedSharedPreferences.getInstance();
int counter = 1;

/// Access SharedPreferences' setInt method
await instance.setInt('counter', counter);
Modes of operation

Default mode is SIC AESMode.sic, you can override it using the mode named parameter:

EncryptedSharedPreferences encryptedSharedPreferences = EncryptedSharedPreferences(mode: AESMode.cbc);
Supported modes are:
  • CBC AESMode.cbc
  • CFB-64 AESMode.cfb64
  • CTR AESMode.ctr
  • ECB AESMode.ecb
  • OFB-64/GCTR AESMode.ofb64Gctr
  • OFB-64 AESMode.ofb64
  • SIC AESMode.sic

Categories

Dependencies

Dependency list 2 items

Source repository

Projects using this package