Skip to content

gabrielmaialva33/nfc-guard

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