HDE Advent Calendar 2016

“one day - one person - one blog post”, from December 1st - 25th

HDE Advent Calendar Day 8: How does QR code Work?

Hi! This is Ted, a new member and just spent my first week at HDE. Although I really want to write about my experience here in Japan since I have always wanted to come here ever since I started watching animes in high school, but I think there is not enough for me to write for the entire article just yet, and I will save it for another time. After reading about movies, travelling and testimonials, let’s read something informative. When I was scanning the secure browser QR code, I was quite amazed that the image gets recognized and can be converted to a string of text, which is then decrypted. QR code is so abundant today, but how does it actually work? Why can the code be scanned despite the code is often partially damaged? What advantage does it have compared with traditional bar codes?



Some History

QR code, short for Quick Response code is a type of binary code that was invented by a Japanese company called Denso Wave (automotive industry). It has been used widely today in the commercial world including tracking, information management, sales management and goods identification.


How does it work?

QR code is a binary code because it only stores two values 0 (white)/1 (black), but it is also a matrix code. The matrix feature allows QR code to store much more information than the traditional one-dimensional bar codes, or approximately 350 times more information; the ability to store more information also enables QR code to tolerant errors or damages better. The specific math error correction QR code uses is called Reed Solomon code, a technology that has been adopted in CDs, DVDs and RAID 6. There are error correction abilities ranging from 7% to 30%, but there is a trade-off between the amount of data the QR code can store and the correction ability of the QR code. Therefore, we often see QR codes with images on them, thanks to error correction algorithm.


The Technical

QR code has several characteristics encrypted in the matrix that helps the machines to read the data despite the direction or size. First there are the conspicuous position patterns at the three corners. Then there is a “timing code” between the two position patterns at the top and a “timing code” between the two position patterns on the left. The timing code helps the machine to understand how big each cell is in terms of width and height; the ability to be able to scan QR code regardless of the direction, the angle or the size is therefore attributed to the timing code. There are then two copies of the “mask code” along the two position codes on the left which helps to “unmask” the code. The redundancy is to ensure that when one part is damanged, the other part still has a copy of the information. There is then an encrypt information (the type of information stored), the length information (the number of blocks to read).

To understand what I am explaining above more lucidly, I recommend this video:

How to Decode a QR Code by Hand

I think just watch the first 10 minutes will give you a great insight into how to decrypt the code.



Since the mobile devices have been so abundant today and the world is inundated with information, QR code has been used widely for devices to scan and quickly access URLs. However, there are people who exploit QR codes in order to send malicious javascript and web advertisement. There has been cases in Russia, where smartphones that scanned the QR code send SMS texts that caused $6.



I don’t want to explode your brain, so let’s look at how this technology can be used creatively in life!

The World Park Interactive Museum @ New York's Central Park

I hope you really learnt how QR code works or at least the idea behind this technology while reading through this article.