How do QR codes work? D. Indumathi, Bengaluru You must have seen Quick Response (QR) codes everywhere. Autorickshaw and taxi drivers want to be paid by scanning their QR codes; tea shops allow you to pay for your tea and coffee by scanning these codes, and even buses in Bengaluru allow you to pay for your bus ticket with a QR code generated newly for each passenger's ticket! How do these QR codes work? How are they different from other payment options such as Gpay or Paytm? What is a QR code You may have noticed barcodes on biscuit packets, etc. This is a set of lines on the packet. You can scan this with your cellphone camera and you will get information about the contents (see the box). The barcodes are a set of lines. In contrast, a quick response (QR) code is a box in 2 dimensions. You can think of it as a kind of matrix barcode that uses black squares on a white background to encode information. Just like barcodes, swiping on it gives information. The major difference is that there is much more information squeezed into a QR code. BOX Bar codes A barcode is a unique set of black-and-white lines that stores product details. For instance, it tells you the country of origin, name of the manufacturer, and item code for scanning. For example, the popular Parle-G Original Glucose Biscuits pack uses the barcode number 8901719101038. Here 890 is the Country Code, meaning, the product was made in India. The next group of numbers 1719 identifies the manufacturer as Parle Products. The digits 8-12 are the product code which identify the exact type, flavour, and weight of the biscuit. All Parle products will begin with 8901719 and the remaining numbers will change depending on the exact product. The final 13th number helps the scanner verify that the code was read correctly. END OF BOX A QR code The QR code is a barcode which contains more details. It not only contains static information as text material (like barcodes which tell you fixed information about the origin of the product). It can also direct you to website pages which contain more information, or even payment information. Look at a QR code; for instance the one in the picture. You can see three large squares in the corners. These tell the scanner the code's position, orientation, and angle. In fact, next time watch when your friend or parent pays using a QR code. Ask them to scan it sideways, or at different angles. The scan will still work. This is because of these "finder patterns". In fact, there is even a further correction: there is a smaller square near the bottom right. This helps to correct distortion if the code is on a curved or tilted surface. If you look at the filled squares, you can see that they are laid out in rows and columns, like a chess board (this is called a matrix). Alternating rows and columns help the scanner map out the grid. The tiny individual squares hold the actual information. How data is encoded in the QR code You may have learned of binary numbers in your maths classes. Binary numbers are represented in bits of 0 and 1. For instance, in the usual decimal system, you can write numbers from 0 to 9. For the next number, you write '10', which means '1' in the 10s place and '0' in the 1s place, adding up to 10. Similarly, '101' has '1' in the 100s place, '0' in the 10s place, and '1' in the 1s place, adding up to 101. Binary numbers work the same way. After writing 0 and 1, you write 2 as '10'. This is to be read as '1' in the 2s place, and '0' in the 1s place, adding up to 2. So 8 can be written as '1000' and 1024 as '10000000000' (this is usually called 1KB)! You can see that the number become very big very soon, but it is easy for computers to store these numbers as off (for '0') and on (for '1') switches. Coming back to our QR code, black squares represent a binary '1', and white spaces represent a binary '0'. Text, numbers, or URLs are translated into strings of ones and zeros. A QR code can be made up of a maximum of 177 rows and 177 columns, which makes for a possible 31,329 data modules. Most QR codes aren’t that big, though. Error Correction One of the most important parts of a QR code is error correction. You may have seen dirty, torn, stained QR codes hanging from a thread in a shop or auto. But they still work! This is because QR codes use fancy mathematics so that it is fully readable even if up to 30% of it is dirty, blurred, or damaged! How Do QR codes work? The scanner first recognizes the three position markers in the QR code. The quiet area is used to help the scanner find the edges of the code. Scanners read these modules following a specific zigzag path across the grid of dots. The QR code scanner begins at the bottom right of the QR code to find the mode indicator. This a group of four data modules which tell you whether the data you are going to scan are a bunch of numbers, or text (alphanumeric) or even in kanji script! The next eight data modeules are the character count indicator, which indicate how many characters are to be read in total. The scanner then moves up two data modules at a time until it hits the first position marker. Then it moves two data modules to the left and goes down. It repeats this right-to-left, up-then-down zig-zag process until every data module is covered (since it knows how many characters to read). After reading the final character, the scanner checks out the error correction data modules. Then it finally uses the data it has read to go to a new link/website or a payment portal, depending on what the QR code does. How Do Dynamic QR Codes Work? A dynamic QR code is a QR code whose encoded information can be changed after creation. That’s because the information encoded in a dynamic QR code is a short redirection URL. That means a URL that redirects to another URL, or what’s called a destination URL. On the destination URL is the content. This can be a digital restaurant menu, a syllabus, contact information, an invitation, etc. That content can be changed entirely without having to change the QR code. Additionally, the destination URL itself can be changed entirely without having to change the QR code. Because what’s encoded in the QR code is the redirection URL, not the destination URL. This is useful for Universities whose syllabus regularly gets revised, or a restaurant whose menu (or price!) changes. QR codes and safety Scanning unknown QR codes can expose you to severe digital safety threats. This malicious tactic, known as "quishing" (QR code phishing). It exploits the fact that human eyes cannot read a QR code's destination URL before scanning it. Never scan random codes found in public places, flyers, or unsolicited mail. Inspect physical QR codes at restaurants to ensure that they are the original, and have not been pasted over by malicious codes. Such codes can steal your confidential banking information or even download spyware on to your phone. As with all technology, mis-uses are always trying to keep up with the uses! How can QR codes help with online payment? Nowadays, people do not think twice before paying for even small purchases on-line. Typically, they scan a QR code, which takes you to a payment portal. What happens next? The Unified Payments Interface (UPI) app on your mobile phone allows you to transfer money from your bank to the seller's bank. How does this work? Unified Payments Interface (UPI) How Does UPI Work? Major UPI apps include BHIM (official government-backed app), Google pay (Gpay), Paytm, etc. All major UPI apps in India are equally safe because they all follow the strict security rules set by the National Payments Corporation of India (NPCI). First, the app works only on your registered smartphone using your unique SIM card. No money moves without your secret 4- or 6-digit PIN. All data is encrypted (the information is mixed up into an unreadable code using a mathematical algorithm which makes it very hard for unauthorised third-party sites to read it). Finally, the data is transferred through heavily protected banking channels. While most UPI apps need you to have an active internet connection it is possible to pay offline. The QR code enables you to access the payment system to complete the transaction. While a UPI app is much more than the QR code used to access it, a QR code is also much more than just a gateway to a UPI app! Sources: https://www.sproutqr.com/blog/how-do-qr-codes-work; https://www.geeksforgeeks.org; Wikipedia; Google Gemini AI