일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- appstore connect guideline
- app store connect guideline
- undefined name
- providernotfoundexception
- flutter_dotenv
- GetX
- tflite_flutter
- 채팅 메시지 정렬
- appstroe connect guideline
- withopacity
- exception caught by image resource service
- app stroe connect guideline
- youtube_player_flutter
- exception
- dart sdk version upgrade
- guideline 4.3(a)
- information needed
- AI
- app completeness
- 플러터
- guideline 1.5
- buildcontext
- flutter doctor -v
- flutter_secure_storage
- 에러
- Flutter
- infinity or nan toint
- permissiondeniedexception
- .dio
- pub.dev
Archives
- Today
- Total
min_chan님의 블로그
[pub.dev] - flutter_secure_storage 본문
await storage.write(key: '키값 지정', value: '밸류 값 지정');
flutter_secure_storage란?
flutter_secure_storage는 보안이 필요한 데이터를 안전하게 저장할 수 있도록 도와주는 Flutter용 라이브러리
- iOS: Keychain을 사용
- Android: AES 암호화 (RSA 키로 AES 키 암호화, KeyStore에 저장)
flutter_secure_storage 사용법
1. 패키지 설치
- 터미널에서 pub add 명령어를 실행해 설치
2. Configure Android version
- [project]/android/app/build.gradle 에서 minSdkVersion을 18이상으로 변경
3. 기본 사용법
- SecureStroage instance 생성하기
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
final storage = FlutterSecureStorage();
- 데이터 저장하기
await storage.write(key: 'test_token_key_name', value: 'test_token_value');
- 데이터 읽기
String? token = await storage.read(key: 'test_token_key_name');
print(token); // test_token_value
- 모든 데이터 읽기
Map<String, String> allValues = await storage.readAll();
- 데이터 삭제하기
await storage.delete(key: 'test_token_key_name'); // test_token_key_name이란 키를 가진 데이터 삭제
- 모든 데이터 삭제하기
await storage.deleteAll();
+ flutter_secure_storage VS shared_preferences
기능 |
flutter_secure_storage |
shared_preferences |
보안 | 강력한 암호화 (AES, RSA, KeyStore) | 평문 저장 |
저장 방식 | Keychain (IOS) EncryptedSharedPreferences (AOS) |
단순 Key-Value 저장 데이터 암호화 X |
주요 용도 | 인증 토큰, 민감한 사용자 정보 저장 | 설정값, 일반 사용자 데이터 저장 |
'pub.dev' 카테고리의 다른 글
[pub.dev] - dio (0) | 2025.03.14 |
---|---|
[pub.dev] - http (0) | 2025.03.13 |
[pub.dev] - flutter_dotenv (0) | 2025.02.27 |
[pub.dev] - provider (0) | 2025.02.24 |
[pub.dev] - pub.dev (0) | 2025.02.19 |