Live data from Hacker News

10 > 64, in QR Codes

huonw.github.io

1–10 of 83 posts

Re: 10 > 64, in QR Codes

#2
This is particularly useful for numeric data that is usually displayed in hex, like UUIDs [1]

I used this for digital QR code tickets [2], and it made the codes so much easier to scan, even with bad lighting.

[1] https://news.ycombinator.com/item?id=39094251

[2] https://workspace.google.com/marketplace/app/qr_code_ticket_...

Re: 10 > 64, in QR Codes

#3

    qrencode -t UTF8 https://www.service.nsw.gov.au/campaign/service-nsw-mobile-app?data=eyJ0IjoiY292aWQxOV9idXNpbmVzcyIsImJpZCI6IjEyMTMyMSIsImJuYW1lIjoiVGVzdCBOU1cgR292ZXJubWVudCBRUiBjb2RlIiwiYmFkZHJlc3MiOiJCdXNpbmVzcyBhZGRyZXNzIGdvZXMgaGVyZSAifQ==
vs

    qrencode -t UTF8 https://www.service.nsw.gov.au/campaign/service-nsw-mobile-app?data=072685680885510189821994892577900638215789419258463239488533499278955911240512279111633336286737089008384293066931974311305533337894591404330656702603998035920596585517131555967430155259257402711671699276432408209151397638174974409842883898456527289026013404155725275860173673194594939
The latter one is actually smaller. TIL

Re: 10 > 64, in QR Codes

#4

qrencode -t UTF8 https://www.service.nsw.gov.au/campaign/service-nsw-mobile-app?data=eyJ0IjoiY292aWQxOV9idXNpbmVzcyIsImJpZCI6IjEyMTMyMSIsImJuYW1lIjoiVGVzdCBOU1cgR292ZXJubWVudCBRUiBjb2RlIiwiYmFkZHJlc3MiOiJCdXNpbmVzcyBhZGRyZXNzIGdvZXMgaGVyZSAifQ== vs qrencode -t UTF8 https://www.service.nsw.gov.au/campaign/service-nsw-mobile-app?data=07268568088551018982199489257790063821578941925846323948853349927895591124051227911163…

Note that the URL also has to be encoded in two segments, so that the decimal part can use a more efficient QR encoding than the alphanumeric base URL.

I'm not sure that qrencode CLI tool will automatically do this for you.

> In a URL, the rest of the URL is not purely numeric, so actually seeing the benefits of this encoding requires using two segments:

> * one with the “boring” bits of the URL at the start, likely using the Binary mode

> * one with the big blob of base10 data, using the Numeric mode

Re: 10 > 64, in QR Codes

#5
We have a similar problem at work right now, but due to different constraints we've settled on Base85. Slightly denser than Base64, but still just plain old printable ASCII characters and the following characters are still "free" so one can use them as field delimiters in a CSV-style format:

    "',/[]\
Incidentally, this also makes them JSON-Safe.

Base94 uses all printable characters, and Base122 uses both printable characters and whitespace.

UUIDs encoded in various alphabets:

    len     algo               value
    24 Base64 padded   wScmB8cVS/K05Wk+nORR8Q==
    22 Base64 unpadded osnQ3DUDTDuUQBc9mBRYFw
    20 Base85          rHoLuTk%W0fgpY+`c>xc 
    20 Base94          d(+H"Q/hP}i}d9

Re: 10 > 64, in QR Codes

#6
post #4

qrencode -t UTF8 https://www.service.nsw.gov.au/campaign/service-nsw-mobile-app?data=eyJ0IjoiY292aWQxOV9idXNpbmVzcyIsImJpZCI6IjEyMTMyMSIsImJuYW1lIjoiVGVzdCBOU1cgR292ZXJubWVudCBRUiBjb2RlIiwiYmFkZHJlc3MiOiJCdXNpbmVzcyBhZGRyZXNzIGdvZXMgaGVyZSAifQ== vs qrencode -t UTF8 https://www.service.nsw.gov.au/campaign/service-nsw-mobile-app?data=07268568088551018982199489257790063821578941925846323948853349927895591124051227911163…

Note that the URL also has to be encoded in two segments, so that the decimal part can use a more efficient QR encoding than the alphanumeric base URL. I'm not sure that qrencode CLI tool will automatically do this for you. > In a URL, the rest of the URL is not purely numeric, so actually seeing the benefits of this encoding requires using two segments: > * one with the “boring” bits of the URL at the start, likely…

> I'm not sure that qrencode CLI tool will automatically do this for you.

If I'm looking at the correct repository, it does [1].

[1] https://github.com/fukuchi/libqrencode/blob/master/split.c

Re: 10 > 64, in QR Codes

#7
This is really great, I didn't know you could switch encoding schemes within the same QR code. There's a nifty visualization tool [0] that shows how this can reduce QR code sizes. It can determine the optimal segmentation strategy for any string and display a color-code version with statistics. Very nice!

0: https://www.nayuki.io/page/optimal-text-segmentation-for-qr-...

Re: 10 > 64, in QR Codes

#8
Or... Don't encode data in the URL at all. If your data isn't secret or per-user, have it go to https://yoursite.com/gh. If it is security sensitive, go to https://yoursite.com/Qhm4Qr55mS

2 alphanumerics (=4000 links) is plenty to encode a link to all the major pages of your website/service you may want to advertise. 10 alphanumerics (=10^18) is plenty that even if every person in the world had a QR code, nobody could guess one before hitting your rate limiter.

The user experience gained by fast reliable scanning is far greater than that enabled by slightly improved offline support (offline functionality requires that the user already has your app installed, and in that case, you could preload any codes that user had access to).

Re: 10 > 64, in QR Codes

#9
post #4

Earlier quoted context omitted.

Note that the URL also has to be encoded in two segments, so that the decimal part can use a more efficient QR encoding than the alphanumeric base URL. I'm not sure that qrencode CLI tool will automatically do this for you. > In a URL, the rest of the URL is not purely numeric, so actually seeing the benefits of this encoding requires using two segments: > * one with the “boring” bits of the URL at the start, likely…

> I'm not sure that qrencode CLI tool will automatically do this for you. If I'm looking at the correct repository, it does [1]. [1] https://github.com/fukuchi/libqrencode/blob/master/split.c

You're right! I briefly searched the code but I missed seeing that since they don't use the term "segment".

Re: 10 > 64, in QR Codes

#10

Or... Don't encode data in the URL at all. If your data isn't secret or per-user, have it go to https://yoursite.com/gh . If it is security sensitive, go to https://yoursite.com/Qhm4Qr55mS 2 alphanumerics (=4000 links) is plenty to encode a link to all the major pages of your website/service you may want to advertise. 10 alphanumerics (=10^18) is plenty that even if every person in the world had a QR code, nobody cou…

As the article mentions, they need to include the data so that the app could work offline, at least to some degree.
Post reply on HN