eHealthDecoder icon indicating copy to clipboard operation
eHealthDecoder copied to clipboard

unable to decode base45

Open zeph opened this issue 4 years ago • 5 comments

decoding the base45 string obtained by my tool https://github.com/zeph/qr_encode_disaster_recovery from the Green Pass I just got on my Immuni App fails miserably with a decode error... same happens attempting with the official test data at this address https://github.com/eu-digital-green-certificates/dgc-testdata/tree/main/IT/2DCode/raw (at least with example 1.json)

any luck?

zeph avatar Jun 28 '21 08:06 zeph

after the pip install -f requirements.txt present in this project... $ curl https://raw.githubusercontent.com/eu-digital-green-certificates/dgc-testdata/main/IT/2DCode/raw/1.json|jq .BASE45|base45 --decode

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  8093  100  8093    0     0  64934      0 --:--:-- --:--:-- --:--:-- 65266
Traceback (most recent call last):
  File "/home/gms/tmp/local/qr_encode_disaster_recovery/.p3/lib/python3.9/site-packages/base45/__init__.py", line 32, in b45decode
    buf = [BASE45_CHARSET.index(c) for c in s]
  File "/home/gms/tmp/local/qr_encode_disaster_recovery/.p3/lib/python3.9/site-packages/base45/__init__.py", line 32, in <listcomp>
    buf = [BASE45_CHARSET.index(c) for c in s]
ValueError: substring not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/gms/tmp/local/qr_encode_disaster_recovery/.p3/bin/base45", line 8, in <module>
    sys.exit(main())
  File "/home/gms/tmp/local/qr_encode_disaster_recovery/.p3/lib/python3.9/site-packages/base45/cli.py", line 28, in main
    sys.stdout.buffer.write(b45decode(data.decode()))
  File "/home/gms/tmp/local/qr_encode_disaster_recovery/.p3/lib/python3.9/site-packages/base45/__init__.py", line 45, in b45decode
    raise ValueError("Invalid base45 string")
ValueError: Invalid base45 string

zeph avatar Jun 28 '21 08:06 zeph

it got me base45 0.2.1 ...I'll open a ticket there too if it looks more appropriate

zeph avatar Jun 28 '21 08:06 zeph

Do I need to put all the text from the QR, as argument? Or only a portion? If I put all the text... image

PS: Esiste un modo invece per generare la stringa, dal Json?

Verg92 avatar Jul 19 '21 07:07 Verg92

Do I need to put all the text from the QR, as argument? Or only a portion? If I put all the text...

according to "2D Barcode Specifications" the string must start with "HC1" or "HC2". What did you use to read your QR?

siddolo avatar Jul 21 '21 11:07 siddolo

PS: Esiste un modo invece per generare la stringa, dal Json?

Implementare gli step al contrario. Chiaramente non puoi generare una firma valida poichè non disponi delle chiavi private.

siddolo avatar Jul 21 '21 11:07 siddolo