8 ms·
Decoding small QR codes by hand (2012)
- teeray 3y agoCan’t wait for someone to do this on a post-apocalyptic TV show
- account-5 3y agoI often wonder if the was an apocalypse and society rebuilt having forgotten the past what archeologists would make of thing ls like QR codes, and would they be able to work them out?
- deleted 3y ago[deleted]
- xg15 3y agoI also wonder if they'd grossly underestimate the complexity of the whole thing, like we tended to do with ecosystems and biological organisms. Something like "no way this one random half-row of pixels on the left and the four pixels in the bottom right have a completely different meaning than the rest of the pixels!" Also, I figure, it would be very difficult to reconstruct the mask patterns if you don't already know the formulas in advance. Someone might be able to figure out the codes that use the simple masks, but I figure, there'd still be many "unreadable" QR codes left that use the more complex masks.
- userbinator 3y agoRegardless of what specification you're implementing, I always recommend "mentally executing" the algorithms for at least small test cases, as when you inevitably need to debug your implementation, you will be forced to do so anyway, and it increases your familiarity with what it should be doing. As the saying goes: "how can you tell the machine what to do, if you don't know how to do it yourself?" For those who want to go the extra step and try the error correction by hand too, this article will be useful: https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_f... (Side note: the example image of a QR tattoo evoked slight feelings of trypophobic disgust.)
- IanCal 3y agoThis is how I was taught encryption algos - by hand on paper (simplified like fewer rounds in des) and they've stuck with me in a lot more detail for over a decade.
- cyberax 3y agoMy pet peeve: WTF PEOPLE ARE NOT PUTTING A CLEAR TEXT URL NEXT TO THE QR CRAP?!?!? Especially when the QR code itself points to a URL shortener.
- 0cf8612b2e1e 3y agoI think the forced tracking is half the point.
- whoopdedo 3y agoAn example of this and candidate for worst use of a QR code is found on Wifi APs provided by AT&T. A sticker on the device shows a convenient QR code that will get you connected. If you're thinking it uses industry standard Wifi schema well you don't know AT&T very well. Instead it sends you to att.com. That's right, in order to connect to the wifi so you can get online you must first be online so you can get the password from a website. Fortunately they still print the SSID and password on the back. But it's clear that AT&T would rather you go through their telemetry portal instead. (And then there's how the signal on it was so weak that it couldn't penetrate interior walls more than 10 meters away. But that's another story.)
- unpopular42 3y agoWhat forced tracking? If you're going to visit the URL, there is no extra tracking that can be provided by the QR or the shortener. Same if you aren't going to visit it
- ArnoVW 3y agoThe QR code means that you can include a tracking id into the URL
- tgv 3y agoThere’s no reason for it to be the same URL. It could be used to give a false sense of trust. Perhaps that’s why?
- rreichel03 3y agoThis is really neat! I’ve wanted to know the QR code contents a few times without actually scanning with my phone so I actually built a super simple app to do this. Nothing fancy, just dumping the raw contents of the code to a string. https://apps.apple.com/us/app/barcode-qr-scanner-rawcode/id1636758263 https://apps.apple.com/us/app/barcode-qr-scanner-rawcode/id1... Happy to add any features folks might be interested in!
- 0cf8612b2e1e 3y agoSuper interested. As with most things Apple, the lack of control is infuriating, and I hate how the QR scanner auto visits the scanned link rather than just decoding the data.
- AnonC 3y agoI thought I’d take a quick look to see what your app offers. Here’s some feedback: * On launch, it asks for Camera permission. I declined and the app crashed. Next launch, it opens to the blank screen with a (scan) icon and an Edit option, both on the top right. Tap on the scan icon and the app crashes. Tap on Edit and it changes to Done (there are no previous scans, obviously). It should ideally provide instructions to enable Camera permissions in the Settings app and also say why it needs it and how it’ll be used. * The App Privacy section for your app declares that it collects usage data and diagnostic data. It would be good to know more details of what’s collected (preferably in the app description). Generally, people wouldn’t expect such a (simple use case) app to collect and transmit information (unless they explicitly ask for it to be done).
- sir 3y agoJust FYI, you can also do this with the inbuilt Shortcuts app - create a shortcut to scan a QR code then copy its contents to the clipboard for example.
- jkepler 3y agoUse a better QR scanner app. I use Privacy Friendly Apps' "Privacy Friendly QR Scanner", which always presents you with the scanned URL or text in the app before doing anything, and asks you to verify that you want to visit the site. It also includes the ability to generate your own QR codes. See https://secuso.aifb.kit.edu/english/105.php https://secuso.aifb.kit.edu/english/105.php for that and other apps developed by that research group.
- sandebert 3y agoSomewhat related: How to recover a broken QR by hand. https://www.robertxiao.ca/hacking/ctf-writeup/mma2015-qrcode/ https://www.robertxiao.ca/hacking/ctf-writeup/mma2015-qrcode...
- userbinator 3y agoThe real challenge is writing a QR reader that can follow the same principles to read even more corrupted codes.
- jraph 3y agoScilabus made a nice video about it for French speaking people [1]. On a linux computer, I take a screenshot and run zbar, a cli tool available in the repositories. [1] https://m.youtube.com/watch?v=wKB-ZI2gXsk https://m.youtube.com/watch?v=wKB-ZI2gXsk
- avian 3y ago> 99% of the QR codes you encounter don't have any missing bits I see a lot of cutesy QR codes out there that include a logo in the center. These are basically intentionally damaged and depend on error correction to recover the missing bits that are covered by the logo.
- vsnf 3y agoNot if they're one of these QR codes[0], which was discussed here a few days ago[1] > Instead of scribbling on redundant pieces and relying on error correction to preserve the meaning, we can engineer the encoded values to create the picture in a code with no inherent errors But as another commenter noted, this likely increases the scan time required. [0] https://research.swtch.com/qart https://research.swtch.com/qart [1] https://news.ycombinator.com/item?id=36128082 https://news.ycombinator.com/item?id=36128082
- londons_explore 3y agoThis QArt technique can be extended with error diffusion dithering... Then the uncontrollable pixels can be hidden in areas of the image which would normally be grey, with the uncontrollable bits error contribution passed onwards to the controllable regions of the image.
- avian 3y agoThese are cool and definitely a much more interesting hack than just sticking a company logo in the middle of the code in Photoshop. But I've never seen one of these in the wild.
- deleted 3y ago[deleted]
- matsemann 3y agoHow do camera apps recognize where the QR code is in the image, and what part of the image it should decode? I guess it also often has to some processing on it, as it will be scewed/bent/etc. Looking at this guide, it's easy to understand the steps. But I don't get how one actually would apply them in code to a picture of a QR code. How?
- pjot 3y agoQR codes have certain zones that scanners look for. To determine orientation scanners look for “alignment markers”.
- phoronixrly 3y agoDo you have an article that goes into the details of implementing a reader, and does not just tell you 'use pyzbar'?
- stavros 3y agoThat would probably be a machine vision problem, but I'm also curious to know how you turn the pixels of a photo into a series of bits.
- alex_suzuki 3y agoTypically by looking at „runs“ of black and white pixels (after image has been binarized/thesholded). For a QR code marker, you would look for a 1-1-3-1-1 pattern, which would indicate that this image row crosses a QR code finder pattern.
- kaoD 3y agoBut do they do this at different angles? If so, which? How do they deal with (possibly partially) obscured alignment markers? How do they determine the angle and size of squares? How does one sample each square (center point, average of square, min, max...)? Should I convert my image to grayscale first? If so... which of the RGB-to-grayscale methods should I use for best results? Should I pre-process the picture to enhance sharpness and reduce focus artifacts? Should I bruteforce each frame of the video stream in look for the alignment markers? Etc. etc. I think I have the general idea on how all that works, but... isn't there an official spec/algorithm on how one is supposed to do this? The devil is in the details.
- xg15 3y agoOne thing that cleared up some confusion for me: The tattoo photo shows a version 2 QR code (as he writes) but the schematic images are for a version 1 code[1]. That's also why the bottom right alignment pattern is missing in the schematics. He didn't forget it, it's just not there in a v1 code. [1] https://www.qrcode.com/en/about/version.html https://www.qrcode.com/en/about/version.html
- larusso 3y agoI also saw this. So one would then simply leave this part out on the way down? Is the alignment pattern always on the same location? I guess so.
- xg15 3y agoI think the pattern has a fixed location that is defined by the version. And yeah, that was my understanding as well, you just skip the corresponding bits when doing the "zigzag reading". But I'd also like to see an example, in particular as that would be different from how the other "large" alignment patterns are handled.
- deleted 3y ago[deleted]
- nayuki 3y ago> I think the pattern has a fixed location that is defined by the version. Correct, the alignment patterns only depend on the version, not the error correction level or text encoding. Source: I read the spec and wrote my own QR encoder library.
- xg15 3y agoIs there any reason why so many different masks are required and why the mask patterns are so elaborate? In particular the last few masks seem mostly designed to make life hard for (human) decoders :)
- cornholio 3y agoWhile I understand the teaching approach, this sound like the type of task which, even if it came up as a completely random one-off need, I would feel is much easier to solve in code. The inevitable bugs in my script are at least repeatable and I can iterate until I have a solution, whereas a single bit error in the manual process will waste the entire effort with no progress. And experience has shown that, more often than not, such hack scripts find ways to grow into mission critical services. Sure, it's an ancient Mayan qr code that is unique in the world and we just so happen to have found precise decoding instructions; but are you sure the one of the stone bits isn't just a piece of fossilized bird poo that was not present in the original? Are you sure all the stone pieces were found? are you sure no other ancient qr codes will be found in the future? Life is too short not to automate everthing.
- sshine 3y agoTo me, decoding a QR code by hand is a cool feat, like solving a Rubik’s cube. It is very unlikely that you will ever need to do it. And like you said, it’s an excellent way to teach implementors of automated QR code readers/writers.
- YuccaGloriosa 3y agoThe idea that the ability to decode could be lost makes me me wonder what info you would need as a kind of Rosett Rosetta stone for a future or alien civilization. I'm thinking what would you have on a wall of stone? Would it be possible to represent the whole decode process with all options, and do it purely pictorially?
- hyperman1 3y agoThe seti project sent such a message. See https://en.m.wikipedia.org/wiki/Cosmic_Call https://en.m.wikipedia.org/wiki/Cosmic_Call which points to https://www.plover.com/misc/Dumas-Dutil/messages.pdf https://www.plover.com/misc/Dumas-Dutil/messages.pdf . Read annex B of that message. We spent a night decoding it with minimal hints, which was reasonably easy. Basically, page 1 defines numbers as dots, binary and their own symbol set. Then they define math operations. This allows them to describe some physical and chemical relations, from which the metric system is derived. This allows them to create descriptions of physical thing which, combined with some crude graphics, let them tell about our home planet. If that's possible, explaining qr codes should also be possible
- nayuki 3y agoSomeone made a decoding video tutorial a decade ago: https://www.youtube.com/watch?v=KA8hDldvfv0 https://www.youtube.com/watch?v=KA8hDldvfv0
- omoikane 3y agoRelated, this page has a step by step process of how the encoding process works: https://www.nayuki.io/page/creating-a-qr-code-step-by-step https://www.nayuki.io/page/creating-a-qr-code-step-by-step Previously discussed here: 2020: https://news.ycombinator.com/item?id=24119124 https://news.ycombinator.com/item?id=24119124 2018: https://news.ycombinator.com/item?id=18360847 https://news.ycombinator.com/item?id=18360847
- jonas-w 3y agoWow, thanks for the first link, that was exactly what I was looking for after reading TFA. But I wish I could scan a qrcode and let this website explain it to me, instead of generating one with the same content, as I couldn't replicate the one in front of me with this page.
- nayuki 3y ago> I wish I could scan a qrcode and let this website explain it to me Here you go: https://qrlogo.kaarposoft.dk/qrdecode.html https://qrlogo.kaarposoft.dk/qrdecode.html
- jonas-w 3y agoDoesn't seem to work for me, I used one of their example logo qr codes on their website and all give the error "Cannot decode a function pattern"
- tasuki 3y agoSome weird comments there, eg: > I am stuck decoding a qr code.... I have tried several ways. It was sent a long time ago so maybe it has expired. Any takers? I don't think they read the post...
- stuckkeys 3y agoHolly shit. How bored was this guy. Kudos for the dedication. Reminds of that silicon valley scene. How many guys they can j off. Funny shit.