I remember a couple of years ago I read up about the details on how QR codes are created. Specifically the masks that are added at the end to ensure that there aren’t any areas with too much whitespace or something that ends up inadvertently looking like the corner of a QR code (that square inside a square thing).

And for some reason, I’m staring at two QR codes in front of me, looking at the details, one looks like it contains a pipe going around a corner, another looks like it has a bit of a star, which made me wonder… Why have I never seen a QR Code with a swastika or something else you really don’t want to have on there? I’ve never seen any word on filtering out stuff like that when it comes to masking.

Am I just too bored out of my mind so that I’m staring at QR Codes like this with way too much imagination or is there something I’m missing?

EDIT: I’m sure it’s possible to intentionally create one, I’m thinking more of accidentally creating one. Specifically when I see, for instance, a different QR code on the back of every seat in a train, for instance - you’re generating so many, no human is going to check that.

  • FaceDeer@fedia.io
    link
    fedilink
    arrow-up
    37
    ·
    2 days ago

    Apparently there is a mechanism in the basic QR-code-generating algorithm that does something like this.

    There are eight different patterns that can be used to display any given QR code’s data. All eight versions get generated internally by the generation software and then they’re assigned scores that penalize them based on various patterns:

    • Large monochromatic blocks, anything more than 2x2 pixels of the same colour (white or black)
    • Long lines of either colour
    • Anything matching the “finder patterns” (the squares at the corners)
    • Imbalance between 50% black and white pixels

    The best one of the eight is the one that’s actually printed.

    So a swastika isn’t explicitly searched for, but given that a swastika is composed of a bunch of long lines a QR code pattern like that would get penalized pretty harshly. The seven other QR codes would have to be even worse for it to slip through, and I bet the odds are pretty low for that.

    • grue@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      2 days ago

      Ah, so the same checks you need anyway to make sure the thing can actually be read – because a 2x2 vs 3x3 block might start to get hard to differentiate, for example – also happens to obviate OP’s issue as a coincidental side benefit.