Now Reading
Decoding small QR codes by hand

Decoding small QR codes by hand

2023-06-02 22:33:33




Decoding small QR codes by hand

2012-04-21

It isn’t exhausting to decode QR codes with a pen and paper. For this information I’ll seize a random QR code from google photographs and present the method of decoding it by hand. QR codes comprise a number of error correction info and so they can survive a number of errors, however that is rather a lot tougher to do utilizing only a pen and paper (and 99% of the QR codes you encounter haven’t any lacking bits, so it is hardly ever needed). So I am going to spotlight the place the error correction info is saved, however I will not clarify it on this information.

The image I discovered is from http://mikejcaruso.blogspot.ca/2011/04/qr-code-tattoos.html

qr-1.jpg

Earlier than we start we must always rotate it to the correct orientation. QR codes all the time have 3 timing patterns (massive black squares) in all of the corners aside from the bottom-right. So we have to rotate our image 90 levels counterclockwise:

qr-2.jpg

The very first thing we must always be taught is what QR code model we’re taking a look at. The model principally simply represents the bodily dimension of the QR code. Rely the variety of pixels (or modules) throughout the QR code, subtract 17, and divide by 4. For instance, our tattoo QR code is 25 modules vast, and (25-17)/4 = 2, which implies this can be a model 2 QR code. Very massive QR codes (variations 7-40) have just a few further options, however most client QR codes are pretty small and easy, so that you needn’t fear about that.

Subsequent, we are going to determine our QR code’s format marker. Each QR code shops two an identical copies of the format marker, however we solely want certainly one of them. The format marker is 15 bits lengthy: 5 bits of format info, and 10 bits for error correction. The primary 5 bits of the format marker maintain the error correction stage (2 bits) and the information masks (3 bits). These 5 bits are discovered right here:

qr-3.jpg

So in our case the format info is 01100. Nonetheless this quantity has been XOR’ed with 10101 earlier than being written into the QR code. So we should flip bits 1, 3 and 5. After flipping the bits, we get a format info string of 01100^10101 = 11001. The primary two bits of this worth are the error correction stage (the quantity of error correction information included within the QR code). Once more, we are able to ignore this. The final 3 bits of the format string are 001, and that is an important piece of knowledge. This implies the physique of the QR code has been masked in opposition to the masks quantity 001. Here’s a desk of all of the potential masks numbers and their look:

qr-mask.png

Here is the place you want the pen and paper. The rationale QR codes are masked within the first place is that generally explicit mixtures of information bytes produce QR codes with sure undesirable options (like massive empty blocks within the center). These undesirable options confuse the QR code reader, so the information is masked in opposition to a price as a way to make the code simpler to course of when it is scanned by a QR code reader. The pc then unmasks the unique information bytes utilizing the identical course of, and retrieves the information.

You’ll be able to think about the masking course of as primarily masking the floor of the QR code in one of many patterns seen above, ranging from the highest left nook. In our case now we have a masks reference quantity 001, which implies the entire odd-numbered rows are black. As soon as we have tiled the floor of our authentic QR code utilizing the masks sample, then each black pixel within the masks means we have to invert the corresponding bit within the authentic QR code. So in our case, we have to (in our thoughts, or utilizing the pen and paper) invert the entire bits on odd-numbered rows. Observe that we solely masks the information pixels, and never the timing patterns or the format marker (in any other case we would not know unmask it to get the masks reference quantity!). The information areas are the yellow areas on this image:

qr-data.png

I’ve highlighted the information areas of the tattoo QR code beneath:

qr-5.jpg

Observe that there is a little island in the midst of the information space that we should work round. That is known as an alignment sample, and everytime you see one within the information simply skip previous it to learn the information bytes.

Any longer we have to all the time keep in mind the masks sample above, and at any time when we learn bits from the information part we have to account for the masks sample, and flip any bits that might be masked off by it (in our case, that is each odd row).

The information part consists of [header][data] chunks. Technically QR codes are allowed to have a number of of those chunks, however most QR codes simply have one massive chunk that holds all the information, so it will not matter. The header has an encoding sort and a size (the variety of information bytes). The encoding sort is all the time 4 bits, however the size is saved in 8-10 bits relying on the encoding sort. Here is the encoding sort of our tattoo:

qr-4.jpg

However keep in mind, each odd row must have its bits inverted. To assist us keep in mind, I am going to use inexperienced to focus on each cell that must be inverted after we learn it:

qr-6.png

Now, the encoding sort is saved because the bottom-right 4 bits, ranging from the underside proper and dealing left and proper in a zig-zag movement.

qr-7.png

So in our case, the tattoo itself has the bits 1000. Nonetheless the underside row is masked, so we invert the primary two bits: 0100. Which means that our QR code’s encoding sort is 0100. Here is the desk of encoding sorts:

  • 0001 Numeric
  • 0010 Alphanumeric
  • 0100 8-bit Byte

The opposite encoding sorts are hardly ever utilized in client QR codes. They’re used for encoding japanese characters, customized charsets and spreading a message throughout a number of QR codes in sequence. For our functions these 3 encodings can be sufficient.

In order that signifies that our QR code makes use of 8-bit byte encoding. The following piece of knowledge is the size discipline, or the variety of characters (clusters of bits) which are within the message. Like I stated, the size discipline adjustments dimension relying on the encoding sort. Here is the variety of bits within the size discipline, for every encoding sort:

  • Numeric (10 bits)
  • Alphanumeric (9 bits)
  • 8-bit Byte (8 bits)

Since we’re utilizing 8-bit byte mode, our size discipline is 8 bits lengthy. We learn the following 8 bits in a vertical zig-zag movement, like this:

qr-7-length.png

So the tattoo itself accommodates the bits 11011100 (studying from backside to high). Nonetheless we have to masks two of those rows, so the precise size discipline has the worth 00010000. That is 16 in decimal, which implies this QR code has a message that’s sixteen 8-bit bytes lengthy. After the size discipline, the bytes themselves are saved, one after one other, MSB first. We proceed climbing in a vertical zig-zag movement till we hit the highest, after which we curl over and proceed downwards as seen on this image:

qr-placement.png

So the primary byte could be 10000110 (masked), which is 01001101 (unmasked). That corresponds to ASCII character ‘M’. The following byte could be 10101101 (masked), which is 01100001 (unmasked). That corresponds to ASCII character ‘a’. To this point we have decoded “Ma”.

Persevering with up and across the nook: 10100000 (masked), or 01100011 (unmasked). That is ASCII ‘c’. Then it is ‘i’.

By persevering with on this approach, we are able to decode the complete message: Maci Clare Peltz.

heavyw8t

So WTF is Maci Clare Peltz alleged to be?

qartis

My guess is somebody’s girlfriend’s title, however I am undecided.

Raymond Decelles

Most likely the tattoo proprietor’s girlfriend, spouse, mom, daughter, no matter.

Luke

how do we all know that it XORed with 10101?

qartis

ISO 18004:2006, part 6.9.1 paragraph 4 says:

The 15-bit error corrected format info shall then be XORed with the Masks Sample 101010000010010, as a way to be sure that no mixture of Error Correction Degree and information masks sample will end in an all-zero information string.

the place the primary 5 bits of the Masks Sample are utilized to the 5 information bits of the format info.

Les Potter

So how do you zigzag across the alignment thingy? Additionally, the purple field on the high of the QR is barely 7 bits vast. Are you able to clarify why?

Les Potter

Your paragraph on the format code says it is 14 bits lengthy, however then beneath the spec is quoted as saying it 15 bits lengthy. Are you able to clarify?

qartis

Whoops, that was a typo. You are appropriate, the format code is 15 bits lengthy.

qartis

My earlier footage had a border line incorrectly drawn, making it appear like there have been solely 7 bits alongside the highest edge. I’ve redone the photographs to hopefully make it a bit extra clear. As for zig-zagging across the alignment sample, the best approach to consider it’s that you just skip previous the bits which are occupied by the alignment sample. Here is a picture from Wikipedia that reveals a number of examples of zig-zags passing close to alignment patterns (picture credit score Walter Tuvell, wtuvell)

Martie Anderson

I am caught on deciphering this code. Any takers? Thanks, Martie (sorry it is so faint.)

qartis

Hello Martie, that code is not a QR code, it is a Knowledge Matrix code. It represents the textual content string: “358166070831158”. I’ve connected a clearer model right here so that you can try to decode (see the Knowledge Matrix wikipedia article: https://en.wikipedia.org/wiki/Data_Matrix). If there may be sufficient curiosity I can create a weblog put up about decoding different 2D barcode codecs by hand.

See Also

Martie Anderson

Something you are able to do could be so useful. The code was adhered to the again of my cellphone. May or not it’s a brand new format of GPS monitoring? Is thishe what’s placed on produce to trace gross sales? Thanks for your entire assist.

刘文景

If there are some errors within the information code, I’m wondering how one can decode it?

Iri

https://uploads.disquscdn.com/images/5c239e6cf4e9e5ded58cac253f360a820253225c446f7898317aeb3dbe9b3811.jpg I’m caught decoding a qr code…. I’ve tried a number of methods. It was despatched a very long time in the past so possibly it has expired. Any takers?

http://elpapelillo.wordpress.com

Felfa

It is a base64 encoded textual content. Actually, this QR code says: ENC;(...):Lz0YbziKr+6AIUiR9l8jwISyBWES4ah/xVBBIMV4eTs=

QR codes by no means expire.

Iri

Thanks Felfa! I received the identical code from a QR decoder… I don’t know what this code means. May or not it’s an additional encrypted message or is it a line of code you suppose?

PointyOintment

GPS? It is actually only a label. It was most likely used within the manufacturing facility to trace elements and accomplished telephones transferring by the meeting and packaging processes.

kamrom dechu

I scanned the tattoo QR code into Pokemon Moon. It gave me a Taillow.

Ninan Naner

Might you educate me to decode qr code as present beneath,please?
I strive a number of time as comply with your resolution to decode however I nonetheless cannot get the reply “A1”.

Thanks very a lot. I hope you will notice my query and reply me in early.

https://uploads.disquscdn.com/images/51d2418d871d509ef1ee0076aa38b94dc13ea44b3b868f7ec112d3c4939d2de7.jpg

David Konsumer

It is binary information, base64 encoded. You will get the binary by pasting Lz0YbziKr+6AIUiR9l8jwISyBWES4ah/xVBBIMV4eTs= right here: http://www.motobit.com/util/base64/decoder

Ninan Naner

I received it. Thanks.

Edmund French

Hello there,

I am within the means of decoding a QR code, and utilizing this information as..properly, a information, however one factor I am unable to get my head round – the tattoo is clearly 25×25, however the footage proven which are not the tattoo are 21×21. I haven’t got any programming expertise or something related, so I think I am lacking one thing apparent.. I’ve gone proper as much as the ‘divide into 8 bit blocks’ stage, however do not know part it up earlier than I decode, as a result of the sizes do not match.

Any assist drastically appreciated.

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top