dart_pcsc 2.0.2 copy "dart_pcsc: ^2.0.2" to clipboard
dart_pcsc: ^2.0.2 copied to clipboard

Communicate with smart cards using PC/SC.

example/dart_pcsc_example.dart

import 'dart:typed_data';

import 'package:dart_pcsc/dart_pcsc.dart';

void main() async {
  final context = Context(Scope.user);
  try {
    await context.establish();

    List<String> readers = await context.listReaders();

    if (readers.isEmpty) {
      print('No readers');
      return;
    }
    print('Readers: $readers');

    print('Waiting for card');
    List<String> withCard = await context.waitForCard(readers).value;

    print('Connecting to card in ${withCard.first}');
    Card card = await context.connect(
      withCard.first,
      ShareMode.shared,
      Protocol.any,
    );

    print('Transmitting');
    Uint8List resp = await card.transmit(
      Uint8List.fromList([0x00, 0xa4, 0x04, 0x00, 1, 2, 3]),
    );
    int status = (resp[0] << 8) + resp[1];
    print('Status: 0x${status.toRadixString(16)}');

    await card.disconnect(Disposition.resetCard);
  } finally {
    await context.release();
  }
}
0
likes
150
pub points
45%
popularity

Publisher

unverified uploader

Communicate with smart cards using PC/SC.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

async, ffi

More

Packages that depend on dart_pcsc