commit 5828f1f50c1c1724d9174549badf69fa75f20b0b Author: Arne Keller Date: Wed Jul 28 15:33:51 2021 +0200 Initial commit diff --git a/decodeVaccineQR.py b/decodeVaccineQR.py new file mode 100644 index 0000000..b583e4c --- /dev/null +++ b/decodeVaccineQR.py @@ -0,0 +1,43 @@ +from base45 import b45decode +import zlib +import cbor +from datetime import datetime + +# scan your QR Code using e.g. zbar-tools (zbarimg) + +qr_decoded = b"HC1:DATA_OF_QR_CODE" +step1 = b45decode(qr_decoded[4:]) +step2 = zlib.decompress(step1) +step3 = cbor.loads(step2) +step4 = step3.value +step5 = step4[2] +step6 = cbor.loads(step5) + +ISSUER_CLAIM = 1 +EXPIRATION_CLAIM = 4 +IAT_CLAIM = 6 + +HCERT_CLAIM = -260 +EU_DGC_V1_CLAIM = 1 + +print("Country:", step6[ISSUER_CLAIM]) +print("Issue date (UTC):", datetime.utcfromtimestamp(step6[IAT_CLAIM]).strftime('%Y-%m-%d %H:%M:%S')) +print("Expiration date (UTC):", datetime.utcfromtimestamp(step6[EXPIRATION_CLAIM]).strftime('%Y-%m-%d %H:%M:%S')) + +step7 = step6[HCERT_CLAIM][EU_DGC_V1_CLAIM] + +print("Name:", step7["nam"]) +print("Date of birth:", step7["dob"]) +print("Schema version:", step7["ver"]) +print("Certificate info: ...") +for step8 in step7["v"]: + print("Unique Certificate Identifier:", step8["ci"]) + print("Country:", step8["co"]) + print("Date of vaccination:", step8["dt"]) + print("Dose number:", step8["dn"]) + print("Doses required:", step8["sd"]) + print("Targeted disease:", step8["tg"], "(expected value: COVID-19 = 840539006)") + print("Vaccine type:", step8["vp"], "(e.g. mRNA = 1119349007)") + print("Vaccine manufacturer:", step8["ma"], "(e.g. Biontech = ORG-100032015)") + print("Medical product ID:", step8["mp"], "(e.g. Comirnaty = EU/1/20/1528)") + print("Certificate issuer:", step8["is"]) \ No newline at end of file diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..4cdbccf --- /dev/null +++ b/poetry.lock @@ -0,0 +1,29 @@ +[[package]] +name = "base45" +version = "0.4.1" +description = "Base45 Encoder/Decoder" +category = "main" +optional = false +python-versions = ">=3.7,<4.0" + +[[package]] +name = "cbor" +version = "1.0.0" +description = "RFC 7049 - Concise Binary Object Representation" +category = "main" +optional = false +python-versions = "*" + +[metadata] +lock-version = "1.1" +python-versions = "^3.8" +content-hash = "37666b70034bae04212d4c588e48e584f8e445517fd83d4dadb4a92caf927e33" + +[metadata.files] +base45 = [ + {file = "base45-0.4.1-py3-none-any.whl", hash = "sha256:ba5e93482c8954583e29643ef236af8fa804383d5961e5d2630d2ed6577111a0"}, + {file = "base45-0.4.1.tar.gz", hash = "sha256:dd963b02f8933770851f7f430b952f1fb7d71e0d261df981b2d5486996ec52c1"}, +] +cbor = [ + {file = "cbor-1.0.0.tar.gz", hash = "sha256:13225a262ddf5615cbd9fd55a76a0d53069d18b07d2e9f19c39e6acb8609bbb6"}, +] diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..cc535e2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,17 @@ +[tool.poetry] +name = "decodecovidvaccinecertificate" +version = "0.1.0" +description = "" +authors = ["Arne Keller "] +license = "GPL-3.0-or-later" + +[tool.poetry.dependencies] +python = "^3.8" +cbor = "^1.0.0" +base45 = "^0.4.1" + +[tool.poetry.dev-dependencies] + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api"