How flutter secure storage plugin stores the key in both android and iOS ?
#flutter#storage#android#ios
Answer
Flutter Secure Storage Plugin
flutter_secure_storage uses platform-specific secure storage:
Android Implementation
Uses Android Keystore (hardware-backed when available):
java// Under the hood - Android code KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore"); keyStore.load(null); SecretKey key = (SecretKey) keyStore.getKey("key_alias", null);
Process:
- Data encrypted with AES key
- Key stored in AndroidKeystore
- Key protected by device lock screen
- Hardware acceleration if available
iOS Implementation
Uses iOS Keychain:
swift// iOS Keychain - secure by default SecurityClass: kSecClassGenericPassword AccessibleAttribute: kSecAttrAccessibleWhenUnlockedThisDeviceOnly
Process:
- Data encrypted and stored in Keychain
- Protected by device passcode
- Hardware-backed on modern devices
- Requires authentication to access
Comparison
| Feature | Android | iOS |
|---|---|---|
| Storage | AndroidKeystore | Keychain |
| Encryption | AES | Hardware |
| Hardware | When available | Always |
| Access Control | Device lock | Biometric/Passcode |
Usage
dartfinal storage = FlutterSecureStorage(); await storage.write(key: 'token', value: 'secret_token'); final token = await storage.read(key: 'token'); await storage.delete(key: 'token');
Security: Both methods are cryptographically secure.