v3.0.1
encrypted_shared_preferences
This plugin stores Shared Preferences as encrypted values on device storage.
84Likes 4.6K30-day downloads140Pub points
AndroidiOSWebmacOSWindowsLinux
Flutter plugin for Encrypted Shared Preferences
^5.0.1^2.0.8English project snapshot. Visit GitHub for the latest content.
This plugin stores Shared Preferences as encrypted values. It is decrypted when retrieved. You could use this side by side with regular Shared Preferences.
EncryptedSharedPreferences encryptedSharedPreferences = EncryptedSharedPreferences();
encryptedSharedPreferences.setString('sample', 'Hello, World!').then((bool success) {
if (success) {
print('success');
} else {
print('fail');
}
});
encryptedSharedPreferences.getString('sample').then((String value) {
print(value); /// Prints Hello, World!
});
encryptedSharedPreferences.remove('sample').then((bool success) {
if (success) {
print('success');
} else {
print('fail');
}
});
/// Clears all values, including those you saved using regular Shared Preferences.
encryptedSharedPreferences.clear().then((bool success) {
if (success) {
print('success');
} else {
print('fail');
}
});
encryptedSharedPreferences.reload();
/// You can pass a custom SharedPreferences instance (e.g. A newer version of SharedPreferences)
final prefs = await SharedPreferences.getInstance();
EncryptedSharedPreferences encryptedSharedPreferences = EncryptedSharedPreferences(prefs: prefs);
// 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);
Default mode is SIC AESMode.sic, you can override it using the mode named parameter:
EncryptedSharedPreferences encryptedSharedPreferences = EncryptedSharedPreferences(mode: AESMode.cbc);
AESMode.cbcAESMode.cfb64AESMode.ctrAESMode.ecbAESMode.ofb64GctrAESMode.ofb64AESMode.sic