Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

242 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


NFCGuard
NFCGuard - Secure NFC Tag Writer with Unique Code Protection 🔐

A sophisticated Flutter application for securely writing NFC tags with unique codes and Brazilian CPF validation

Flutter Dart Platform License Made with Love


Features   |    Security   |    Technologies   |    Installation   |    Configuration   |    Usage   |    License


✨ Features

Secure NFC Writing 🔐

  • 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

Brazilian Integration 🇧🇷

  • 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

Modern Architecture 🏗️

  • 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 Features

Code Protection System 🔒

# Security Measures:
✅ 8-character unique code generation
✅ Code reuse prevention system
✅ Encrypted secure storage
✅ Usage history tracking
✅ Anti-tampering validation
✅ Secure key management

Data Protection

# 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 Security

# 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

💻 Technologies

Core Framework

Backend & Database

  • 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

State Management & Architecture

NFC & Hardware

  • 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

Brazilian Localization

  • 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

Data & Storage

Development Tools


📦 Installation

Prerequisites

Quick Start

  1. Clone the repository
git clone https://github.com/gabrielmaialva33/nfc-guard.git
cd nfc-guard
  1. Install dependencies
flutter pub get
  1. Generate code
flutter packages pub run build_runner build
  1. Check Flutter setup
flutter doctor
  1. Run on device
# Android device (NFC required)
flutter run

# iOS device (NFC required)
flutter run -d ios

# Check connected devices
flutter devices
  1. Build for production
# Android APK
flutter build apk --release

# iOS (requires Xcode and Apple Developer account)
flutter build ios --release

⚙️ Configuration

NFC Permissions

Android

<!-- 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" />

iOS

<!-- 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>

Code Generation Setup

  1. Watch for Changes (Development):
flutter packages pub run build_runner watch
  1. One-time Generation:
flutter packages pub run build_runner build
  1. Clean and Rebuild:
flutter packages pub run build_runner clean
flutter packages pub run build_runner build --delete-conflicting-outputs

Environment Configuration

Create 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;
}

🔌 Usage

Basic Workflow

  1. Launch App - Open NFCGuard
  2. Authentication - Enter CPF for Brazilian users
  3. Generate Code - Create unique 8-character security code
  4. Prepare NFC Tag - Hold NFC tag ready
  5. Write Tag - Tap "Write to NFC" and hold tag to device
  6. Verification - Confirm successful write and code storage

NFC Tag Writing Process

# 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 history

Code Management

Code 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

Supported NFC Tags

# 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)

Brazilian Features

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

🧪 Testing

Run Tests

# 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/

NFC Testing Requirements

  • 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

📝 License

This project is under the MIT license. See LICENSE for details.


🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/SecureNFCFeature)
  3. Commit your changes (git commit -m 'Add secure NFC writing feature')
  4. Push to the branch (git push origin feature/SecureNFCFeature)
  5. Open a Pull Request

⭐ Support

If you find this project helpful, please give it a star ⭐ to help others discover it!

For support or questions:


👥 Author

Maia

Made with ❤️ by Maia - Passionate about secure mobile solutions!


© 2017-present Maia

About

🔐 NFCGuard - Secure NFC Tag Writer with Unique Code Protection

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages