NfcReaderLib 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package NfcReaderLib --version 1.0.0
                    
NuGet\Install-Package NfcReaderLib -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NfcReaderLib" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NfcReaderLib" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="NfcReaderLib" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NfcReaderLib --version 1.0.0
                    
#r "nuget: NfcReaderLib, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NfcReaderLib@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NfcReaderLib&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=NfcReaderLib&version=1.0.0
                    
Install as a Cake Tool

NfcReaderLib

.NET Framework NuGet License

NFC/Smart card utilities library providing PC/SC communication, SL Token generation (SHA-256 based tokens from ICC certificates), and utility functions for card data processing.

?? Installation

NuGet Package Manager

Install-Package NfcReaderLib -Version 1.0.0

.NET CLI

dotnet add package NfcReaderLib --version 1.0.0

Package Reference

<PackageReference Include="NfcReaderLib" Version="1.0.0" />

?? Target Framework

  • .NET Framework 4.7.2

? Features

  • ?? PC/SC Communication - Low-level smart card reader communication
  • ?? SL Token Generation - SHA-256 based secure tokens from ICC certificates
  • ??? Card Utilities - Helper functions for card data processing
  • ?? Data Formatting - Byte array and hex string conversions
  • ?? TLV Parsing Support - Tag-Length-Value structure handling

?? Quick Start

Basic PC/SC Communication

using NfcReaderLib;

// Initialize card reader
var reader = new CardReader();
reader.Initialize();

// Connect to card
reader.Connect("ACS ACR122U PICC Interface 0");

// Send APDU command
byte[] apdu = { 0x00, 0xA4, 0x04, 0x00, 0x00 };
byte[] response = reader.SendApdu(apdu);

SL Token Generation

using NfcReaderLib;

// Generate SL Token from ICC certificate
byte[] iccCert = GetIccCertificate(); // Tag 9F46
string slToken = SLCard.GenerateToken(iccCert);

// Output: "E3 B0 C4 42 98 FC 1C 14..." (SHA-256 hash)

Utility Functions

using NfcReaderLib;

// Convert hex string to byte array
byte[] data = Util.HexStringToByteArray("00A4040000");

// Convert byte array to hex string
string hex = Util.ByteArrayToHexString(data);

// Format card number
string pan = Util.FormatCardNumber("1234567890123456");
// Output: "1234 5678 9012 3456"

?? Main Components

SLCard Class

Purpose: Card data model with ICC certificate parsing and token generation

Key Methods:

  • GenerateToken(byte[] iccCertificate) - Generate SL Token from ICC cert
  • ParseIccCertificate(byte[] data) - Parse ICC public key certificate

Properties:

  • CardNumber - Primary Account Number (PAN)
  • ExpiryDate - Card expiration date
  • CardholderName - Name on card
  • IccCertificate - ICC Public Key Certificate (Tag 9F46)
  • SlToken - Generated secure link token

Util Class

Purpose: Utility functions for data conversion and formatting

Key Methods:

  • HexStringToByteArray(string hex) - Convert hex to bytes
  • ByteArrayToHexString(byte[] bytes) - Convert bytes to hex
  • FormatCardNumber(string pan) - Format PAN with spaces
  • FormatExpiryDate(string date) - Format expiry as MM/YY

?? SL Token Details

What is SL Token?

The SL (Secure Link) Token is a unique cryptographic identifier derived from the card's ICC Public Key Certificate using SHA-256 hashing.

Token Generation Process

ICC Certificate (Tag 9F46) ? SHA-256 Hash ? Hex String ? SL Token

Example:

byte[] iccCert = new byte[] { /* ICC cert data */ };
string token = SLCard.GenerateToken(iccCert);
// Output: "E3 B0 C4 42 98 FC 1C 14 9A FB F4 C8 99 6F B9 24..."

Properties

? Unique - Each card generates unique token
? Consistent - Same card always generates same token
? Secure - One-way hash, cannot be reversed
? Privacy-Friendly - No PAN or sensitive data exposed
? Format - Space-separated hex string (95 characters)

Use Cases

  • ?? Loyalty program card identification
  • ?? Card binding to user accounts
  • ?? Transaction correlation
  • ?? Duplicate card detection
  • ?? Analytics without storing sensitive data

?? Requirements

Runtime Requirements

  • .NET Framework 4.7.2 or later
  • Windows 7 or later
  • PC/SC smart card service (SCardSvr)

Dependencies

  • System.Security.Cryptography.Algorithms (4.3.0) - For SHA-256 hashing

?? PC/SC Integration

Supported Readers

This library works with any PC/SC compliant smart card reader:

  • ? ACR122U (contactless)
  • ? SCM SCR331 (contact)
  • ? Omnikey 5321 (dual interface)
  • ? Generic PC/SC readers

PC/SC Service

Ensure the PC/SC service is running:

# Check service status
Get-Service SCardSvr

# Start service if stopped
Start-Service SCardSvr

?? Documentation

For complete documentation, see the main project:

?? Contributing

Contributions welcome! Please submit issues and pull requests on GitHub.

?? License

Copyright � Johan Henningsson 2024

This project is licensed under the MIT License.

  • EMVCard.Core - High-level EMV card reading functionality
  • AztecQRGenerator.Core - QR code generation for card data

?? Author

Johan Henningsson

?? Support

If you find this library useful, please ? star the repository on GitHub!


Version 1.0.0 | .NET Framework 4.7.2 | MIT License

Product Compatible and additional computed target framework versions.
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on NfcReaderLib:

Package Downloads
EMVCard.Core

EMV chip card reading library with support for PSE/PPSE application selection, GPO processing, record reading, TLV parsing, JH Token generation, and event-driven card read notifications. Works with contact and contactless EMV cards via PC/SC readers. Updated for 2026 release with improved documentation and copyright. Now supports both 32-bit and 64-bit Windows systems through NfcReaderLib 1.0.3.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0 127 1/18/2026 2.1.0 is deprecated because it is no longer maintained and has critical bugs.
2.0.4 107 1/14/2026
1.0.4 101 1/13/2026
1.0.3 105 1/1/2026
1.0.2 93 1/1/2026
1.0.1 96 1/1/2026
1.0.0 104 12/31/2025