A sophisticated Flutter application for securely writing NFC tags with unique codes and Brazilian CPF validation
FeaturesΒ Β Β |Β Β Β SecurityΒ Β Β |Β Β Β TechnologiesΒ Β Β |Β Β Β InstallationΒ Β Β |Β Β Β ConfigurationΒ Β Β |Β Β Β UsageΒ Β Β |Β Β Β License
- Unique Code Generation - 8-character secure codes for each tag
- Anti-Replication Protection - Prevents code reuse and duplication
- Multiple Tag Support - Write up to 8 different datasets per NFC tag
- Real-Time Validation - Instant verification of code validity
- Secure Storage - Encrypted storage for sensitive data using Flutter Secure Storage
- Usage Tracking - Monitor and prevent duplicate code usage
- π Enterprise Logging - Complete NFC operation audit trail
- π Cloud Synchronization - Real-time data backup with Supabase
- CPF Validation - Built-in Brazilian CPF document validation
- CEP Lookup - Automatic postal code verification and address lookup
- Portuguese Interface - Fully localized in Portuguese
- Brazilian Standards - Compliance with local data protection requirements
- Local Storage - Secure local data persistence with SharedPreferences
- Riverpod State Management - Reactive state management with code generation
- Material Design 3 - Modern UI components with light/dark theme support
- Clean Architecture - Organized code structure with separation of concerns
- Type Safety - Full Dart null safety implementation
- Code Generation - Automated provider and JSON serialization generation
- π Supabase Integration - Real-time backend with PostgreSQL database
- π Cloud Authentication - Secure user management and session handling
# Security Measures:
β
8-character unique code generation
β
Code reuse prevention system
β
Encrypted secure storage
β
Usage history tracking
β
Anti-tampering validation
β
Secure key management# Security Implementation:
- Flutter Secure Storage for sensitive data
- Local validation before NFC write
- Code uniqueness verification
- Encrypted user data storage
- Secure token management
- Protected against replay attacks
- π Cloud data encryption with Supabase
- π Operation logging and audit trails# NFC Protection:
- Unique identifiers per tag
- Multiple dataset support (up to 8)
- Secure write protocols
- Tag authentication
- Anti-cloning measures
- π Enterprise operation logging
- π Real-time monitoring and alerts- Flutter 3.9.0+ - Cross-platform mobile framework
- Dart 3.0+ - Modern programming language
- Material Design 3 - Contemporary UI components
- Supabase 2.5.6 - Real-time backend-as-a-service
- PostgreSQL - Robust relational database
- Real-time subscriptions - Live data synchronization
- Authentication - Built-in user management
- Riverpod 2.4.9 - Reactive state management
- riverpod_annotation 2.3.3 - Code generation annotations
- riverpod_generator 2.3.9 - Provider code generation
- nfc_manager 4.0.2 - NFC tag reading and writing
- NFC Operation Logging - Enterprise-level operation tracking
- Native Android/iOS NFC - Platform-specific NFC implementations
- Hardware Security - Secure element integration where available
- all_validations_br 3.0.0 - Brazilian document validation
- search_cep 4.0.2 - Brazilian postal code API integration
- Portuguese Localization - Full app translation and formatting
- flutter_secure_storage 9.0.0 - Encrypted key-value storage
- shared_preferences 2.2.2 - Local preferences storage
- http 1.1.0 - HTTP client for API calls
- build_runner 2.4.7 - Code generation automation
- json_annotation 4.8.1 - JSON serialization annotations
- json_serializable 6.7.1 - JSON code generation
- flutter_lints 5.0.0 - Dart/Flutter linting rules
- Flutter SDK 3.9.0+
- Android Studio or * VS Code*
- Git
- NFC-enabled Device (Android/iOS with NFC support)
- Clone the repository
git clone https://github.com/gabrielmaialva33/nfc-guard.git
cd nfc-guard- Install dependencies
flutter pub get- Generate code
flutter packages pub run build_runner build- Check Flutter setup
flutter doctor- Run on device
# Android device (NFC required)
flutter run
# iOS device (NFC required)
flutter run -d ios
# Check connected devices
flutter devices- Build for production
# Android APK
flutter build apk --release
# iOS (requires Xcode and Apple Developer account)
flutter build ios --release<!-- Required for NFC functionality -->
<uses-permission android:name="android.permission.NFC" /><uses-feature
android:name="android.hardware.nfc" android:required="true" />
<!-- Optional: for enhanced NFC features -->
<uses-permission android:name="android.permission.NFC_PREFERRED_PAYMENT_INFO" /><!-- Info.plist -->
<key>NFCReaderUsageDescription</key><string>This app uses NFC to write secure tags with unique
codes
</string>
<!-- Required NFC entitlements -->
<key>com.apple.developer.nfc.readersession.formats</key><array>
<string>NDEF</string>
<string>TAG</string>
</array>- Watch for Changes (Development):
flutter packages pub run build_runner watch- One-time Generation:
flutter packages pub run build_runner build- Clean and Rebuild:
flutter packages pub run build_runner clean
flutter packages pub run build_runner build --delete-conflicting-outputsCreate necessary configuration files:
// lib/core/config/supabase_config.dart
class SupabaseConfig {
static const String supabaseUrl = 'YOUR_SUPABASE_URL';
static const String supabaseAnonKey = 'YOUR_SUPABASE_ANON_KEY';
}
// lib/core/config/app_config.dart
class AppConfig {
static const String cepApiUrl = 'https://viacep.com.br/ws/';
static const bool enableDebugMode = false;
static const bool enableNfcLogging = true;
}- Launch App - Open NFCGuard
- Authentication - Enter CPF for Brazilian users
- Generate Code - Create unique 8-character security code
- Prepare NFC Tag - Hold NFC tag ready
- Write Tag - Tap "Write to NFC" and hold tag to device
- Verification - Confirm successful write and code storage
# Step-by-step Process:
1. π± Open NFCGuard app
2. π Validate Brazilian CPF
3. π Generate unique security code
4. π‘ Enable NFC on device
5. π·οΈ Place NFC tag near device
6. βοΈ Write data to tag
7. β
Verify successful write
8. πΎ Store usage historyCode Generation:
- Automatically generates 8-character codes
- Validates uniqueness against stored history
- Prevents code replication and reuse
- Encrypts codes in secure storage
Code Validation:
- Real-time validation during generation
- Checks against previously used codes
- Validates format and structure
- Provides instant feedback
Usage Tracking:
- Records all generated codes
- Tracks write timestamps
- Prevents duplicate usage
- Maintains audit trail
# Compatible NFC Tag Types:
β
NTAG213 (180 bytes)
β
NTAG215 (540 bytes)
β
NTAG216 (924 bytes)
β
Mifare Classic 1K/4K
β
Mifare Ultralight
β
ISO14443 Type A/B
β
FeliCa (Android only)CPF Validation:
- Real-time CPF format validation
- Mathematical verification
- Error handling with Portuguese messages
- Integration with user authentication
CEP Integration:
- Automatic address lookup
- Postal code validation
- Brazilian address formatting
- Integration with user registration
# Run all tests
flutter test
# Run with coverage
flutter test --coverage
# Run specific test file
flutter test test/unit/nfc_service_test.dart
# Integration tests (requires device)
flutter test integration_test/- Physical Device: NFC functionality requires real hardware
- NFC Tags: Various tag types for compatibility testing
- Test Environment: Isolated test codes to prevent conflicts
- Mock Services: Unit tests with mocked NFC operations
This project is under the MIT license. See LICENSE for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/SecureNFCFeature) - Commit your changes (
git commit -m 'Add secure NFC writing feature') - Push to the branch (
git push origin feature/SecureNFCFeature) - Open a Pull Request
If you find this project helpful, please give it a star β to help others discover it!
For support or questions:
- π§ Email: gabrielmaialva33@gmail.com
- π¬ Telegram: @mrootx
- π GitHub Issues: Create an issue
Made with β€οΈ by Maia - Passionate about secure mobile solutions!
- π§ Email: gabrielmaialva33@gmail.com
- π¬ Telegram: @mrootx
- π GitHub: @gabrielmaialva33
Β© 2017-present Maia
