Skip to main content

eid 0.1.0 copy "eid: ^0.1.0" to clipboard
eid: ^0.1.0 copied to clipboard

Talks to electronic identity cards over any transport: APDUs, ISO 7816-4 file reading, card insertion and the values national cards share.

example/example.dart

// ignore_for_file: avoid_print

import 'dart:typed_data';

import 'package:eid/eid.dart';

/// Reads a transparent file by path, over whatever transport is at hand.
///
/// In an application the transport comes from an adapter package, such as
/// `eid_ccid` for a USB reader. Country packages such as `eid_belgium` know
/// the paths and decode the files.
Future<Uint8List> readFile(CardTransport transport, List<int> path) async {
  final channel = CardChannel(transport);
  await channel.selectPath(path);
  return await channel.readTransparentFile();
}

/// A card that holds one four byte file, to run the example without a reader.
final class DemoCard implements CardTransport {
  @override
  Future<Uint8List> transmit(Uint8List command) async {
    final isRead = command[1] == 0xB0;
    return Uint8List.fromList(isRead ? [1, 2, 3, 4, 0x90, 0x00] : [0x90, 0x00]);
  }
}

Future<void> main() async {
  final content = await readFile(DemoCard(), [0x3F00, 0xDF01, 0x4031]);
  print(hexString(content)); // 01020304
}
0
likes
160
points
569
downloads

Documentation

API reference

Publisher

verified publishercomapps.be

Weekly Downloads

Talks to electronic identity cards over any transport: APDUs, ISO 7816-4 file reading, card insertion and the values national cards share.

Homepage
Repository (GitHub)
View/report issues

Topics

#eid #smartcard #apdu #identity

Funding

Consider supporting this project:

www.paypal.com

License

MIT (license)

More

Packages that depend on eid