{"id":26418600,"url":"https://github.com/aarsol-pvt-ltd/mifarepy","last_synced_at":"2026-03-18T00:03:27.130Z","repository":{"id":282527823,"uuid":"948881701","full_name":"AARSOL-Pvt-Ltd/mifarepy","owner":"AARSOL-Pvt-Ltd","description":"A Python library that enables seamless communication with MIFARE RFID card readers, supporting serial (RS232, USB) interfaces and GNetPlus protocol.","archived":false,"fork":false,"pushed_at":"2025-03-15T15:06:47.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T16:19:33.640Z","etag":null,"topics":["embedded","gnetplus","hardware","mifare","mifare-classic","mifare-classic-1k","mifare-ultralight","mifare1k","mifareclassic","nfc","nfc-card-reader","nfc-reader","pymifare","python","python3","rfid","rfid-reader","serial-communication"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AARSOL-Pvt-Ltd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-15T06:58:42.000Z","updated_at":"2025-03-15T15:04:27.000Z","dependencies_parsed_at":"2025-03-15T08:28:59.322Z","dependency_job_id":null,"html_url":"https://github.com/AARSOL-Pvt-Ltd/mifarepy","commit_stats":null,"previous_names":["sparkdrago05/pymifare","aarsol-pvt-ltd/mifarepy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AARSOL-Pvt-Ltd%2Fmifarepy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AARSOL-Pvt-Ltd%2Fmifarepy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AARSOL-Pvt-Ltd%2Fmifarepy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AARSOL-Pvt-Ltd%2Fmifarepy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AARSOL-Pvt-Ltd","download_url":"https://codeload.github.com/AARSOL-Pvt-Ltd/mifarepy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244141576,"owners_count":20404835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embedded","gnetplus","hardware","mifare","mifare-classic","mifare-classic-1k","mifare-ultralight","mifare1k","mifareclassic","nfc","nfc-card-reader","nfc-reader","pymifare","python","python3","rfid","rfid-reader","serial-communication"],"created_at":"2025-03-18T01:48:46.039Z","updated_at":"2026-03-18T00:03:27.115Z","avatar_url":"https://github.com/AARSOL-Pvt-Ltd.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **mifarepy**\n\n[![PyPI Version](https://img.shields.io/pypi/v/mifarepy.svg)](https://pypi.org/project/mifarepy/)\n[![Python Versions](https://img.shields.io/pypi/pyversions/mifarepy.svg)](https://pypi.org/project/mifarepy/)\n[![PyPI Downloads](https://static.pepy.tech/badge/mifarepy)](https://pepy.tech/projects/mifarepy)\n[![License](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](LICENSE)\n[![GitHub Issues](https://img.shields.io/github/issues/SparkDrago05/mifarepy)](https://github.com/SparkDrago05/mifarepy/issues)\n\u003c!-- [![Build Status](https://github.com/SparkDrago05/mifarepy/actions/workflows/build.yml/badge.svg)](https://github.com/SparkDrago05/mifarepy/actions) --\u003e\n\n## **Overview**\n\n`mifarepy` is a **Python library** for interfacing with **MIFARE® RFID card readers** (e.g., PROMAG PCR310U, MF5, MF10) using the **GNetPlus® protocol**.\nIt provides a clean, object-oriented API for performing common operations such as:\n- **Interacting via RS232 and USB-serial** interfaces\n- **Supporting GNetPlus® commands** (Read, Write, Authenticate, Auto Mode, etc.)\n- Reading a card’s serial number (`get_sn`, `wait_for_card`)\n- Querying reader firmware version (`get_version`)\n- Enabling/disabling automatic card events (`set_auto_mode`, `wait_for_card`)\n- Authenticating sectors (`authenticate_sector`)\n- Reading and writing 16‑byte blocks (`read_block`, `write_block`)\n- Bulk operations on sectors and arbitrary block mappings (`read_sector`, `write_sector`, `read_blocks`, `write_blocks`)\n\n---\n\n## **Attribution \u0026 Original Repository**\n\nThis project is **derived from** the original `gnetplus.py` which is written in Python 2 by **Chow Loong Jin \u0026 Harish Pillay**.\n\n- **Original Repository:** [gnetplus by harishpillay](https://github.com/harishpillay/gnetplus)\n- **Original Authors:** Chow Loong Jin \u0026 Harish Pillay\n- **License:** This project remains under **LGPL v3.0 or later** to comply with the original licensing terms.\n\nThis version of `gnetplus.py` includes **bug fixes, more features, documentation improvements, and enhanced compatibility**.\n\n---\n\n## **Supported Hardware**\n\nThis library is compatible with **PROMAG** MIFARE® readers, including:\n\n- **PCR310U** (USB-based)\n- **MF5 OEM Read/Write Module**\n- **MF10 MIFARE Read/Write Module**\n- **Other devices using the GNetPlus® protocol**\n\nThese readers operate at **13.56 MHz** and support **MIFARE® 1K/4K, Ultra-Light, and PRO cards**.\n\n---\n\n## **Installation**\n\nTo install `mifarepy`, ensure **Python 3.6+** is installed, then run:\n\n```sh\npip install mifarepy\n```\n\nOr manually include the `mifarepy.py` file in your project.\n\n---\n\n## Quickstart\n\n```python\nfrom mifarepy.reader import MifareReader\n\n# Initialize the reader on your serial port\nreader = MifareReader('/dev/ttyUSB0')\n\n# Enable auto mode and wait for card detection\nreader.set_auto_mode(True)\ncard_sn = reader.wait_for_card(timeout=10)\nprint('Found card:', card_sn)\n\n# Authenticate sector 1 with the default Key A\ndefault_key = bytes.fromhex('FFFFFFFFFFFF')\nreader.authenticate_sector(sector=1, key=default_key, key_type='A')\n\n# Read block 4 and display as hex\nblock_data = reader.read_block(4)\nprint('Block 4 data:', block_data)\n\n# Write 16 bytes to block 4\npayload = bytes(range(16))\nreader.write_block(4, payload)\n```\n---\n\n## **Communicating with the Reader**\n\n### **Detecting the Device**\n\nWhen plugged into a **Linux** system (such as **Raspberry Pi** or **Fedora**), the reader is detected as:\n\n```\nProlific Technology, Inc. PL2303 Serial Port\n```\n\nTo find the assigned port, check:\n\n```sh\ndmesg | grep ttyUSB\n```\n\nExample output:\n\n```\nusb 6-1: pl2303 converter now attached to ttyUSB3\n```\n\nThis means the device is at `/dev/ttyUSB3`.\n\n---\n\n## **Supported Commands**\n\nThis library supports the following **GNetPlus® protocol commands**:\n\n| Command               | Functionality                                |\n|-----------------------|----------------------------------------------|\n| **Polling**           | Check if a reader is connected               |\n| **Get Version**       | Retrieve firmware version                    |\n| **Logon/Logoff**      | Secure access                                |\n| **Get Serial Number** | Retrieve MIFARE® card serial number          |\n| **Read Block**        | Read memory block from MIFARE® 1K card       |\n| **Write Block**       | Write to a specific block                    |\n| **Authenticate**      | Perform authentication with Key A/Key B      |\n| **Set Auto Mode**     | Enable/Disable automatic event notifications |\n| **Request All**       | Detect multiple cards in the field           |\n\nFor a full list of commands, refer to the *\n*[mifarepy Communication Protocol](./TM970013_GNetPlusCommunicationProtocol_REV_D.pdf)**.\n\n---\n\n## **Example Output**\n\nWhen a card is detected, you will see:\n\n```\nFound card: 0x19593d65\nTap card again.\nFound card: 0x19593d65\n```\n\nIf no card is found, the script prompts:\n\n```\nTap card again.\n```\n\n---\n\n## **MIFARE® 1K Card Structure**\n\nThe **MIFARE® 1K card** consists of **16 sectors**, each with **4 blocks** (16 bytes each).  \nMemory layout:\n\n- **Blocks 0-3**: Sector 0 (First block stores manufacturer data)\n- **Blocks 4-7**: Sector 1\n- **Blocks 8-11**: Sector 2\n- **...**\n- **Blocks 60-63**: Sector 15 (Contains access keys \u0026 conditions)\n\nFor authentication, use **Key A** or **Key B** stored in the last block of each sector.\n\n---\n\n## **MIFARE® 1K Authentication \u0026 Security**\n\n1. **Authenticate** before reading/writing.\n2. Use **GNetPlus SAVE_KEY command** to store keys securely.\n3. Blocks are **protected** by access conditions.\n4. **Keys should not be stored in the same sector** as sensitive data.\n\nFor further details, refer to:\n\n- **[MIFARE Application Programming Guide](./TM970014_MifareAppliactionProgrammingGuide_REV_H.pdf)**\n- **[MIFARE Demo Quick Start](./TM970018_Mifare%20Demo%20Quick%20Start.pdf)**\n\n---\n\n## **License**\n\nThis project is licensed under **GNU Lesser General Public License v3.0 or later (LGPL-3.0-or-later)**.  \nSee [COPYING](./COPYING) for full details.\n\n---\n\n## **Documentation \u0026 References**\n\nFor more details, refer to:\n\n- **[GNetPlus Communication Protocol](./TM970013_GNetPlusCommunicationProtocol_REV_D.pdf)**\n- **[MIFARE Application Guide](./TM970014_MifareAppliactionProgrammingGuide_REV_H.pdf)**\n- **[MIFARE RWD Specification](./TM970023_RWD_SPEC.pdf)**\n- **[MF10 Instruction Sheet](./TM951179_MF10_Instruction.pdf)**\n\nFor further information, visit: [GIGA-TMS Inc.](http://www.gigatms.com.tw)\n\n---\n\n## **Author \u0026 Credits**\n\n**Original Authors:**\n\n- **Chow Loong Jin** (\u003clchow@redhat.com\u003e)\n- **Harish Pillay** (\u003chpillay@redhat.com\u003e)\n\n**Adapted \u0026 Maintained by:**\n\n- **Spark Drago** (\u003chttps://github.com/SparkDrago05\u003e)\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faarsol-pvt-ltd%2Fmifarepy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faarsol-pvt-ltd%2Fmifarepy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faarsol-pvt-ltd%2Fmifarepy/lists"}