A mask
By designing specific masking rules and XOR operations, the problems of insufficient QR code masking patterns and inadequate security were solved, thereby improving the security of QR codes and the success rate of scanning.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHANGJIAJIE NEWWAVE COMPUTER CO LTD
- Filing Date
- 2024-12-20
- Publication Date
- 2026-06-23
AI Technical Summary
The existing QR code masking modes are too few and lack sufficient security, making scanning difficult and easy to forge.
A mask is designed using XOR operation and specific masking rules. By drawing a coordinate system, calculating the loss score, and selecting the mask with the lowest loss score, only data symbols and error correction symbols are processed. The masking operation is performed using the formula ROW MOD2 + COLUMN MOD2 == 0, and a special QR code is designed.
It improves the security and scanning success rate of QR codes, prevents the appearance of large black and white blocks, and enhances the anti-counterfeiting capabilities of QR codes.
Smart Images

Figure CN122263935A_ABST
Abstract
Description
Technical Field
[0001] This technology pertains to QR codes, particularly involving masking techniques. Background Technology
[0002] A mask is a strategy that changes the value of code elements within a QR code area according to specific rules. The original data may contain a large number of 1s or 0s. After these 1s or 0s are directly converted into black or white blocks, large areas of black or white may appear, making QR codes difficult to scan. To prevent large areas of black or white blocks, an XOR algorithm and a mask pattern are used to make the black and white blocks in the QR code evenly distributed, so as not to produce large areas of black or white. This preset pattern is the mask.
[0003] The masking process is applied to data symbols and error correction symbols, but not to symbols in functional modules and reserved areas.
[0004] After searching the State Intellectual Property Office's patent publication website using the keywords "QR code and mask", the applicant obtained 24 search results. No similar patents were found in the 24 search results. According to the State Intellectual Property Office website, these patents mainly focus on color QR codes and anti-counterfeiting QR code technologies.
[0005] In the Fast Response Matrix Code, eight masks are preset to make the black and white modules of the final QR code bit blocks more evenly distributed. However, such a general mask is often less secure. To improve security, a specific type of mask is needed. Summary of the Invention 1. Technical problems that need to be solved: The problem of insufficient masking modes needs to be addressed; The security issues of the general mode need to be addressed. Technical solution
[0006] The mask is written according to the following steps: Step 1: Draw a coordinate system. In the coordinate system, the origin of the X-axis and Y-axis is located at the top left corner. The coordinate system has no negative numbers. The coordinate system increments by 1 step downwards and to the right. Step 2: Draw the reference QR code graphic. The drawing references the V2.0 version of the QR code, and the graphic is compiled in accordance with the relevant standard "GB / T 18284-2000-Fast Response Matrix Code". Step 3: Draw the mask file. The mask file uses even-numbered rows and even-numbered columns as black blocks and the rest as white blocks to draw the original mask file. Step 4: Place the mask file into the QR code and delete the black blocks in the location detection graphic, location detection graphic separator, positioning graphic, correction graphic, and function graphic area; Step 5: Calculate using the formula ROW MOD2 + COLUMN MOD2 == 0, and the test is complete; Step 6: Add a QR code to the original data and perform a masking operation; Step 7: Calculate the loss score according to the loss score scoring rules; The mask only processes the data code elements and error correction code elements, but the scoring process evaluates the entire QR code area, including functional modules and reserved areas. The four scoring rules are defined as follows: Rule 1: Check each row. If there are 5 consecutive symbols of the same color, add 3 to the loss score. If there are more symbols of the same color after 5 consecutive symbols, add 1 to the loss score for each additional symbol. Similarly, check each column and finally add the loss scores in the horizontal and vertical directions. Rule 2: If a 2x2 area of the same color is found, a loss score will be incurred. This also applies to overlapping areas. For each area found, the cumulative loss score is 3 points.
[0007] Rule 3: When a pattern similar to the positioning module appears, the loss score increases by 40 points for each one detected.
[0008] Rule 4: If more than half of the entire QR code is black or white, the loss score is increased; the greater the difference, the higher the score. Step 8: Add up the loss scores obtained from the four rules to get the total loss score; Step 9: Score the loss score for all masks according to the four rules, and add them together to obtain the total loss score; Step 10: The mask determined by the QR code has the lowest total loss score; Step 11: Mark the code of the determined mask at the mask position in the QR code; Step 12: During decoding, the source data is obtained by decoding according to the mask code and the function rules of the mask code.
[0009] Beneficial effects:
[0010] The mask is generated by XOR operation, which performs masking operations on the mask pattern according to the row and column values. By enriching the mask operation rules, the security problems caused by general mask operation rules can be effectively prevented. Attached Figure Description
[0011] Appendix Figure 1 This is a schematic diagram of the QR code structure; Appendix Figure 2 It is the original mask file; Appendix Figure 3 It is a mask file. Detailed Implementation
[0012] The applicant will describe the implementation method of this application with reference to the accompanying drawings: The mask is written according to the following steps: Step 1: Draw a coordinate system. In the coordinate system, the origin of the X-axis and Y-axis is located at the top left corner. The coordinate system has no negative numbers. The coordinate system increments by 1 step downwards and to the right. Step 2: Draw the reference QR code graphic. The drawing references the V2.0 version of the QR code, and the graphic is compiled in accordance with the relevant standard "GB / T 18284-2000-Fast Response Matrix Code". Step 3: Draw the mask file. The mask file uses even-numbered rows and even-numbered columns as black blocks and the rest as white blocks to draw the original mask file. Step 4: Place the mask file into the QR code and delete the black blocks in the location detection graphic, location detection graphic separator, positioning graphic, correction graphic, and function graphic area; Step 5: Calculate using the formula ROW MOD2 + COLUMN MOD2 == 0, and the test is complete; Step 6: Add a QR code to the original data and perform a masking operation; Step 7: Calculate the loss score according to the loss score scoring rules; The mask only processes the data code elements and error correction code elements, but the scoring process evaluates the entire QR code area, including functional modules and reserved areas. The four scoring rules are defined as follows: Rule 1: Check each row. If there are 5 consecutive symbols of the same color, add 3 to the loss score. If there are more symbols of the same color after 5 consecutive symbols, add 1 to the loss score for each additional symbol. Similarly, check each column and finally add the loss scores in the horizontal and vertical directions. Rule 2: If a 2x2 area of the same color is found, a loss score will be incurred. This also applies to overlapping areas. For each area found, the cumulative loss score is 3 points.
[0013] Rule 3: When a pattern similar to the positioning module appears, the loss score increases by 40 points for each one detected.
[0014] Rule 4: If more than half of the entire QR code is black or white, the loss score is increased; the greater the difference, the higher the score. Step 8: Add up the loss scores obtained from the four rules to get the total loss score; Step 9: Score the loss score for all masks according to the four rules, and add them together to obtain the total loss score; Step 10: The mask determined by the QR code has the lowest total loss score; Step 11: Mark the code of the determined mask at the mask position in the QR code; Step 12: During decoding, the source data is obtained by following the function rules of the mask code. The decoding function is ROW MOD2+COLUMN MOD2==0.
[0015] It should be noted that the mask code is 3 bits, meaning a maximum of 8 masks are allowed. However, new masks can be designed by changing the masking rules. Since loss scores are calculated using 8 masks during mask verification, if any one of the masks fails to score, the entire process will fail. This method can be used to design a dedicated QR code to prevent general QR codes from being scanned successfully. Of course, there are other rules for designing dedicated codes. Compared to other dedicated code design rules, designing a dedicated code by changing the masking rules undoubtedly involves the least code modification, requiring only changes to the functions.
Claims
1. The mask writing and decoding process follows these steps: Step 1: Draw a coordinate system. In the coordinate system, the origin of the X-axis and Y-axis is located at the top left corner. The coordinate system has no negative numbers. The coordinate system increments by 1 step downwards and to the right. Step 2: Draw the reference QR code graphic. The drawing references the V2.0 version of the QR code, and the graphic is compiled in accordance with the relevant standard "GB / T 18284-2000-Fast Response Matrix Code". Step 3: Draw the mask file. The mask file uses even-numbered rows and even-numbered columns as black blocks and the rest as white blocks to draw the original mask file. Step 4: Place the mask file into the QR code and delete the black blocks in the location detection graphic, location detection graphic separator, positioning graphic, correction graphic, and function graphic area; Step 5: Calculate using the formula ROW MOD2 + COLUMN MOD2 == 0, and the test is complete; Step 6: Add a QR code to the original data and perform a masking operation; Step 7: Calculate the loss score according to the loss score scoring rules; The mask only processes the data code elements and error correction code elements, but the scoring process evaluates the entire QR code area, including functional modules and reserved areas. The four scoring rules are defined as follows: Rule 1: Check each row. If there are 5 consecutive symbols of the same color, add 3 to the loss score. If there are more symbols of the same color after 5 consecutive symbols, add 1 to the loss score for each additional symbol. Similarly, check each column and finally add the loss scores in the horizontal and vertical directions. Rule 2: If a 2x2 area of the same color is found, a loss score will be incurred. This also applies to overlapping areas. For each area found, the cumulative loss score is 3 points. Rule 3: When a pattern similar to the positioning module appears, the loss score increases by 40 points for each one detected. Rule 4: If more than half of the entire QR code is black or white, the loss score is increased; the greater the difference, the higher the score. Step 8: Add up the loss scores obtained from the four rules to get the total loss score; Step 9: Score the loss score for all masks according to the four rules, and add them together to obtain the total loss score; Step 10: The mask determined by the QR code has the lowest total loss score; Step 11: Mark the code of the determined mask at the mask position in the QR code; Step 12: During decoding, the source data is obtained by following the function rules of the mask code. The decoding function is ROW MOD2+COLUMN MOD2==0.