pythonbeid 0.2.0__py3-none-any.whl → 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pythonbeid/__init__.py +77 -6
- pythonbeid/__main__.py +3 -0
- pythonbeid/card_reader.py +846 -256
- pythonbeid/cli.py +176 -0
- pythonbeid/exceptions.py +73 -30
- pythonbeid/integrity.py +455 -0
- pythonbeid/models.py +593 -0
- pythonbeid/parser.py +472 -89
- pythonbeid/py.typed +0 -0
- pythonbeid/trust/belgium_root_ca2.pem +22 -0
- pythonbeid/trust/belgium_root_ca3.pem +32 -0
- pythonbeid/trust/belgium_root_ca4.pem +32 -0
- pythonbeid/trust/belgium_root_ca6.pem +21 -0
- pythonbeid-1.0.0.dist-info/METADATA +293 -0
- pythonbeid-1.0.0.dist-info/RECORD +19 -0
- {pythonbeid-0.2.0.dist-info → pythonbeid-1.0.0.dist-info}/WHEEL +1 -1
- pythonbeid-1.0.0.dist-info/entry_points.txt +2 -0
- {pythonbeid-0.2.0.dist-info → pythonbeid-1.0.0.dist-info}/licenses/LICENSE +21 -21
- pythonbeid-0.2.0.dist-info/METADATA +0 -104
- pythonbeid-0.2.0.dist-info/RECORD +0 -9
- {pythonbeid-0.2.0.dist-info → pythonbeid-1.0.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pythonbeid
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Read and verify Belgian eID cards (identity, address, photo) through PC/SC
|
|
5
|
+
Author-email: Fabien Toune <fabien.toune@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Lapin-Blanc/pythonbeid
|
|
8
|
+
Project-URL: Repository, https://github.com/Lapin-Blanc/pythonbeid
|
|
9
|
+
Project-URL: Issues, https://github.com/Lapin-Blanc/pythonbeid/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/Lapin-Blanc/pythonbeid/blob/master/CHANGELOG.md
|
|
11
|
+
Keywords: belgium,eid,beid,belpic,smartcard,pcsc,identity card
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Operating System :: MacOS
|
|
16
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
25
|
+
Classifier: Topic :: Security
|
|
26
|
+
Classifier: Topic :: Security :: Cryptography
|
|
27
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
28
|
+
Classifier: Topic :: System :: Hardware
|
|
29
|
+
Classifier: Typing :: Typed
|
|
30
|
+
Requires-Python: >=3.11
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Requires-Dist: pyscard>=2.0.8
|
|
34
|
+
Provides-Extra: verify
|
|
35
|
+
Requires-Dist: cryptography>=42; extra == "verify"
|
|
36
|
+
Provides-Extra: dev
|
|
37
|
+
Requires-Dist: black>=25; extra == "dev"
|
|
38
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
39
|
+
Requires-Dist: cryptography>=42; extra == "dev"
|
|
40
|
+
Requires-Dist: mypy>=1.13; extra == "dev"
|
|
41
|
+
Requires-Dist: pre-commit>=4; extra == "dev"
|
|
42
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
43
|
+
Requires-Dist: pytest-cov>=6; extra == "dev"
|
|
44
|
+
Requires-Dist: ruff>=0.8; extra == "dev"
|
|
45
|
+
Requires-Dist: twine>=6; extra == "dev"
|
|
46
|
+
Dynamic: license-file
|
|
47
|
+
|
|
48
|
+
# pythonbeid
|
|
49
|
+
|
|
50
|
+
[](https://pypi.org/project/pythonbeid/)
|
|
51
|
+
[](https://pypi.org/project/pythonbeid/)
|
|
52
|
+
[](https://github.com/Lapin-Blanc/pythonbeid/actions/workflows/ci.yml)
|
|
53
|
+
[](LICENSE)
|
|
54
|
+
|
|
55
|
+
Read and verify **Belgian electronic identity cards** (eID, Kids-ID, residence
|
|
56
|
+
cards for foreign nationals) from Python, with any PC/SC smart card reader.
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from pythonbeid import CardReader
|
|
60
|
+
|
|
61
|
+
with CardReader() as reader:
|
|
62
|
+
eid = reader.read()
|
|
63
|
+
print(eid.identity.last_name, eid.identity.birth_date)
|
|
64
|
+
print(eid.address.street, eid.address.postal_code, eid.address.municipality)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Features
|
|
68
|
+
|
|
69
|
+
- **Complete card content**: every field of the identity and address files
|
|
70
|
+
(applet 1.7 and 1.8 layouts), the photo, chip information and certificates.
|
|
71
|
+
- **Correct in every language**: birth dates written in French, Dutch or
|
|
72
|
+
German, incomplete birth dates, `M`/`F`/`V`/`W` sex letters, document types
|
|
73
|
+
and special statuses.
|
|
74
|
+
- **Authenticity checks**: photo digest, National Register signatures of the
|
|
75
|
+
identity and address files, certificate chain up to the Belgian root CAs and,
|
|
76
|
+
on applet 1.8 cards, the chip challenge that detects cloned data.
|
|
77
|
+
- **Robust transport**: follows the official middleware (block size, `6Cxx`,
|
|
78
|
+
`61xx`, end of file), runs inside PC/SC transactions so other applications
|
|
79
|
+
cannot interfere, recovers when another application resets the card, and
|
|
80
|
+
leaves the card powered for them.
|
|
81
|
+
- **Typed API**: immutable dataclasses, enums and `datetime.date`, shipped
|
|
82
|
+
with `py.typed`; strict mypy clean.
|
|
83
|
+
- **Command line**: `pythonbeid read`, `pythonbeid verify`...
|
|
84
|
+
- No PIN is ever sent: only public card content is read.
|
|
85
|
+
|
|
86
|
+
## Installation
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pip install pythonbeid # reading
|
|
90
|
+
pip install "pythonbeid[verify]" # reading + signature verification
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Requirements: Python 3.11 or later and a PC/SC reader.
|
|
94
|
+
|
|
95
|
+
- **Windows, macOS**: nothing else to install.
|
|
96
|
+
- **Linux**: the PC/SC daemon must run, and [pyscard](https://pypi.org/project/pyscard/)
|
|
97
|
+
is compiled at install time:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
sudo apt install pcscd libpcsclite-dev # Debian, Ubuntu, Mint, MX Linux...
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Reading a card
|
|
104
|
+
|
|
105
|
+
`CardReader()` picks the first reader that holds a Belgian eID card. You can
|
|
106
|
+
also choose the reader and wait for the card to be inserted:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from pythonbeid import CardReader, list_readers
|
|
110
|
+
|
|
111
|
+
print(list_readers()) # ['ACS ACR38U 0', ...]
|
|
112
|
+
|
|
113
|
+
with CardReader("ACR38U", timeout=30) as reader: # index, name or part of it
|
|
114
|
+
identity = reader.read_identity()
|
|
115
|
+
address = reader.read_address()
|
|
116
|
+
photo = reader.read_photo() # JPEG bytes
|
|
117
|
+
print(reader.card_info.applet_version_string) # "1.7" or "1.8"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`reader.read()` reads everything in a single transaction and returns an
|
|
121
|
+
`EidData` object (`card`, `identity`, `address`, `photo`, raw `files`). Pass
|
|
122
|
+
`photo=False` or `integrity=False` to skip the photo or the files used by the
|
|
123
|
+
verification. All models offer `to_dict()` for JSON serialisation.
|
|
124
|
+
|
|
125
|
+
Reading speed depends on the reader: `read()` takes about 9 s on an old
|
|
126
|
+
9600-baud ACS ACR38U and proportionally less on faster readers. The photo
|
|
127
|
+
(3 KB) is the largest file; skip it when you do not need it.
|
|
128
|
+
|
|
129
|
+
### Identity fields
|
|
130
|
+
|
|
131
|
+
| Field | Type | Notes |
|
|
132
|
+
|---|---|---|
|
|
133
|
+
| `card_number`, `chip_number` | `str` | chip number in hexadecimal |
|
|
134
|
+
| `validity_start`, `validity_end` | `date` | `is_valid_on(day)` helper |
|
|
135
|
+
| `issuing_municipality` | `str` | |
|
|
136
|
+
| `national_number` | `str` | `national_number_valid` checks the modulo-97 checksum |
|
|
137
|
+
| `last_name` | `str` | |
|
|
138
|
+
| `first_names` | `str` | the first two given names only |
|
|
139
|
+
| `third_given_name_initial` | `str` | `given_names` joins both |
|
|
140
|
+
| `nationality`, `birth_place` | `str` | in the language of the card |
|
|
141
|
+
| `birth_date` | `PartialDate \| None` | `.to_date()`; year or month may be unknown; `None` for an unknown format (raw value in `raw[0x0C]`) |
|
|
142
|
+
| `sex` | `Sex \| None` | `Sex.MALE` / `Sex.FEMALE` |
|
|
143
|
+
| `noble_condition` | `str` | |
|
|
144
|
+
| `document_type` | `DocumentType \| None` | `.description`, `.is_kids_card`, `.is_foreigner_card` |
|
|
145
|
+
| `special_status` | `SpecialStatus` | `.white_cane`, `.yellow_cane`, `.extended_minority` |
|
|
146
|
+
| `photo_hash`, `basic_key_hash` | `bytes` | used by the verification |
|
|
147
|
+
| foreign nationals | | `duplicate`, `special_organization`, `member_of_family`, `date_and_country_of_protection`, `work_permit`, `employer_vat_1/2`, `regional_file_number`, `brexit_mention_1/2`, `card_a_mention_1/2`, `eu_registration_date` |
|
|
148
|
+
| `raw` | `Mapping[int, bytes]` | every TLV record, for future tags |
|
|
149
|
+
|
|
150
|
+
The address has `street` (street and house number), `postal_code` and
|
|
151
|
+
`municipality`.
|
|
152
|
+
|
|
153
|
+
## Verifying authenticity
|
|
154
|
+
|
|
155
|
+
Requires the `verify` extra.
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
with CardReader() as reader:
|
|
159
|
+
report = reader.verify()
|
|
160
|
+
print(report.is_valid)
|
|
161
|
+
for error in report.errors:
|
|
162
|
+
print(error)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
| Check | Meaning |
|
|
166
|
+
|---|---|
|
|
167
|
+
| `photo_hash_valid` | the photo matches the digest in the identity file |
|
|
168
|
+
| `identity_signature_valid` | the identity file is signed by the National Register (RRN) |
|
|
169
|
+
| `address_signature_valid` | the address file is signed by the RRN (and bound to the identity signature) |
|
|
170
|
+
| `rrn_certificate_trusted` | the RRN certificate is an end-entity signing certificate issued by a bundled Belgian root CA |
|
|
171
|
+
| `rrn_certificate_period_valid` | the RRN certificate validity overlaps the card validity |
|
|
172
|
+
| `content_matches_files` | the decoded identity, address and photo are those of the signed files |
|
|
173
|
+
| `basic_key_valid` | applet 1.8: the chip public key is the one signed by the RRN |
|
|
174
|
+
| `chip_authenticated` | applet 1.8: the chip signed a random challenge with its private key |
|
|
175
|
+
|
|
176
|
+
A check that does not apply is `None`. The RRN certificate is not required to
|
|
177
|
+
be valid today: certificates of valid cards may have expired since, and cards
|
|
178
|
+
re-signed after issuance carry a newer one. Whether a card has a basic key is
|
|
179
|
+
decided by the signed identity file, never by the unsigned chip information,
|
|
180
|
+
so a clone cannot avoid the chip challenge by claiming an older applet.
|
|
181
|
+
|
|
182
|
+
Raw files can be checked offline, for instance on a server receiving them
|
|
183
|
+
from a client:
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
from pythonbeid import EidData, verify_eid
|
|
187
|
+
|
|
188
|
+
eid = EidData.from_files(files) # {CardFile: bytes}
|
|
189
|
+
report = verify_eid(eid) # everything is checked on the raw files
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
The chip challenge needs the live card: `reader.authenticate_chip(identity)`
|
|
193
|
+
checks the chip against an identity file whose signature you verified.
|
|
194
|
+
|
|
195
|
+
Bundled trust anchors, downloaded from `certs.eid.belgium.be` and
|
|
196
|
+
`crt.eidpki.belgium.be` (SHA-256):
|
|
197
|
+
|
|
198
|
+
| Root | Fingerprint |
|
|
199
|
+
|---|---|
|
|
200
|
+
| Belgium Root CA2 | `9f9744463be13714754e1a3becf98c08cc205e4ab32028f4e2830c4a1b2775b8` |
|
|
201
|
+
| Belgium Root CA3 | `a8d14e945e3e5156bcae5e39737cf6a1b1f51028bbbf982f50ce5f4c05568b4d` |
|
|
202
|
+
| Belgium Root CA4 | `702dd5c1a093cf0a9d71fadd9bf9a7c5857d89fb73b716e867228b3c2beb968f` |
|
|
203
|
+
| Belgium Root CA6 | `9c872bc979a7c09a58d4a274c199e5cb16cfa9b9618d98bc9a9988e984b8495c` |
|
|
204
|
+
|
|
205
|
+
Pass `trusted_roots=[...]` (PEM or DER) to use your own.
|
|
206
|
+
|
|
207
|
+
## Command line
|
|
208
|
+
|
|
209
|
+
```console
|
|
210
|
+
$ pythonbeid readers
|
|
211
|
+
0: ACS ACR38U 0
|
|
212
|
+
$ pythonbeid info # reader, ATR, applet version
|
|
213
|
+
$ pythonbeid read --json # identity and address
|
|
214
|
+
$ pythonbeid read --photo me.jpg
|
|
215
|
+
$ pythonbeid verify # exit status 3 when a check fails
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
`python -m pythonbeid` works too. Options: `--reader`, `--timeout`, `--json`,
|
|
219
|
+
`-v` / `-vv` (APDU trace, without card data).
|
|
220
|
+
|
|
221
|
+
## Errors
|
|
222
|
+
|
|
223
|
+
All exceptions derive from `pythonbeid.BeidError`:
|
|
224
|
+
|
|
225
|
+
| Exception | Raised when |
|
|
226
|
+
|---|---|
|
|
227
|
+
| `NoReaderError` | no reader, or none matches the requested one |
|
|
228
|
+
| `PCSCServiceError` | the PC/SC service is not running (subclass of `NoReaderError`) |
|
|
229
|
+
| `NoCardError` | no card in the reader, or the card was removed |
|
|
230
|
+
| `UnsupportedCardError` | the card is not a Belgian eID card, or lacks a feature |
|
|
231
|
+
| `CardCommunicationError` | transport failure |
|
|
232
|
+
| `APDUError` | the card refused a command (`.sw` holds the status word) |
|
|
233
|
+
| `CardDataError` | card content cannot be decoded (also a `ValueError`) |
|
|
234
|
+
|
|
235
|
+
## Migrating from 0.x
|
|
236
|
+
|
|
237
|
+
The 0.x API still works and emits a `DeprecationWarning`:
|
|
238
|
+
|
|
239
|
+
| 0.x | 1.0 |
|
|
240
|
+
|---|---|
|
|
241
|
+
| `cr.read_informations(photo=True)` | `reader.read()` returning typed `EidData` |
|
|
242
|
+
| `CardReader(reader_index=1)` | `CardReader(1)` or `CardReader("name")` |
|
|
243
|
+
| `info["birth_date"]` (`datetime`) | `identity.birth_date` (`PartialDate`) |
|
|
244
|
+
| `info["suffix"]` | `identity.third_given_name_initial` |
|
|
245
|
+
| `info["address"]`, `info["city"]` | `address.street`, `address.municipality` |
|
|
246
|
+
| `info["photo"]` (base-64 `str`) | `eid.photo` (`bytes`) |
|
|
247
|
+
| `parse_tlv`, `parse_french_date` | `decode_tlv`, `parse_birth_date` |
|
|
248
|
+
|
|
249
|
+
Behaviour fixes that may be visible: birth dates written in Dutch or German
|
|
250
|
+
are now parsed correctly (0.x silently returned January for most months, and
|
|
251
|
+
failed on German cards); values are stripped of padding spaces; unknown month
|
|
252
|
+
names raise instead of defaulting to January.
|
|
253
|
+
|
|
254
|
+
## Compatibility
|
|
255
|
+
|
|
256
|
+
- Applet 1.7 cards (RSA keys): validated on real cards.
|
|
257
|
+
- Applet 1.8 cards (elliptic-curve keys, current generation): implemented
|
|
258
|
+
after the official specification and middleware, and covered by simulated
|
|
259
|
+
tests. Reports from 1.8 card holders are welcome (see the issue template;
|
|
260
|
+
never share personal data).
|
|
261
|
+
- Python 3.11 to 3.15 on Windows, macOS and Linux.
|
|
262
|
+
|
|
263
|
+
## Privacy
|
|
264
|
+
|
|
265
|
+
Card content is personal data (GDPR). pythonbeid never logs it: debug logs
|
|
266
|
+
only contain command headers, status words and lengths. Ask for consent and
|
|
267
|
+
keep only what you need.
|
|
268
|
+
|
|
269
|
+
## Development
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
git clone https://github.com/Lapin-Blanc/pythonbeid && cd pythonbeid
|
|
273
|
+
python -m venv .venv && . .venv/bin/activate # .venv\Scripts\activate on Windows
|
|
274
|
+
pip install -e ".[dev]" && pre-commit install
|
|
275
|
+
pytest # simulated card, no hardware needed
|
|
276
|
+
pytest --hardware # also runs the tests on a real card (no data is printed)
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
280
|
+
|
|
281
|
+
## References
|
|
282
|
+
|
|
283
|
+
Official documentation, in the
|
|
284
|
+
[Fedict/eid-mw](https://github.com/Fedict/eid-mw/tree/master/doc/sdk/documentation)
|
|
285
|
+
repository:
|
|
286
|
+
|
|
287
|
+
- *ID and Address file contents*, applet 1.8, v5.0 (2023)
|
|
288
|
+
- *Belgian Electronic Identity Card content*, v5.4
|
|
289
|
+
- *Reference manual Belpic V1.8 eID card* and *V1.7*
|
|
290
|
+
|
|
291
|
+
## License
|
|
292
|
+
|
|
293
|
+
MIT, see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
pythonbeid/__init__.py,sha256=blxIJjtfcEG5BAIwInLVGJY4H5bT3erMssZyIY4w9Bs,1755
|
|
2
|
+
pythonbeid/__main__.py,sha256=k1ocEWawweo1qCJWNFAAvyxz3tcY13dzvCenHszij30,48
|
|
3
|
+
pythonbeid/card_reader.py,sha256=qdpez_gfDf__DaB1iJzVgdP3Htyk1amEkO-NTX2zkKs,32892
|
|
4
|
+
pythonbeid/cli.py,sha256=BA-Zx50ZJ0-TfOcUSPBqyOLF4vCAT5LroGH67wJ3EYc,5527
|
|
5
|
+
pythonbeid/exceptions.py,sha256=pEndy6ciiqFNSh3WeNHzEE0llIa-KHT8bpLvBxMnUfA,1937
|
|
6
|
+
pythonbeid/integrity.py,sha256=x1IvB_8NDD5azKT4tvw-SfZ4oKS3nsiOyIZ3qx6gX8M,16660
|
|
7
|
+
pythonbeid/models.py,sha256=iSS_ywPThDjdiZKIfVWOGTd9_3i5CsbcTgIsYxBOVn8,20617
|
|
8
|
+
pythonbeid/parser.py,sha256=d_CRUJP6B1td4BbdpK6REY00s4l5qZwPCDWElmhVk5g,16127
|
|
9
|
+
pythonbeid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
pythonbeid/trust/belgium_root_ca2.pem,sha256=2CqkJxMhInhCUUyVJIbnBBQqm3og7hqc0wxaRiuHBzI,1294
|
|
11
|
+
pythonbeid/trust/belgium_root_ca3.pem,sha256=3AAr5yeQ5Z42UDVtcQwHexk9TNCfg28gIn2dZ34YlAg,1988
|
|
12
|
+
pythonbeid/trust/belgium_root_ca4.pem,sha256=lumT5v9x4256Mtf7XVW9DeBaCXnT5IWPrr2kWfo_pf8,1988
|
|
13
|
+
pythonbeid/trust/belgium_root_ca6.pem,sha256=E92NB3hYd3BM0bPn2M9qTe_CaHmFABTniM-p-4B8oCw,1241
|
|
14
|
+
pythonbeid-1.0.0.dist-info/licenses/LICENSE,sha256=VOOj3rL3m3LyHxJOvzfNxWbRhDeBfzne6GKYwypfvxA,1069
|
|
15
|
+
pythonbeid-1.0.0.dist-info/METADATA,sha256=NoL1pSUvw3N_Xt46tH_E2BpIXcduArc8i04U1Ep8dAo,12539
|
|
16
|
+
pythonbeid-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
17
|
+
pythonbeid-1.0.0.dist-info/entry_points.txt,sha256=Z3MJzsElAc6cLLuxOogzl0SKWywH5o8F7Fwny_tBOLs,51
|
|
18
|
+
pythonbeid-1.0.0.dist-info/top_level.txt,sha256=-Uw6t8lKuiCAYujzrtgkiyiNdngHathGf-Nh0EVwHc4,11
|
|
19
|
+
pythonbeid-1.0.0.dist-info/RECORD,,
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Fabien Toune
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Fabien Toune
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: pythonbeid
|
|
3
|
-
Version: 0.2.0
|
|
4
|
-
Summary: Un module pour lire les informations des cartes d'identité belges
|
|
5
|
-
Author-email: Fabien Toune <fabien.toune@gmail.com>
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/Lapin-Blanc/pythonbeid
|
|
8
|
-
Project-URL: Bug Tracker, https://github.com/Lapin-Blanc/pythonbeid/issues
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Classifier: Topic :: Security
|
|
12
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
13
|
-
Requires-Python: >=3.9
|
|
14
|
-
Description-Content-Type: text/markdown
|
|
15
|
-
License-File: LICENSE
|
|
16
|
-
Requires-Dist: pyscard
|
|
17
|
-
Provides-Extra: dev
|
|
18
|
-
Requires-Dist: pytest; extra == "dev"
|
|
19
|
-
Requires-Dist: pytest-cov; extra == "dev"
|
|
20
|
-
Requires-Dist: build; extra == "dev"
|
|
21
|
-
Requires-Dist: twine; extra == "dev"
|
|
22
|
-
Dynamic: license-file
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
# PythonBEID
|
|
26
|
-
|
|
27
|
-
PythonBEID est un module Python pour lire les informations essentielles des cartes d'identité belge à l'aide d'un lecteur de cartes PC/SC et de la bibliothèque `pyscard`.
|
|
28
|
-
|
|
29
|
-
## Installation
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
pip install pythonbeid
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Utilisation
|
|
36
|
-
|
|
37
|
-
```python
|
|
38
|
-
from pythonbeid import CardReader, NoReaderError, NoCardError
|
|
39
|
-
|
|
40
|
-
try:
|
|
41
|
-
with CardReader() as cr: # context manager — ferme proprement la connexion
|
|
42
|
-
info = cr.read_informations(photo=False)
|
|
43
|
-
print(info["last_name"]) # Smith
|
|
44
|
-
print(info["birth_date"]) # datetime(1990, 1, 1)
|
|
45
|
-
except NoReaderError:
|
|
46
|
-
print("Aucun lecteur de carte détecté.")
|
|
47
|
-
except NoCardError:
|
|
48
|
-
print("Aucune carte dans le lecteur.")
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Si plusieurs lecteurs sont connectés, précisez l'index :
|
|
52
|
-
|
|
53
|
-
```python
|
|
54
|
-
with CardReader(reader_index=1) as cr:
|
|
55
|
-
info = cr.read_informations()
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Champs retournés par `read_informations()`
|
|
59
|
-
|
|
60
|
-
| Clé | Type | Description |
|
|
61
|
-
|---|---|---|
|
|
62
|
-
| `card_number` | str | Numéro de la carte |
|
|
63
|
-
| `validity_start` | datetime | Date début de validité |
|
|
64
|
-
| `validity_end` | datetime | Date fin de validité |
|
|
65
|
-
| `issuing_municipality` | str | Commune de délivrance |
|
|
66
|
-
| `national_number` | str | Numéro national |
|
|
67
|
-
| `last_name` | str | Nom de famille |
|
|
68
|
-
| `first_names` | str | Prénom(s) |
|
|
69
|
-
| `suffix` | str | Suffixe de nom |
|
|
70
|
-
| `nationality` | str | Nationalité |
|
|
71
|
-
| `birth_place` | str | Lieu de naissance |
|
|
72
|
-
| `birth_date` | datetime | Date de naissance |
|
|
73
|
-
| `sex` | str | Sexe |
|
|
74
|
-
| `address` | str | Adresse |
|
|
75
|
-
| `postal_code` | str | Code postal |
|
|
76
|
-
| `city` | str | Localité |
|
|
77
|
-
| `photo` | str | Photo en base64 (si `photo=True`) |
|
|
78
|
-
|
|
79
|
-
### Activer les logs
|
|
80
|
-
|
|
81
|
-
```python
|
|
82
|
-
import logging
|
|
83
|
-
logging.basicConfig(level=logging.DEBUG)
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
## Dépendances
|
|
87
|
-
|
|
88
|
-
- `pyscard`
|
|
89
|
-
|
|
90
|
-
## Tests
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
pip install -e ".[dev]"
|
|
94
|
-
pytest # tous les tests (matériel skippé si absent)
|
|
95
|
-
pytest tests/test_parser.py # tests sans matériel uniquement
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## Contribuer
|
|
99
|
-
|
|
100
|
-
Les contributions et améliorations sont les bienvenues !
|
|
101
|
-
|
|
102
|
-
## Licence
|
|
103
|
-
|
|
104
|
-
Ce projet est sous licence MIT. Voir le fichier `LICENSE` pour plus de détails.
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
pythonbeid/__init__.py,sha256=gfglDkvri8Gh2ixRUY_6KOVQ1UAUSfGuy1nBdJswOPg,305
|
|
2
|
-
pythonbeid/card_reader.py,sha256=UCo-2FehvCyIx1jQu3fkATD8kapUtSH8s8wNtxMNNE4,11070
|
|
3
|
-
pythonbeid/exceptions.py,sha256=BS06iT3v5FbGFTEZBjkdCZ9A2nCWPLPf8lmYh_cz5Fo,820
|
|
4
|
-
pythonbeid/parser.py,sha256=TyFzpj5sfu3J9w1sxt96j1Xr4gK7INC5a4VFaZCIyyA,2711
|
|
5
|
-
pythonbeid-0.2.0.dist-info/licenses/LICENSE,sha256=8xOq3W-9w8IgGAWBbKMFTcX3fMQCV4YmgQsvC14CTPE,1090
|
|
6
|
-
pythonbeid-0.2.0.dist-info/METADATA,sha256=UDm9o_DqulBCyk4WKpXV8XNCqxR4ALG28ZzfZLqJiRg,3078
|
|
7
|
-
pythonbeid-0.2.0.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
|
|
8
|
-
pythonbeid-0.2.0.dist-info/top_level.txt,sha256=-Uw6t8lKuiCAYujzrtgkiyiNdngHathGf-Nh0EVwHc4,11
|
|
9
|
-
pythonbeid-0.2.0.dist-info/RECORD,,
|
|
File without changes
|