summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2021-12-30 11:16:03 +0200
committerYuval Adam <_@yuv.al>2021-12-30 11:16:03 +0200
commit9aa2e675f538bbcdf0d5bd1d27f39fceb6bcd30f (patch)
treeb94f8b6cb2bbf2b6d84605fb2d16635071046071
parent70871ab5d000937a876ac3c41a87d0fafa5a6312 (diff)
WIP
-rw-r--r--verify.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/verify.py b/verify.py
index 257fc99..23823d2 100644
--- a/verify.py
+++ b/verify.py
@@ -17,6 +17,7 @@ class GreenPassVerifier(object):
def __init__(self, data_bytes):
self.validate_bytes(data_bytes)
+ print(data_bytes)
sig, self.payload = data_bytes.split(b"#", maxsplit=1)
self.signature = base64.decodebytes(sig)
self.data = json.loads(self.payload)
@@ -43,15 +44,16 @@ class GreenPassVerifier(object):
for i in range(len(doc)):
for img in doc.get_page_images(i):
xref, width = img[0], img[2]
- if width in (
- 3080, # in green pass v2
- 3720, # in green pass
- 4200, # in vaccination certificate
- 4680, # in other vaccination certificate
- ):
+ try:
img = fitz.Pixmap(doc, xref)
data = img.tobytes(output="png")
+ with open(f"/tmp/greenpass/{xref}.png", "wb") as f:
+ f.write(data)
return cls.from_qr(BytesIO(data))
+ except:
+ pass
+ else:
+ raise Exception("No QR found")
def validate_bytes(self, bs):
if bs.decode().startswith("GreenPass"):