Maths and Computing:

menu
Home
Mathematics
Binary
Computing
Coding
Books

Version 1 QR Codes

Version 1 QR Codes: Create



Text:

Creating a QR Code

This tool is designed to create a version 1 QR code using one of three different options.

Single Step

The QR code is created in one step using optimal settings for determining the encoding, error level and mask value

Step by Step

The settings are entered one step at a time with the available options limited by the results of the previous steps

Custom Entry

Allows the setting for the encoding, error level and mask values to be entered together.


Explanation of the Process

These pages describe the detail relating to creating a version 1 QR code and does this using the example of the QR code that is being created.

Once the QR code has been created, the following information is provided about each step of the process and the different elements involved in creating a QR code.

  • The encoding of each character
  • The calculation used to create the error codes
  • The data placement within the QR code
  • The application of the mask pattern on the data
  • The creation of the information bits


Single Step

Create the QR code in one step using the optimal encoding, error level values and mask.

The maximum length of text allowed for a version 1 QR code is:

  • 41 numeric characters
  • 25 alphanumeric character
  • 17 binary characters.

If the text entered is too long for the encoding, the text will be truncated to allow it to fit.


Enter the text that you want to create a version 1 QR code for.

Text:

Step by Step

Create the QR code step by step, by providing the values of the following:

  • The Encoding
  • The Error Level
  • The Mask Pattern

The available options are based on the output from the previous steps.


Enter the text that you want to create a version 1 QR code for.

Text:

Customise

Create the QR code in one step using customised settings for the encoding, error level values and mask


Enter the text that you want to create a version 1 QR code for.

Text:

Encoding:

Error Level:

Mask: (0-7)

 

The Key Stages in Creating a QR Code

This is a step by step overview of the processes involved in creating a QR code containing a given series of characters.

For more information, select the title button for a given stage.


  • An encoding mode is chosen to determine how the characters will be encoded.
  • Binary data can contain 7-bit ASCII characters or unicode characters that are encoded as multibyte characters using the UTF-8 encoding.
  • Numeric data takes the least space, followed by alphanumeric and then binary
  • If the data can be encoded in more that one way, then the one that takes the least space is chosen
  • An error level determines the number of bytes that can be corrupted, detected and correntec.
  • The four error levels are high, quartile, medium and low.
  • The high error level requires the most space followed by quartile, medium and then low.
  • The error level is determined accoring to whether it is more important to be able to correct data or to keep the size of the QR Code low.
  • With the input data, the encoding and the error level, the number of data bytes can be calculated..
  • The number of data bytes determines the minimum QR Code version that can be used..
  • The QR Code grid can then be set up with the number of module based on the verison 1
  • The static elements of the QR Code are the positioning patterns, the timing patterns and the spacing. These can be added to the grid.
  • There are eight different mask patterns.
  • Any of these mask patterns can be applied to the data to create a valid QR Code.
  • Certain mask patterns create a better result with fewer blocks of white and black data.
  • The result when each pattern is applied is rated, and the mask with the lowest ranking is chosen and applied to the data.
  • The format information consists of fifteen bits.
  • Two bits are used for the error level and three for the mask pattern. The rest are error correction bits.
  • A mask is applied to the bits and the resulting bits are added to the QR Code.
  • The information bits are placed near to the two left positioning pattern
  • A copy of the fifteen bits is also added to the QR Code.

Terminology

QR Code

A QR code (Quick Response Code) contains data that can be scanned in using a device which is able to capture and decode the information stored within the data.

Alphanumeric Encoding

Data made up entirely of the the numeric characters, upper case letter from 1-Z, space and the characters: $ % * + - , /

Binary or Byte Encoding

Data made up of byte size blocks. An ASCII-7 character can be represented by one byte and all other characters can be expressed using UTF-8 encoding in two or more bytes.

Bit

A binary value equal to 0 or 1 that is represented by a single black or white module in the QR code.

Character Count

The number of characters encoded in the QR Code with the exception of multibyte characters that counts each byte as a character.

Data Block

Variable bit blocks of data containing information relating to one of these:

  • Encoding mode
  • Character count
  • Encoded data
  • Padding
  • Error Codes

Data Byte

8-bit blocks of data that store the encoded data and the error codes.

Error Level

The error level determines the extent to which the QR code can be corrupted or not correctly scanned and the data can still be corrected.

Encoding Mode

Determines how the data is encoded. The standard encoding modes are numeric, alphanumeric, binary and kanji. The value is stored in a 4-bit block.

Error Bits

Additional bits that are added to the data to enable error correction.

Galoid Field Arithmetic

Calculations performed on a finite number of elements. QR codes use GF arithmetic over 2 and 256 elements. Calculations use the XOR operation and polynomial division.

Indicator Blocks

Two blocks of data used to store the encoding mode and character count.

Information Bits

Fifteen bits of encoded data containing the error level value and the mask pattern number.

Mask

A pattern applied to the QR code to optimise on the distribution of the modules.

Modules

Modules are the smallest component of a QR code.

  • Modules are typically square and either black or white.
  • A black module represents the binary value 0.
  • A white module represents the binary value 1.

Numeric Encoding

Data made up entirely of the characters 0, 1, 2, 3, 4, 5, 6, 7, 8 or 9.

Positioning Patterns

Patterns that help to establish the orientation when scanning the QR code.

Quiet Zone

Blank space that is added around the QR code to enable correct scanning.

Reed-Solomon Error Codes

Additional codes that are added to the data to enable error detection and correction of multiple errors.

Timing Pattens

Alternating black and white modules determine the QR code version. The pattern contains (4n + 1) modules for a version n QR code.


Version 1 QR Codes

Detail relating to a Version 1 QR Code

  • The QR Code is made up of 21 by 21 black and white modules
  • The QR Code has a maximum capacity of 26 bytes of data.
  • The maximum number of ASCII characters that can be encoded is seventeen

This tool is designed for a version 1 QR Code and followiing modifications are implement when creating the QR Code.

  • If the size of the data is too large for a version 1 QR Code, it will be truncated to fit in
  • The available error levels is restricted by the number of bytes left after the data has been encoded

QR Code Encoding

Encoding describes the method by which the characters are converted into bits of data that can be store in the QR code

  • There are four standard encoding modes used by QR codes: numeric, alphanumeric, binary and kanji.
  • This tool demonstrates numeric, alphanumeric and binary encoding.
  • All characters can be encoded using binary encoding although this may not be the most efficient selection.
  • The selected encoding is stored as a 4-bit mode indicator at the beginning of the data.

Table of encoding types for a QR code

Encoding Description 4-bit Mode Indicator
Numeric Numeric characters: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 0001
Alphanumeric Uppercase letters, numeric characters, space or one of the characters $ % * + - , / 0010
Binary Any character. 0100
Kanji Kanji characters 1000


Numeric Encoding

Numeric encoding can be used if the data is made up entirely of the characters 0, 1, 2, 3, 4, 5, 6, 7, 8 or 9


Encoding the Data

To encode the numeric characters:

  • The digits are placed into groups of three from left to right to create values between 0 and 999.
  • The 3-digit values are coverted to 10-bit binary numbers.
  • If there is one remaining digit, it is multiplied by 16 and converted to an 8-bit binary number
  • If there are two remaining digits, 2-digit value is multiplied by 2. The result is converted to an 8-bit binary number

Example: 12345

Digit groups: 123 45

Calculation for 123

  • 123 = 0001111011 (10-bit binary value)

Calculation for 45

  • 45 × 2 = 90
  • 90 = 01011010 (8-bit binary value)

Example: 9876543

Digit groups: 987, 654 and 3

Calculation for 987

  • 987 = 1111011011 (10-bit binary value)

Calculation for 654

  • 654 = 1010001110 (10-bit binary value)

Calculation for 3

  • 3 × 16 = 48
  • 48 = 00110000 (8-bit binary value)

Alphanumeric Encoding

Alphanumeric encoding can be used if the data is made up entirely of the following:

  • Numeric digits
  • Upper case letters
  • Space
  • The characters $ % * + - , / .
Alphanumeric data values
ASCII value 0 1 2 3 4 5 6 7 8
Character 0 1 2 3 4 5 6 7 8

ASCII value 9 A B C D E F G H
Character 9 10 11 12 13 14 15 16 17

ASCII value I J K L M N O P Q
Character 18 19 20 21 22 23 24 25 26

ASCII value R S T U V W X Y Z
Character 27 28 29 30 31 32 33 34 35

ASCII value $ % * + - . / :
Character 36 37 38 39 40 41 42 43 44


Encoding the Data

To encode the alphanumeric characters:

  • Look up the value of each alphanumeric character.
  • The values are taken in pairs.
  • The first value of each pair is multiplied by 45 and added to the second value to form a value between 1 and 2024.
  • This value is then converted to an 11-bit binary number.
  • If there is one remaining character, its value is multiplied by 4 and converted to an 8-bit binary number.

Example: CAT

Character groups: CA T

Calculation for C and A

  • The values for C and A are 12 and 10
  • 45 × 12 + 10 = 550
  • 550 = 01000100110 (11-bit binary value)

Calculation for T

  • The value for T is 29
  • 4 × 29 = 29
  • 29 = 01110100 (8-bit binary value)


Binary Encoding

Binary encoding can be used for any character that has a unicode value and is stored using one of more bytes using UTF-8 encoding.

For values between 0 and 127, one byte of data is used and the character is encoded using it's ASCII value.

7-bit ASCII Values (32-127)
ASCII value 33 34 35 36 37 38 39 40 41 42 43 44
Character ! " # $ % & ' ( ) * + ,

ASCII value 45 46 47 48 49 50 51 52 53 54 55 56
Character - . / 0 1 2 3 4 5 6 7 8

ASCII value 57 58 59 60 61 62 63 64 65 66 67 68
Character 9 : ; < = > ? @ A B C D

ASCII value 69 70 71 72 73 74 75 76 77 78 79 80
Character E F G H I J K L M N O P

ASCII value 81 82 83 84 85 86 87 88 89 90 91 92
Character Q R S T U V W X Y Z [ \

ASCII value 93 94 95 96 97 98 99 100 101 102 103 104
Character ] ^ _ ` a b c d e f g h

ASCII value 105 106 107 108 109 110 111 112 113 114 115 116
Character i j k l m n o p q r s t

ASCII value 117 118 119 120 121 122 123 124 125 126 127 128
Character u v w x y z { | } ~ DEL €
ASCII value 33 34 35 36 37 38
Character ! " # $ % &

ASCII value 39 40 41 42 43 44
Character ' ( ) * + ,

ASCII value 45 46 47 48 49 50
Character - . / 0 1 2

ASCII value 51 52 53 54 55 56
Character 3 4 5 6 7 8

ASCII value 57 58 59 60 61 62
Character 9 : ; < = >

ASCII value 63 64 65 66 67 68
Character ? @ A B C D

ASCII value 69 70 71 72 73 74
Character E F G H I J

ASCII value 75 76 77 78 79 80
Character K L M N O P

ASCII value 81 82 83 84 85 86
Character Q R S T U V

ASCII value 87 88 89 90 91 92
Character W X Y Z [ \

ASCII value 93 94 95 96 97 98
Character ] ^ _ ` a b

ASCII value 99 100 101 102 103 104
Character c d e f g h

ASCII value 105 106 107 108 109 110
Character i j k l m n

ASCII value 111 112 113 114 115 116
Character o p q r s t

ASCII value 117 118 119 120 121 122
Character u v w x y z

ASCII value 123 124 125 126 127 128
Character { | } ~ DEL €


Multi-Byte Characters

For character with unicode values greater than 127, UTF-8 encoding is used and each character is encoded using two or more bytes of data.

The table below shows examples of such characters and the UTF-8 encoded byte values store in the QR code

Example Characters and their UTF Encoding
Character Unicode Value UTF-8 Encoding
½ 189  194 189
× 215  195 151
π 960  207 128
€ 8364  226 130 172
⇨ 8680  226 135 168
☺ 9786  226 152 186
⚅ 9861  226 154 133
🐼 128060  240 159 144 188
😀 128512  240 159 152 128
🦋 129419  240 159 166 139


Encoding a character as UTF-8

To encode a unicode character value as UTF-8:

  • Convert the unicode value to binary adjusting the preceding 0s so that the number starts with 01.
  • Split the binary values into groups of six bits from right to left.
  • Count the number of bits in the first group and add this to the number of groups/
  • If the total is greater than 8, add one to the group count and add an extra group of value 0/
  • Create an 8-bit binary value starting with a 1 for each group and ending in os. Add this to the first value.
  • Add 10000000 to the value of each remaining group/

The result is to create a multibyte character with the first byte representing the number of bytes, one for each 1 at the beginning, and the other bytes starting with 10 to indicate a continuation bytes.


Example: π

The unicode value for π is 960

  • 960 is represented by the binary sequence 011 1100 0000
  • Split into groups: 01111 000000
  • 2 groups plus 5 initial bits = 7, so no extra groups need to be added
  • 11000000 + 01111 = 11001111
  • The 8-bit binary value 11001111 = 207
  • 10000000 + 000000 = 10000000
  • The 8-bit binary value 10000000 = 128

The UTF-8 Encoding for π is 207 128


Example: 🐼

The unicode value for 🐼 is 128060

  • 128060 is represented by the binary sequence 01 1111 0100 0011 1100
  • Split into groups: 011111 010000 111100
  • 3 groups plus 7 initial bits = 10, so as extra groups needs to be added
  • 11110000 + 0 = 11110000
  • The 8-bit binary value 11110000 = 240
  • 10000000 + 011111 = 10011111
  • The 8-bit binary value 10011111 = 159
  • 10000000 + 010000 = 10010000
  • The 8-bit binary value 10010000 = 144
  • 10000000 + 111100 = 10111100
  • The 8-bit binary value 10111100 = 188

The UTF-8 Encoding for 🐼 is 240 159 144 188


Error Levels

QR codes may be corrupted through incorrect formatting, damage or issues with scanning. The error level determines the percentage of the data that can be corrupted and corrected in the QR Code data.

  • There are four error levels: High, Quartile, Medium and Low.
  • The error level value is stored in the first two digits of the information string.
  • A higher error level is able to correct more data errors but requires more data bytes to be used as error correction codes.
  • A lower level requires fewer data bytes to be used as error codes but and correct fewer errors.

Error Levels for a Version 1 QR Code

The table below gives information relating to the maximum number of characters that can be encoded for a particular error level and the maximum percentage of the data that can be corrected for a Version 1 QR code.

Error correction levels for a version 1 QR code
Error Level Maximum Characters Percentage Information Bits
Numeric Alphanumeric Binary
High 17107 30%
0 0
Quartile 271611 25%
0 1
Medium 342014 15%
1 0
Low 412517 7%
1 1
Error Level Maximum Characters
Numeric Alpha-numeric Binary
High 17107
Quartile 271611
Medium 342014
Low 412517


Padding Blocks

The number of bytes allocated to the encoded data depends on the error level. If the space used to store the indicator modes and the encoded characters is less that the that available, extra padding blocks are added to to fill up the data.

  • The first padding block is made up of four 0 bits and is always included to indicate the end of the data blocks..
  • Additional padding blocks standardly use the byte values 0xEC and 0x11, alternating, until less than eight bits of data are left.
  • Any final padding block with less that eight bits can take a value of 0

Example: "Version 1" encoded using binary mode

  • A version 1 QR code has capacity for 26 bytes.
  • The indicator data and extra 0 bits take up two bytes.
  • Binary encoded "Version 1" takes up nine bytes (One byte per character).
  • This leaves fifteen bytes for the error codes and the padding bytes
Number of error codes required and the padding for the above example.
Error Level Number of bytes Padding bytes
Error codes Padding Hexadecimal Binary
High 17 Unavailable option: Not enough bytes to encode the data
Quartile 13 2 0xEC 0x11 11101100 00010001
Medium 10 5 0xEC 0x11 0xEC 0x11 0xEC
Low 7 8 0xEC 0x11 0xEC 0x11 0xEC 0x11 0xEC 0x11
Error Level Padding bytes
High Unavailable option: Not enough bytes to encode the data
Quartile 0xEC 0x11
Medium 0xEC 0x11 0xEC 0x11 0xEC
Low 0xEC 0x11 0xEC 0x11 0xEC 0x11 0xEC 0x11


Error Codes

To allow for a level of error detection and correctiong, Reed-Solomon error correction codes are added to the data

  • The error level determines the number of error correction codes that can be created.
  • The current data is split into byte size values, and these are used to generate the error codes
  • If the data is corrupted, an algorithm is run on all of the bytes to determinine where the errors occured and how to correct it
  • The error level determines at what point there is too much corruption of the data for the damage to be repaired
The number of data bytes and error codes used for each error level in a Version 1 QR code
Error Level Data Bytes Error Codes Total bytes
High 9 17 26
Quartile 13 13 26
Medium 16 10 26
Low 19 7 26

Generating the Reed-Solomon Error Codes

Generating the Reed-Soloman error codes from the existing data requires the maths of Galois Fields and Polynomial Division.

  • The data is split into k bytes
  • If the capacity of the QR code is n bytes, then n-k bytes are used as error codes
  • The data bytes are used as the coefficients of a polynomial or order k
  • The polynomial is then multiplied by xn-k and divided by a given generator polynomial using Galois Field multiplication over eight elements.
  • The coefficients of the remainder are used as the error codes

The "Error Codes"/"Calculation" tab shows the full calculation for any data input when a QR code is generated.


Masking

A mask is applied to the data area of the QR Code to optimise the ability for a scanner to read it.

  • There are eight different mask patterns.
  • All eight masks produce valid QR codes that can be scanned in.
  • QR code generation tools select the one with the lowest penalty as that is considered visibly the best.
  • The best masks optimise the distribution of black and white modules.

Mask Patterns

The list of mask patterns show the conditional statement and the result of applying it to a 24 by 24 area of white modules

Mask Pattern 0

(row + col) % 2 == 0



Mask Pattern 1

row % 2 == 0



Mask Pattern 2

col % 3 == 0



Mask Pattern 3

(row + col) % 3 == 0



Mask Pattern 4

floor(row/2) + floor(col/3)) % 2 == 0



Mask Pattern 5

(row * col) % 2 + (row * col) % 3 == 0



Mask Pattern 6

((row * col) % 2 + (row * col) % 3) % 2 == 0



Mask Pattern 7

((row * col) % 3 + row + col) % 2 == 0





Applying a Mask Pattern to a QR Code

Mask patterns are applied to the data within a QR code using the conditional statement.

  • The row value of a module is the number of rows down from the top of the QR code, starting at 0.
  • The column value of a module is the number of columns across from the left of the QR code, starting at 0.
  • The row and column values are used to determine if the result of the condition is true or false.
  • If the result is true, then the module value changes from black to white or from white ro black
  • If the result is false, then the module value stays the same
Mappings from the original colour to the new colour depending on the result of the conditional statement
Original Module Color Result of Condition Statement New Module Color
whitefalsewhite
whitetrueblack
blackfalseblack
blacktruewhite

Understanding the Mask Pattern

Each mask pattern is defined using a conditional statement that uses the modulo (%) operator.

  • The modulo operation a % b finds the remainder when a is divided by b.
  • By using %2, the result is guarenteed to be always 1 or .0
  • For each mask a calculation is done using the row and/or column values of each module and then the modulo 2 operator is applied.
  • If the result is 0, then the output is 1.
  • If the result is 1, then the output is 0.
  • The XOR operation is then applied between the output from the condition and the module value to deternime the updated value of the module.

Using the XOR operator

When applying a mask to a qrcode, the black modules are represented by the value 1 and the white by the value 0.

  • If condition is true, then the value is 1.
  • If condition is false then the value is 0.
  • The XOR operation is then applied between the result of the condition and the value of the module.
Output from the XOR operation and the equivalent in terms of the module colour
A B A XOR B Module Equivalent
000 WfalseW
011WtrueB
101BfalseB
110BtrueW


Rating Masks

To determine which is the best mask to use for a QR code, each mask is applied and then rated using a penalty point system.

  • The mask with the lowest penalty points is chosen by default.
  • Any mask value can be chosen although it may not be visibly the best.

Penalty Points

Penalty points are determined using the following factors

Calculation 1: Horizontal and vertical runs of five or more modules of the same colour

Each run of five or more modules of the same colour has a penalty of 3 points plus 1 for each additional pixel


Calculation 2: Block of the same colour greater than two by two modules.

Each two by two block of the same colour has a penalty of 3 points.


Calculation 3: Hoizontal and vertical runs matching the value "10111010000".

Each run matching the following has a penalty of 40 points.

Calculation 4: The ratio of black to white modules

Penalty calculated from the percentage of black modules. Ten penality points for each multiple of 5% from 50%


Components of a QR Code

A QR code consists of a number of static elements that help determine the orientation and size of a QR code when it is being scanned.

The rest of the QR code is used to store the data relating to the information that is encoded within it.

  • This QR code structure is for a version 1 QR code.
  • The information in the QR code relates to Hello World with Binary encoding, Low error level and mask pattern 1.

18 18 17 17
18 18 17 17
18 18 17 17
18 18 17 17
19 19 16 16
19 19 16 16
19 19 16 16
19 19 16 16
26 26 25 25 24 24 23 23 20 20 15 15 10 10 9 9 4 4 3 3
26 26 25 25 24 24 23 23 20 20 15 15 10 10 9 9 4 4 3 3
26 26 25 25 24 24 23 23 20 20 15 15 10 10 9 9 4 4 3 3
26 26 25 25 24 24 23 23 20 20 15 15 10 10 9 9 4 4 3 3
21 21 14 14 11 11 8 8 5 5 2 2
21 21 14 14 11 11 8 8 5 5 2 2
21 21 14 14 11 11 8 8 5 5 2 2
21 21 14 14 11 11 8 8 5 5 2 2
22 22 13 13 12 12 7 7 6 6 1 1
22 22 13 13 12 12 7 7 6 6 1 1
22 22 13 13 12 12 7 7 6 6 1 1
22 22 13 13 12 12 7 7 6 6 1 1




Positioning Patterns

Three patterns to help establish the orientation when scanning the QR code.



Information

Encoded data containing the error level value and the mask pattern number.



Timing Patterns

The five modules indicate that this is a version 1 QR code.

15 15 10 10
15 15 10 10


Data Bytes

The encoded data and the error correction codes. The numbers show the order that the bytes of data are positioned in the QR code.




Space

Space added between the positioning patterns and the rest of the QR code.




Quiet Zone

Blank space that is added around the QR code to enable correct scanning.




Fixed Module

A module that is not used and has been defined to always be black.




Data Position in the QR Code

A version 1 QR code allows for 208 bits of data. This data is entered into the data area of the QR code

  • The first bit is placed in the bottom right of the QR code.
  • The last bit is placed on the far right just above the bottom left positioning pattern.
  • The data goes up and down in a two module width columns, as shown below.
  • If the data sequence reaches a point where it cannot continue, it jumps to the bottom right of the unused data space.

Table showing how data is positioned within the QR code


↘

←

←

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↙

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

←

←

↘

←

←

←

↘

←

↗

←

↘

←

←

←

↘

←

←

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

•

←

↗

←

←

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

↘

←

↗

←

•

←

↗

←

←

←

↗

←

←

←

↗

←



Start

=>

End


Data bits

The encoded data is then made up of:

  1. The mode indicator for the encoding (4 bits)
  2. The character count indicator block (The number of bits used depends on the encoding and the QR version)
  3. The encoded data blocks
  4. Padding data to complete any unused bytes.
  5. Error Codes

Format Information

The format information is a 15-bit sequence containing the error level and mask pattern.

  • The essential information is made up of five bits.
  • The first two bits represent the error level.
  • The next three bits represent the mask pattern.
Error level and mask pattern bits values
Error Levelbits
High
1 0
Quartile
1 1
Medium
0 0
Low
0 1
Maskbits
0
0 0 0
1
0 0 1
2
0 1 0
3
0 1 1
Maskbits
4
1 0 0
5
1 0 1
6
1 1 0
7
1 1 1

  • Ten further bits are used for error correction, resulting in a 15-bit sequence.
  • Up to three bit errors can be detected and corrected.
  • The information bits are encoded by performing a bitwise XOR operation with the binary value 101010000010010 (21522)
  • The encoded information bit modules are placed around the spacing modules in the top left corner of the QR Code
  • They are also duplicated and placed to the other spacing modules in the bottom left and top right corners
  • Duplication provides a further layer of error correction


Example: Low Error Level and Mask Pattern 0


Initial Data
0 1 0 0 0
Adding Error Bits
1 1 1 1 0 1 0 1 1 0
Unencoded Information Bits
0 1 0 0 0 1 1 1 1 0 1 0 1 1 0
Encoded Information Bits
1 1 1 0 1 1 1 1 1 0 0 0 1 0 0


Mapping for each Error Level and Mask Combination

Error Level: 0 (Medium), Mask Pattern: 0

Information Bits: 00000

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Encoded Information Bits

1 0 1 0 1 0 0 0 0 0 1 0 0 1 0

Error Level: 0 (Medium), Mask Pattern: 1

Information Bits: 00001

0 0 0 0 1 0 1 0 0 1 1 0 1 1 1

Encoded Information Bits

1 0 1 0 0 0 1 0 0 1 0 0 1 0 1

Error Level: 0 (Medium), Mask Pattern: 2

Information Bits: 00010

0 0 0 1 0 1 0 0 1 1 0 1 1 1 0

Encoded Information Bits

1 0 1 1 1 1 0 0 1 1 1 1 1 0 0

Error Level: 0 (Medium), Mask Pattern: 3

Information Bits: 00011

0 0 0 1 1 1 1 0 1 0 1 1 0 0 1

Encoded Information Bits

1 0 1 1 0 1 1 0 1 0 0 1 0 1 1

Error Level: 0 (Medium), Mask Pattern: 4

Information Bits: 00100

0 0 1 0 0 0 1 1 1 1 0 1 0 1 1

Encoded Information Bits

1 0 0 0 1 0 1 1 1 1 1 1 0 0 1

Error Level: 0 (Medium), Mask Pattern: 5

Information Bits: 00101

0 0 1 0 1 0 0 1 1 0 1 1 1 0 0

Encoded Information Bits

1 0 0 0 0 0 0 1 1 0 0 1 1 1 0

Error Level: 0 (Medium), Mask Pattern: 6

Information Bits: 00110

0 0 1 1 0 1 1 1 0 0 0 0 1 0 1

Encoded Information Bits

1 0 0 1 1 1 1 1 0 0 1 0 1 1 1

Error Level: 0 (Medium), Mask Pattern: 7

Information Bits: 00111

0 0 1 1 1 1 0 1 0 1 1 0 0 1 0

Encoded Information Bits

1 0 0 1 0 1 0 1 0 1 0 0 0 0 0

Error Level: 1 (Low), Mask Pattern: 0

Information Bits: 01000

0 1 0 0 0 1 1 1 1 0 1 0 1 1 0

Encoded Information Bits

1 1 1 0 1 1 1 1 1 0 0 0 1 0 0

Error Level: 1 (Low), Mask Pattern: 1

Information Bits: 01001

0 1 0 0 1 1 0 1 1 1 0 0 0 0 1

Encoded Information Bits

1 1 1 0 0 1 0 1 1 1 1 0 0 1 1

Error Level: 1 (Low), Mask Pattern: 2

Information Bits: 01010

0 1 0 1 0 0 1 1 0 1 1 1 0 0 0

Encoded Information Bits

1 1 1 1 1 0 1 1 0 1 0 1 0 1 0

Error Level: 1 (Low), Mask Pattern: 3

Information Bits: 01011

0 1 0 1 1 0 0 1 0 0 0 1 1 1 1

Encoded Information Bits

1 1 1 1 0 0 0 1 0 0 1 1 1 0 1

Error Level: 1 (Low), Mask Pattern: 4

Information Bits: 01100

0 1 1 0 0 1 0 0 0 1 1 1 1 0 1

Encoded Information Bits

1 1 0 0 1 1 0 0 0 1 0 1 1 1 1

Error Level: 1 (Low), Mask Pattern: 5

Information Bits: 01101

0 1 1 0 1 1 1 0 0 0 0 1 0 1 0

Encoded Information Bits

1 1 0 0 0 1 1 0 0 0 1 1 0 0 0

Error Level: 1 (Low), Mask Pattern: 6

Information Bits: 01110

0 1 1 1 0 0 0 0 1 0 1 0 0 1 1

Encoded Information Bits

1 1 0 1 1 0 0 0 1 0 0 0 0 0 1

Error Level: 1 (Low), Mask Pattern: 7

Information Bits: 01111

0 1 1 1 1 0 1 0 1 1 0 0 1 0 0

Encoded Information Bits

1 1 0 1 0 0 1 0 1 1 1 0 1 1 0

Error Level: 2 (High), Mask Pattern: 0

Information Bits: 10000

1 0 0 0 0 1 0 1 0 0 1 1 0 1 1

Encoded Information Bits

0 0 1 0 1 1 0 1 0 0 0 1 0 0 1

Error Level: 2 (High), Mask Pattern: 1

Information Bits: 10001

1 0 0 0 1 1 1 1 0 1 0 1 1 0 0

Encoded Information Bits

0 0 1 0 0 1 1 1 0 1 1 1 1 1 0

Error Level: 2 (High), Mask Pattern: 2

Information Bits: 10010

1 0 0 1 0 0 0 1 1 1 1 0 1 0 1

Encoded Information Bits

0 0 1 1 1 0 0 1 1 1 0 0 1 1 1

Error Level: 2 (High), Mask Pattern: 3

Information Bits: 10011

1 0 0 1 1 0 1 1 1 0 0 0 0 1 0

Encoded Information Bits

0 0 1 1 0 0 1 1 1 0 1 0 0 0 0

Error Level: 2 (High), Mask Pattern: 4

Information Bits: 10100

1 0 1 0 0 1 1 0 1 1 1 0 0 0 0

Encoded Information Bits

0 0 0 0 1 1 1 0 1 1 0 0 0 1 0

Error Level: 2 (High), Mask Pattern: 5

Information Bits: 10101

1 0 1 0 1 1 0 0 1 0 0 0 1 1 1

Encoded Information Bits

0 0 0 0 0 1 0 0 1 0 1 0 1 0 1

Error Level: 2 (High), Mask Pattern: 6

Information Bits: 10110

1 0 1 1 0 0 1 0 0 0 1 1 1 1 0

Encoded Information Bits

0 0 0 1 1 0 1 0 0 0 0 1 1 0 0

Error Level: 2 (High), Mask Pattern: 7

Information Bits: 10111

1 0 1 1 1 0 0 0 0 1 0 1 0 0 1

Encoded Information Bits

0 0 0 1 0 0 0 0 0 1 1 1 0 1 1

Error Level: 3 (Quartile), Mask Pattern: 0

Information Bits: 11000

1 1 0 0 0 0 1 0 1 0 0 1 1 0 1

Encoded Information Bits

0 1 1 0 1 0 1 0 1 0 1 1 1 1 1

Error Level: 3 (Quartile), Mask Pattern: 1

Information Bits: 11001

1 1 0 0 1 0 0 0 1 1 1 1 0 1 0

Encoded Information Bits

0 1 1 0 0 0 0 0 1 1 0 1 0 0 0

Error Level: 3 (Quartile), Mask Pattern: 2

Information Bits: 11010

1 1 0 1 0 1 1 0 0 1 0 0 0 1 1

Encoded Information Bits

0 1 1 1 1 1 1 0 0 1 1 0 0 0 1

Error Level: 3 (Quartile), Mask Pattern: 3

Information Bits: 11011

1 1 0 1 1 1 0 0 0 0 1 0 1 0 0

Encoded Information Bits

0 1 1 1 0 1 0 0 0 0 0 0 1 1 0

Error Level: 3 (Quartile), Mask Pattern: 4

Information Bits: 11100

1 1 1 0 0 0 0 1 0 1 1 0 1 1 0

Encoded Information Bits

0 1 0 0 1 0 0 1 0 1 0 0 1 0 0

Error Level: 3 (Quartile), Mask Pattern: 5

Information Bits: 11101

1 1 1 0 1 0 0 1 0 1 1 0 1 1 0

Encoded Information Bits

0 1 0 0 0 0 0 1 0 1 0 0 1 0 0

Error Level: 3 (Quartile), Mask Pattern: 6

Information Bits: 11110

1 1 1 1 0 1 0 1 1 0 1 1 0 0 0

Encoded Information Bits

0 1 0 1 1 1 0 1 1 0 0 1 0 1 0

Error Level: 3 (Quartile), Mask Pattern: 7

Information Bits: 11111

1 1 1 1 1 1 1 0 0 1 1 1 1 1 1

Encoded Information Bits

0 1 0 1 0 1 1 0 0 1 0 1 1 0 1

Contents Copyright 2025 Andy Abraham
Please email comments to info@mathsandcomputing.co.uk