{"id":16908667,"url":"https://github.com/micolous/kotlin-pcsc","last_synced_at":"2025-04-11T15:42:06.671Z","repository":{"id":139103171,"uuid":"214614597","full_name":"micolous/kotlin-pcsc","owner":"micolous","description":"Kotlin wrapper for PC/SC (winscard) API","archived":false,"fork":false,"pushed_at":"2022-06-06T03:36:26.000Z","size":588,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T11:52:15.737Z","etag":null,"topics":["jna","kotlin","kotlin-library","kotlin-native","pcsc","winscard"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/micolous.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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":"2019-10-12T09:02:04.000Z","updated_at":"2023-02-16T05:59:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"7cefeb79-8be9-4c2d-a6d7-b65484d4857f","html_url":"https://github.com/micolous/kotlin-pcsc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micolous%2Fkotlin-pcsc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micolous%2Fkotlin-pcsc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micolous%2Fkotlin-pcsc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micolous%2Fkotlin-pcsc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/micolous","download_url":"https://codeload.github.com/micolous/kotlin-pcsc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248433157,"owners_count":21102516,"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":["jna","kotlin","kotlin-library","kotlin-native","pcsc","winscard"],"created_at":"2024-10-13T18:52:24.510Z","updated_at":"2025-04-11T15:42:06.653Z","avatar_url":"https://github.com/micolous.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [kotlin-pcsc][]\n\n[Kotlin Multiplatform][multi] bindings for the [PC/SC][] API ([winscard][]),\nwhich targets:\n\n* **[JNA][]** on JVM (builds a single library for anything [JNA][] supports)\n* **[Native][]** for [Kotlin/Native][native] apps\n\nThis was developed to support the PC version of [Metrodroid][] (a public transit\ncard reader).\n\n## Supported platforms\n\n**Note:** Cross-compiling **Native** targets is not supported.\n\nPlatform           | [PC/SC][] Implementation | [JNA][] (JRE) | [Native][]\n------------------ | ------------------------ | ------------- | ----------\nLinux x86_64       | [pcsclite][]             | :o:           | :o:\nmacOS 10.14 x86_64 | `PCSC.framework`         | :o:           | :o:\nWindows 10 x86_64  | [WinSCard.dll][winscard] | :o:           | :o:\n\n## API\n\n[API documentation can be viewed online][api-docs], or built locally with:\n`./gradlew dokkaHtml`\n\nThis library _mostly_ follows the PC/SC API, but takes some liberties to make it\neasier to use in Kotlin, such as using object orientation, providing helper\nmethods for common patterns, parsing bitfields into properties, and abstracting\naway the small platform-specific API differences.\n\nThe result is that the same \"common\" API can be used on _all_ platforms: see\n[the `sample` directory](./sample/) for an example.\n\nThe online version of the documentation can be updated with `./update_online_docs.sh`.\n\n## Build and test\n\nAll targets, even native ones, require JDK 9 or later to be installed (for Gradle).\n\nTo run the tests, you need:\n\n* a working [PC/SC][]-compatible smart card reader\n* a card inserted into the reader\n\n### JNA (all platforms)\n\n```sh\n./gradlew :jnaMainClasses :jnaTest\n```\n\nThis builds for all platforms, as the prebuilt `net.java.dev.jna` package already includes\nplatform-specific JNI helpers.  You don't need any cross-compiling or special machine for that.\n\n### Native targets\n\n**Note:** Only `x86_64` targets are currently supported.\n\n#### Linux\n\n* Build dependencies: `libpcsclite1 libpcsclite-dev`\n* Run-time dependencies: `libpcsclite1`\n\n```sh\n./gradlew :linuxX64MainKlibrary :linuxX64Test\n```\n\n#### macOS\n\n* Build dependencies: Xcode 11 or later\n\n```sh\n./gradlew :macosX64MainKlibrary :macosX64Test\n```\n\n#### Windows\n\n```powershell\n.\\gradlew :mingwX64MainKlibrary :mingwX64Test\n```\n\n## Runtime notes\n\n### Linux (JNA and Native)\n\nInstall `libpcsclite1` and `pcscd` packages.\n\nIf you're using a reader with NXP PN53x series chipset (eg: ACS ARC122U), you\nneed to disable the `pn533` and `pn533_usb` modules:\n\n```sh\n# First, unplug the card reader.\n\n# On Linux 3.1 - 4.6:\necho \"blacklist pn533\" | sudo tee -a /etc/modprobe.d/blacklist.conf\nsudo rmmod pn533\n\n# On Linux 4.7 and later:\necho \"blacklist pn533_usb\" | sudo tee -a /etc/modprobe.d/blacklist.conf\nsudo rmmod pn533_usb\n\n# Finally, plug the card reader in again.\n```\n\nThe `pn533`/`pn533_usb` module is a driver for a new Linux-kernel-specific NFC\nsubsystem, which is **incompatible with all existing software**, including\n`libacsccid1` (its PC/SC IFD handler).\n\n## FAQ\n\n### Is there sample code?\n\nYes!  See [the `sample` directory of this repository](./sample/).\n\nThis supports building on all target platforms, and includes a `jnaFatJar` task, which pulls in all\ndependencies to a single JAR file.\n\n### How does this relate or compare to...\n\n#### `javax.smartcardio`?\n\nThis is _entirely different_, and does not support these APIs at all, even when\nthey are available (on Java 8 and earlier).\n\nIf you want to use that API, take a look at [jnasmartcardio][]. `kotlin-pcsc`'s\nJNA implementation was inspired by it.\n\n#### intarsys smartcard-io?\n\n[intarsys smartcard-io][intarsys] is a Java/JRE library which provides a\nJava-friendly PC/SC API (and a `javax.smartcardio` wrapper).\n\nWhile it _can_ be used with Kotlin, it only targets the JRE (not Native).\n\n### What about mobile (Android / iOS) support?\n\nThis is explicitly _not_ in scope for this project.\n\nMost mobile devices do not offer a [PC/SC][]-compatible API. The few devices\nthat _do_ run a regular enough Linux userland that you should be able to build\nusing that.\n\n### How do I use this to connect to FeliCa / MIFARE / etc?\n\nYou'll need to provide your own implementation of those protocols. PC/SC only provides a very low\nlevel interface, and you'll be sending `ByteArray` to the ICC and getting `ByteArray` back.\n\nWe don't even parse the APDUs for you...\n\n[api-docs]: https://micolous.github.io/kotlin-pcsc/index.html\n[intarsys]: https://github.com/intarsys/smartcard-io\n[JNA]: https://github.com/java-native-access/jna\n[jnasmartcardio]: https://github.com/jnasmartcardio/jnasmartcardio\n[kotlin-pcsc]: https://github.com/micolous/kotlin-pcsc\n[Metrodroid]: https://github.com/metrodroid/metrodroid\n[multi]: https://kotlinlang.org/docs/reference/multiplatform.html\n[native]: https://kotlinlang.org/docs/reference/native-overview.html\n[PC/SC]: https://www.pcscworkgroup.com/\n[pcsclite]: https://pcsclite.apdu.fr/\n[winscard]: https://docs.microsoft.com/en-us/windows/win32/api/winscard/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicolous%2Fkotlin-pcsc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicolous%2Fkotlin-pcsc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicolous%2Fkotlin-pcsc/lists"}