Giter Site home page Giter Site logo

0x0000x / nfc_classic_mifare Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phires/nfc_classic_mifare

0.0 0.0 0.0 352 KB

License: MIT License

Ruby 3.68% C++ 21.74% C 1.48% Objective-C 0.04% Kotlin 31.03% Dart 19.45% Swift 1.20% HTML 1.92% CMake 19.45%

nfc_classic_mifare's Introduction

nfc_mifare_classic

A Flutter plugin for Android for reading and writing NFC cards

Notice

  • Only Mifare Classic
  • Only NfcA technology
  • Only works with default password

Setup

Notes

  • Remember that you shouln't write in the sector 0 of any card
  • If you write in the 4th block of any sector write down what you write this is the new password for write and read in this sector
  • In all cases the password parameter is optional, is only in the case the sector has a custom password

Thanks

This plugin in based on the original package mifare_nfc_classic of Andres Maldonado (https://github.com/MaldonadoAndres/mifare_nfc_classic/). Sadly my pull request for Null Safety was not not yet integrated, so I published my own branch with a new package name.

Usage

Check NFC Availability

// Check availability
AVAILABILITY isAvailable = await NfcClassicMifare.availability;
switch(isAvailable){
    case(AVAILABILITY.AVAILABLE):
        //NFC is enabled.
        break;
    case(AVAILABILITY.NOT_ENABLED):
        //The phone support NFC but user has to enable it.
        break;
    case(AVAILABILITY.NOT_SUPPORTED):
        //The phone doesn't support NFC.
        break;
}

Get Sector or Block Count

int _sectorCount = await NfcClassicMifare.sectorCount;
int _blockCount = await NfcClassicMifare.blockCount;

Read a specific Sector

List<String> _sector = await NfcClassicMifare.readSector(sectorIndex:index,password:password)
/*
["FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"]
*/

Read a specific Block of a specific Sector

String _block = await NfcClassicMifare.readBlock(blockIndex: _blockIndex,password:password);
/*
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
*/

Read all sectors of a card

Note: This operation take some seconds so leave the card close to the phone like for 2 seconds.

List<List<String>> _card = await NfcClassicMifare.readAll(password:password);
/*
[["FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"],
...
...
...
["FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"]]
*/

Write a specific Block of a specific Sector

bool didWrite = await  NfcClassicMifare.writeBlock(blockIndex: _blockIndex,message: _message,password:password);
/*
didWrite indicates if the operation completed successfully or not.
*/

Change Password of a Sector

await  NfcClassicMifare.changePasswordOfSector(sectorIndex: _sectorIndex,newPassword: _newPassword,password:password);

Write Raw Hexadecimal

await  NfcClassicMifare.writeRawHexToBlock(blockIndex: _blockIndex,message: rawHex,password:password);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.