v3.0.1
encrypted_shared_preferences
此插件将共享首选项作为加密值存储在设备存储中。
84喜欢 4600近 30 天下载140Pub 分数
AndroidiOSWebmacOSWindowsLinux
加密共享偏好设置的 Flutter 插件
^5.0.1^2.0.8以下为英文项目原文快照,最新内容请访问 GitHub。
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