Created
June 27, 2021 00:32
-
-
Save TheCataliasTNT2k/fdab41e0a80b038fb77c2a039d749d25 to your computer and use it in GitHub Desktop.
Corona vaccination reader (decodes vaccination qr code) all dependencies can be found on pypi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
from zlib import decompress | |
from base45 import b45decode | |
from cbor2 import loads | |
from prettytable import PrettyTable | |
data = loads(loads(decompress(b45decode(input("QR String eingeben: ").removeprefix("HC1:")))).value[2]) | |
body = data[-260][1] | |
nam = body["nam"] | |
v = body["v"][0] | |
dob = body["dob"] | |
issuer = data[1] | |
issued_at = datetime.fromtimestamp(data[4]) | |
expires_at = datetime.fromtimestamp(data[6]) | |
version = body["ver"] | |
family_name = nam["fn"] | |
family_name_standardized = nam["fnt"] | |
given_name = nam["gn"] | |
given_name_standardized = nam["gnt"] | |
birthday = datetime.strptime(dob, "%Y-%m-%d").date() | |
target_id = v["tg"] | |
vaccine_id = v["vp"] | |
medical_product_id = v["mp"] | |
market_authorization_holder_id = v["ma"] | |
dose_number = v["dn"] | |
total_series_of_doses = v["sd"] | |
date_of_vaccination = datetime.strptime(v["dt"], "%Y-%m-%d").date() | |
country_of_vaccination = v["co"] | |
certificate_issuer = v["is"] | |
unique_certificate_identifier = v["ci"] | |
output = {"issuer": issuer, "issued_at": issued_at, "expires_at": expires_at, "version": version, | |
"family_name": family_name, "family_name_standardized": family_name_standardized, "given_name": given_name, | |
"given_name_standardized": given_name_standardized, "birthday": birthday, "target_id": target_id, | |
"vaccine_id": vaccine_id, "medical_product_id": medical_product_id, | |
"market_authorization_holder_id": market_authorization_holder_id, "dose_number": dose_number, | |
"total_series_of_doses": total_series_of_doses, "date_of_vaccination": date_of_vaccination, | |
"country_of_vaccination": country_of_vaccination, "certificate_issuer": certificate_issuer, | |
"unique_certificate_identifier": unique_certificate_identifier} | |
table = PrettyTable() | |
table.field_names = ["Description", "Data"] | |
for k, v in output.items(): | |
table.add_row((k, v)) | |
table.align['Description'] = 'l' | |
table.align['Data'] = 'l' | |
print(table) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment