FLUTTER ECOSYSTEM

roulljdh/encrypted_shared_preferences

暗号化された共有設定用のFlutterプラグイン

encrypted_shared_preferences のプロジェクト画像
Stars
18
Forks
10
最終プッシュ(UTC)
2022/06/11
プロジェクト状態
公開中
roulljdh GitHub avatar
GITHUB User

roulljdh ↗

Web 🕸️ and Mobile 📱 Developer

言語DartHTMLSwiftKotlinObjective-C

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 2 件

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

README を開く / 閉じる

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