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

Clarify about QR numeric encoding - is it unique to Smart Health Cards? #162

Open
jtara opened this issue Jul 15, 2021 · 3 comments
Open

Comments

@jtara
Copy link

jtara commented Jul 15, 2021

Doing one of the hardest things in software development - naming! And I don't know what to call my little function that decodes the numeric QR code value to Base64.

Is this encoding scheme some standard, borrowed from somewhere else, or unique to Smart Health Cards?

If it is some standard, would be good to mention it, and then we know how to look for already-existing optimized implementations, rather than having the re-invent the wheel. (As I just have in Ruby...)

It is simple, easy to implement in any language (but perhaps one shouldn't have to) but, at least... what is it called?

It's a bit of a Caesar Cipher, but of course that's not it's purpose.

As it is, I'm going to turn it into a Ruby String extension, with the awkward named shc_qrnum_to_b64 Which MIGHT be appropriate, if it is unique to Smart Health Cards.

Yea, I should subclass string perhaps (me lazy) - then the function becomes just to_b64 but I still have the conundrum as to what to call the class.

TL;DR Does the algorithm have a name? If so, can it get into the docs? If not, clarify it's not a common algorithm and is unique to Smart Health Cards.

@jmandel
Copy link
Member

jmandel commented Jul 15, 2021

Agreed, naming is hard :-)

And I don't know what to call my little function that decodes the numeric QR code value to Base64

I have a nit-pick here: technically you're not turning a numeric QR into a B64 string -- you're turning it into a JWS, which includes three base64 strings separated by .s (the presence of . in the output means the output itself isn't valid base64 content).

@jtara
Copy link
Author

jtara commented Jul 15, 2021

Thank for pointing out the b64 misnomer, sure it's a jws.

I'm ultimately planning on using ruby-jws, right now just using some utility functions in it, and hacked-together ad-hoc code to decode and verify using bits of ruby-jws and bits of openssl. ruby-jws didn't anticipate the compressed payload, and so can't verify the jws (as opposed to the signature) without some way to tap into the decode chain. I will see if I wind up with something useful to contribute back to ruby-jws.

from_shc_qr_numeric might be a good name. To String, it's just a String. The representation would seem to have use beyond Smart Health Cards, though.

@jmandel
Copy link
Member

jmandel commented Jul 16, 2021

Depending on your goals, consider https://rubygems.org/gems/health_cards for ruby, too.

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

2 participants