Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I get ValueError("Invalid base45 string") #15

Open
Mindrix95 opened this issue Sep 28, 2021 · 16 comments
Open

I get ValueError("Invalid base45 string") #15

Mindrix95 opened this issue Sep 28, 2021 · 16 comments

Comments

@Mindrix95
Copy link

Mindrix95 commented Sep 28, 2021

Hello, i've try with the exemple string and it working well but with my personnal string i get ValueError("Invalid base45 string"), any idea ?

@Theagainmen
Copy link

Same problem here, mine starts different than the HC1, I changed it to what I have, but it still doesn't seem to work.

@hannob
Copy link
Owner

hannob commented Sep 29, 2021

Without seeing the cert there's little I can do, though the error sounds like, well, there's invalid base45 in there.
Can you comment from which country you are, and maybe try to find an example cert from your country? I think some use slight variations of the EU standard, but that would be countries not part of the EU. Maybe we can add support for that.

@Theagainmen
Copy link

Theagainmen commented Sep 29, 2021

Sure, here is an example from my country (Netherlands):
NL2:EV%4XNSNR/20F4W8T.GMJY+6WNM9UP:CE*$.WKJ5:IM5 J1N%D1-2%/Q5 4OBKOWOJY90+O800$6UCAHAH -UYXQ:FAN552TLXZO*/15Y2NZZMP STARP4V:UDIR7-PJ *DIY$YR2W8977JAH3X8.*EX-090JXV-ZYGFH.02A+Q7JXI8 -T:LZCAMUQ4/F74JTU5*3QH/RQ4SFO4+3F7M%*W5NGB COGU*$:R4WZ/XSZ.N/6EW4091:-D$JFK5077%KR2.TOW+8W.T0X4YGOKLE$2F5ZEZ/YIQI*MEH+9ABYEVBQ4+E9T$N97*V73AOV-%TPI-:U$VXG-K54ZWSOQ7%7EALNTH0IMBNY08 7R7FN7VD2-77AXJ3N$M 6OPAH:M-9 I:-QWRB.KZT.K2D.71S%3D2CMB *:%WCL3B-03//SXX CQSE/P-CD$T9G49$ID4K0L$-$L$FEPZP-H.0%H15SHTR/XRU*1PD-42ZFHPP9FNP3D%MXST*GC4RP3:7V K/K$:8E%7Y.I:I:L3V%YD+QQZ-4*ZA/D7$Y15FP76J:OPUAI.83MA7ZUTYIQZPW*$U*O.X%P9NG5YVL0D.JZP0%XBANZ$TXHQMBD.9T8LGBM11Q4JV K0Y 8SHB0 IUUN6TI5JIXHNPBA.ZSAXZY*USZ7WS/2J$US0D..5Q9H./BC2:0J+LC7.7C778/6VOZN*5VUU0W+L5BRD6U%%KT0Y.X BIRF *TRH2Q/%$DKV1 E$$JKTNB%7GZPLAK9ZNEXN0G-BXK7 P*A421PN14Z:R17.M-L0J+BEBH9RERULT-5K7-*NA.5.B.T$2D AQMI%EN-6VC%N-Z5FIPQ-.I8PQ0N:/UBTWCFGY:.Y/LD-LN0R-007Q2D$6WYB6HY3X63JMV*X:4HN:.2EP*2E9L*7LKGX5DUGQEB88H YU*BX 6YVK YUT4P-YR*9:J*R.D2GOC1VDP%8XPT%9*A+V0-/*$51J795Y.HR$*CUR4*HQ*DOYG/+LS-KP08RB 9S.57 MJR8*O+$Q$A/N$ECGV43NIHZNE6TZ2FVIV$V:D7 3A+BZWAF0UG5CERB.HZGO4TJ92:+:P.WFT2KX6IDLJ63.Q95ADSFVD-TDHX3C1+DALEA.WR*YR.K-:8:VN1YX04GGEN WR0-3D%4PS5JXX.8-NT8RW1S6BK5.12R661U745*UASZ55.O8YQ6 YTZ./DZIZWDAPWUB9Z169SQBX-QNC*XTM5ITP56*2LVICJE4UEJB*5QOMQI4D 3P6C-E/$Y3C9L%KKA8LQ8.D*GEOX75VVLL1DZ33E03/KB4-

Changed the HC1 replace to this in code b45data = cert.replace("NL2:", "")

Do you see anything different than yours?

@Mindrix95
Copy link
Author

Hello ! I'm from france and i'm not afraid to share mine, it doesn't works :

HC1:NCFOXN%TSMAHN-HOUKYHFKK1C8JY%79EHJMAD61Y5:X94PSPAO6R5EB5718PV5-FJLF6EB9UM97H98$QP3R8999Q9E$BDZIF7J7UJYIJZJA3CJPA ZJ83B:2T0KTO9TY$SSQTNI92K92KIJ 7K49B:ZJ83B49UYPTVEU053WZJ$7K+ CUEDDIK9AD1QDGHJYSQ9I67Q4UYQDO%+Q.SQBDO3KLET4615IHP- R4FLM47:/6F0PKSOF77V776K82HPPEPHCR7XBHDOTONO7IRJSP/88KCOK594%I7ZC/FJBAJULJJ9G KPA.DS0IZ5QYE9/MVB1C3ZCD6L 0PN0ZW46+A3VGNNVRG0C7PHBO33PHN%GB$A7WSNBRN%BBHONSK31H3%85709OZL65NO-U+KTBLR19115V6IEPZ7W:AXUGTCOQ83E$ERQV95365EU0O1SO7MFPYQ5XME5UX38/MKD$TGT52:UD13%7SEIB8ES0:3Q2R820G/OB1

@Theagainmen
Copy link

Hello ! I'm from france and i'm not afraid to share mine, it doesn't works :

HC1:NCFOXN%TSMAHN-HOUKYHFKK1C8JY%79EH_JMAD61Y5:X94PSPAO6R5EB5718PV5-

Just to speed things up: edit your message and place your code in between these `` tags, this way it shows up like this and it doesn't use mark-up, now the code you sent is invalid anyway, since it removes the underscores and creates italics text

@Mindrix95
Copy link
Author

Finnaly it works well, my mistake was to trust my android phone to extract the string from the QR Code. But with a screencapture and the PIL module, i've a different string !

@Theagainmen
Copy link

Finnaly it works well, my mistake was to trust my android phone to extract the string from the QR Code. But with a screencapture and the PIL module, i've a different string !

Ah great it works for you! I do it the same way and have tried it a few times now, for me the issue stills persists, can you maybe keep the issue open for me? :D

@hannob
Copy link
Owner

hannob commented Sep 29, 2021

@Theagainmen given your cert has a different prefix (NL2 instead of HC1) I wonder what that means. Maybe there's some different encoding here? I can change the code to remove any prefix, but it seems it still doesn't decode, so that wouldn't help us much.
I would have to look into the standards, but currently I don't have time.

@Theagainmen
Copy link

@Theagainmen given your cert has a different prefix (NL2 instead of HC1) I wonder what that means. Maybe there's some different encoding here? I can change the code to remove any prefix, but it seems it still doesn't decode, so that wouldn't help us much. I would have to look into the standards, but currently I don't have time.

Hmhh, I thought it was some kind of country code actually, since NL stands for the Netherlands. Looks like this code is also almost double the length the HC1 example code is..

I was so interested in finding out what's in this QR code, but that will have to wait then haha, thanks for your time and effort.

@Theagainmen
Copy link

I've been trying to look more into this and decode it, but the documentation doesn't really seem to be there about the code itself https://github.com/minvws/nl-covid19-testvac-qr-core and https://github.com/minvws/nl-covid19-coronacheck-app-coordination. The string looks base45 to me, but it is invalid.. maybe it's split up into multiple pieces or something?

@LuukLord
Copy link

LuukLord commented Oct 1, 2021

How and where do i correctly run the ./vac dec [image] command? I ran it using: python vacdec ("JPEG.jpg") it gives me back the ValueError: invalid base45 string.

@naxels
Copy link

naxels commented Oct 4, 2021

@Theagainmen , I haven't verified, but it seems they might be using Base58:
https://news.ycombinator.com/item?id=27603173

Update:
Following this gist: https://gist.github.com/confiks/8fcb480d87a50cf1bb5e40e2f0930fad

I am now able to decode the message, however fails on zlib:
zlib.error: Error -3 while decompressing data: incorrect header check

In the case of your shared QR text, this results in the following data:
decoded.txt

@cksoest
Copy link

cksoest commented Nov 5, 2021

is it also possible to alter information en encode it back to a qrcode

@smarek
Copy link

smarek commented Nov 6, 2021

Hit the same issue, it is important you have no leading spaces, exactly same string, but provided as "text" or "terminal" without stripping preceding and leading spaces will fail to decode

I've made fix available, along with stripping various prefix codes (not just known ones HC1, HC2, NL1, ...) in #19

@smarek
Copy link

smarek commented Nov 6, 2021

@Theagainmen For your information, it's not Base58

It's custom, Netherlands specific, Base45 encoding, that uses similar letters to encode the binary data, and the content is nothing like the EU Covid Pass

Compare

@Theagainmen , I haven't verified, but it seems they might be using Base58: https://news.ycombinator.com/item?id=27603173

Update: Following this gist: https://gist.github.com/confiks/8fcb480d87a50cf1bb5e40e2f0930fad

I am now able to decode the message, however fails on zlib: zlib.error: Error -3 while decompressing data: incorrect header check

In the case of your shared QR text, this results in the following data: decoded.txt

@naxels
Copy link

naxels commented Nov 15, 2021

Just checked this tutorial (Python):
https://www.bartwolff.com/Blog/2021/08/21/decoding-the-dutch-domestic-coronacheck-qr-code

and works for my NL code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants