Complementation-based two-dimensional code encryption and verification method and server

By dividing the QR code into two parts and storing key information on the server side, only certified code scanning software is allowed to parse, which solves the problem of insufficient security of existing QR code technology and achieves encryption and protection of sensitive information. Permission control improves the security protection level of QR codes.

CN118798241AInactive Publication Date: 2024-10-18ZHUHAI HENGQIN CHINA-AUSTRALIA ELECTRONIC PAYMENT TECH CO LTD +1
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410830351.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-25
Publication Date
2024-10-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing QR code technology has shortcomings in security. Sensitive information is completely disclosed once generated and can be easily scanned and interpreted by anyone. It lacks effective protection and authority control, resulting in a low level of security protection.

Method used

By dividing the QR code into two parts, storing key information on the server side, and allowing only certified dedicated scanning software to be parsed after verification with the server side, segmented management and encryption protection of the QR code information are achieved, improving Security.

Benefits of technology

It effectively prevents QR code information from being illegally obtained, ensures the accuracy and integrity of the information, and enhances the security protection level of the QR code to ensure that only authorized users can access sensitive information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118798241A_ABST
    Figure CN118798241A_ABST
Patent Text Reader

Abstract

The invention discloses a complementation-based two-dimensional code encryption and verification method and a server, and relates to the field of two-dimensional code encryption and verification, in the method, the server receives a first graphic unit scanned by a user through a client, and performs structure matching on the first graphic unit and a plurality of second graphic units pre-stored in the server; and if it is detected that a target second graphic unit corresponding to the first graphic unit exists in the server, the first graphic unit and the second graphic unit are combined to generate a complete target two-dimensional code, and then a decoding result of the target two-dimensional code is sent to the client. According to the method, the two-dimensional code is divided into two parts, key information is stored in the server side, segmented management and safety verification of the two-dimensional code information are achieved, the actual content of the two-dimensional code can be successfully analyzed only when authenticated special code scanning software is matched with verification of the server side, and the safety protection level of the two-dimensional code is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of two-dimensional code encryption and verification, and in particular to a two-dimensional code encryption and verification method and server based on complementarity. Background Art

[0002] In the digital age, QR codes have become an important information transmission tool and are widely used in payment, advertising, identity authentication and other fields. Due to its easy generation and scanning characteristics, QR code technology has greatly simplified the information sharing process. However, with the popularization of technology, information security and privacy protection have become an issue that cannot be ignored. Especially in scenarios involving sensitive or private information, the security and confidentiality of traditional QR code technology face severe tests.

[0003] The current QR code technology mainly generates a two-dimensional graphic code containing all the information. Generally, any user with a scanning device can access and interpret the corresponding data information by scanning the QR code. This technology is widely used because it has a very low threshold for use and strong compatibility. Users only need to use ordinary scanning software to quickly obtain the data in the QR code, which shows extremely high efficiency in many fast transactions and information transmission scenarios.

[0004] However, although the existing QR code technology is excellent in convenience and efficiency, it has obvious deficiencies in security. Once the information in the QR code is generated, it is completely public, and anyone can easily scan and interpret the information without authorization. The lack of effective protection for sensitive information and the corresponding permission control mechanism makes the security protection level of the QR code low. Summary of the invention

[0005] The present application provides a complementary QR code encryption and verification method and server, which realizes segmented management and security verification of QR code information by dividing the QR code into two parts and storing key information on the server side. Only certified dedicated code scanning software can successfully parse the actual content of the QR code in cooperation with server-side verification, thereby realizing encryption protection of sensitive information in the QR code and access control of encrypted information, thereby improving the security protection level of the QR code.

[0006] In a first aspect, the present application provides a complementary two-dimensional code encryption and verification method, which is applied to a server, and the method includes: When it is detected that a user scans a first graphic unit through a client, the first graphic unit sent by the client is received, where the first graphic unit is obtained by splitting an original two-dimensional code, and the original two-dimensional code is generated according to the information data to be encrypted; Performing structural matching on the first graphic unit with a plurality of second graphic units pre-stored in a database of a server, the second graphic unit being obtained by splitting the original two-dimensional code, the structural matching being to determine whether there is a target second graphic unit corresponding to the first graphic unit in the database, the target second graphic unit and the first graphic unit being able to complement each other to obtain a complete original two-dimensional code, the target second unit being one of the plurality of second graphic units; If it is detected that there is a target second graphic unit corresponding to the first graphic unit in the database, the first graphic unit and the target second graphic unit are complementary spliced ​​to generate a complete target two-dimensional code, and one or more original two-dimensional codes are stored in the database, and the target two-dimensional code belongs to one of the one or more original two-dimensional codes; The decoding result of the target two-dimensional code is sent to the client, and the decoding result is the information data to be encrypted corresponding to the target two-dimensional code.

[0007] Through the above embodiment, the server splits the original QR code into two complementary graphic units, and realizes the segmented management of the QR code information by storing one of the graphic units in the database and distributing the other through public channels. This method can effectively prevent the QR code information from being illegally obtained and interpreted, greatly improving the security of the QR code. Even if someone obtains a publicly distributed graphic unit, the complete QR code information cannot be restored due to the lack of the other half of the graphic unit paired with it. At the same time, the server not only ensures the accuracy and integrity of the QR code information through structural matching and merging, but also realizes the encryption protection of sensitive information in the QR code and the access control of the encrypted information, thereby improving the security protection level of the QR code.

[0008] In some embodiments, when it is detected that the user scans the first graphic unit through the client, before the step of receiving the first graphic unit sent by the client, it also includes: Splitting the plurality of original two-dimensional codes according to a preset splitting rule to obtain a plurality of first graphic units and corresponding second graphic units, wherein the preset splitting rule is to use the pixels of odd rows and odd columns in the matrix corresponding to the original two-dimensional code as the content of the first graphic unit, and to use the pixels of even rows and even columns in the matrix corresponding to the original two-dimensional code as the content of the second graphic unit; Distributing the first graphic unit through a public channel; The second graphic unit is stored in a database, and access rights for the second graphic unit are set.

[0009] Through the above embodiment, the server splits the original two-dimensional code matrix according to odd and even rows and columns to form two graphic units with complementary structures. This regular splitting method is not only convenient for fast matching and reorganization, but also difficult to infer the complete two-dimensional code structure even if a single graphic unit is leaked, further enhancing security. At the same time, access control is introduced to prevent illegal users from obtaining key information by directly accessing the server database, thereby improving the security of the two-dimensional code data.

[0010] In some embodiments, when it is detected that the user scans the first graphic unit through the client, the step of receiving the first graphic unit sent by the client specifically includes: When it is detected that the user scans the first graphic unit through the client, determining whether the scanning software of the client is authorized; If not, refusing to receive the first graphic unit sent by the client, and sending a prompt message indicating that authorization cannot be obtained to the client; If yes, then receive the first graphic unit sent by the client.

[0011] Through the above embodiment, the server will only perform pairing verification in the database after receiving the first graphic unit sent by the authorized dedicated code scanning software. Even if the unauthorized code scanning software obtains the public graphic unit, it cannot communicate with the server, let alone decode the complete QR code content. This further limits the illegal access to the QR code information and improves the information security level of the QR code.

[0012] In some embodiments, the step of structurally matching the first graphic unit with a plurality of second graphic units pre-stored in a database of the server specifically includes: The first graphic unit is sequentially spliced ​​with a plurality of second graphic units pre-stored in the server according to a preset rule to obtain a combined two-dimensional code, wherein the preset rule is to use the pixels of the first graphic unit as odd rows and odd columns of the combined two-dimensional code, and the pixels of the second graphic unit as even rows and even columns of the combined two-dimensional code; Determine whether the combined two-dimensional code conforms to a data matrix structure of a preset two-dimensional code standard; If so, the current second graphic unit corresponds to the first graphic unit; If not, the current second graphic unit does not correspond to the first graphic unit.

[0013] Through the above embodiment, the server restores the standard two-dimensional code data matrix by staggering the pixel points of the two graphic units. This reconstruction method is based on the inherent rules of the preset two-dimensional code matrix, and can quickly identify the correctly matched graphic unit combination, thereby improving the verification efficiency. At the same time, the combination of non-standard structures of the two-dimensional code will not pass the verification, which is convenient for timely detection of illegal forgery or tampering.

[0014] In some embodiments, after the step of structurally matching the first graphic unit with a plurality of second graphic units pre-stored in a database of the server, the method further includes: If it is detected that the target second graphic unit corresponding to the first graphic unit does not exist in the database, a prompt message indicating that the scan has failed or is invalid is sent to the user's client.

[0015] Through the above embodiment, the server can send corresponding prompt information to the user when the QR code scanning fails. This feedback mechanism avoids the user from being in an unknown waiting state for a long time, and optimizes the user's experience. At the same time, the failure prompt can also prompt the user to re-acquire a valid QR code graphic, rather than repeatedly trying invalid scans, which improves the efficiency in practical applications.

[0016] In some embodiments, before the step of sending the decoding result of the target two-dimensional code to the client, the method further includes: Get the decoding result of the target QR code; Verify the integrity and legality of the information content corresponding to the decoding result; If it is detected that the decoding result passes the integrity and legality verification, the permission to send the decoding result to the client is enabled.

[0017] Through the above embodiment, the server verifies the integrity and legality of the decoding result of the QR code, and only the content that passes the verification will be authorized to be sent to the client. This avoids the server from sending incomplete or tampered data information to the client, and further improves the reliability and security of data transmission between the server and the client.

[0018] In some embodiments, the step of sending the decoding result of the target two-dimensional code to the client specifically includes: Encrypting the decoding result according to a preset encryption algorithm; The encrypted decoding result is sent to the client through the server; The client and the decoding result are recorded on file.

[0019] Through the above embodiment, the server encrypts the decoding result of the QR code through an end-to-end encrypted transmission method and then sends it to the client, and requires filing records. This transmission method can prevent sensitive information from being stolen during network transmission, and filing records also facilitate subsequent audits and problem location, thereby expanding the practical value of the server in the field of secure communications.

[0020] In a second aspect, the present application provides a server, the server comprising: one or more processors and a memory; The memory is coupled to the one or more processors, and the memory is used to store computer program code, which includes computer instructions. The one or more processors call the computer instructions so that the server can implement a complementary two-dimensional code encryption and verification method provided in the above embodiment, which will not be repeated here.

[0021] In a third aspect, the present application provides a computer-readable storage medium, including instructions. When the instructions are executed on a server, the server can implement a complementary QR code encryption and verification method provided in the above embodiment, which will not be repeated here.

[0022] In a fourth aspect, the present application provides a computer program product. When the computer program product runs on a server, the server can implement a complementary QR code encryption and verification method provided in the above embodiment, which will not be repeated here.

[0023] One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: 1. The server can generate the original QR code according to the information to be encrypted, and split it into two complementary graphic units according to the preset odd-even row and column rules. One of the graphic units is distributed through public channels, and the other is stored in the server database with access control. This segmented storage method can effectively prevent the QR code information from being illegally obtained and maliciously tampered with, greatly improving the security of the QR code encrypted information.

[0024] 2. The server only receives the public graphic units scanned by the authorized client software. After verification, the graphic unit is structurally matched and merged with the other half of the graphic units stored on the server to restore the complete QR code. The reconstruction algorithm based on the inherent rules of the QR code quickly identifies the correctly matched graphic unit combination by comparing the reorganized matrix structure, ensuring the accuracy and integrity of the QR code information and better protecting the sensitive information in the QR code.

[0025] 3. The server decodes and verifies the reorganized QR code, then sends the encrypted decoding result to the client and records it. This end-to-end encrypted transmission method can further prevent sensitive information from being stolen during network transmission. In addition, the server also introduces a scanning failure feedback mechanism to improve the user experience. The record function also facilitates subsequent audits and problem location. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 It is a flowchart of a complementary two-dimensional code encryption and verification method in an embodiment of the present application; Figure 2 It is another flowchart of a complementary two-dimensional code encryption and verification method in an embodiment of the present application; Figure 3 This is a schematic diagram of an exemplary scenario in which the server decompresses the original QR code in an embodiment of the present application; Figure 4 It is a schematic diagram of a physical device structure of a server in an embodiment of the present application. DETAILED DESCRIPTION

[0027] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification and appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear indication to the contrary in the context. It should also be understood that the term "and / or" used in the present application refers to any or all possible combinations comprising one or more listed items.

[0028] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.

[0029] The following is a description of the process of the method provided by this implementation. Figure 1 , which is a flow chart of a complementary two-dimensional code encryption and verification method in an embodiment of the present application.

[0030] S101. When it is detected that a user scans a first graphic unit through a client, a first graphic unit sent by the client is received.

[0031] Specifically, the user can scan the first graphic unit through the scanning software in his client device (such as a mobile phone, tablet, etc.). The first graphic unit is actually a part of the original two-dimensional code after being split according to specific rules. Although it is incomplete, it contains part of the original information, and the part of the original information is the information that can be made public set by the user. When the user scans the first graphic unit through the scanning software, the part of the original information corresponding to the first graphic unit can be read, and the scanning software will automatically send the first graphic unit to the server for verification.

[0032] For example, a restaurant may split the QR code of a meal ticket into two graphic units. One of the graphic units (i.e., the first graphic unit) will be printed on the meal ticket and distributed to users, while the other will be kept in the restaurant's server. When users visit the store to consume, they only need to scan the first graphic unit on the meal ticket with the official app or mini program provided by the restaurant. The app or mini program will transmit the scanned first graphic unit to the store's verification system (equivalent to the server), and then enter the next step of the verification process.

[0033] It should be noted that the above-mentioned first graphic unit is obtained by splitting the original two-dimensional code, and the original two-dimensional code is generated according to the information data to be encrypted. Specifically, the server first generates the original two-dimensional code based on the information data to be encrypted, and the user can scan the original two-dimensional code through any scanning software to read the data information to be encrypted. In order to prevent the leakage of the information to be encrypted, the server splits the original two-dimensional code into two complementary and independent parts (i.e., the first graphic unit and the second graphic unit) according to the preset splitting rules, and the first graphic unit can be publicly distributed, such as the graphic unit printed on the meal coupon in the above embodiment, and the second graphic unit is stored in the database of the server and is not open to the public. Only authorized specific scanning software can read the second graphic unit in the database for information matching by sending the first graphic unit to the server.

[0034] In the above embodiment, the server increases the difficulty of copying the QR code by dividing the QR code into two according to a preset rule, because a single graphic unit cannot be directly decoded. At the same time, the first graphic unit is scanned and transmitted by a designated app or applet instead of being uploaded by the user using any scanning tool, which can also prevent the first graphic unit from being spread at will. The server only accepts graphic units uploaded from official channels, laying the foundation for subsequent verification and merging.

[0035] S102: Perform structural matching between the first graphic unit and a plurality of second graphic units pre-stored in a database of the server.

[0036] Since the first graphic unit is only half of the original QR code, the other half (i.e., the second graphic unit) that matches it needs to be found in the server's database to restore the complete QR code. Therefore, after receiving the first graphic unit uploaded by the user, the server will perform structural matching on the first graphic unit with multiple second graphic units pre-stored in the database, and then filter out the target second graphic unit that can match the structure of the first graphic unit.

[0037] Specifically, the server compares the first graphic unit with a series of second graphic units stored in the server database one by one, and detects whether the two graphic units to be compared match in spatial structure and whether they can be spliced ​​into a complete target two-dimensional code that conforms to the standard data matrix structure of the two-dimensional code according to preset arrangement rules, so as to find the target second graphic unit that can be spliced ​​with the current first graphic unit to form a legal two-dimensional code.

[0038] Continuing with the example of restaurant meal coupons, the restaurant will generate a batch of complete QR codes in advance and split them into two graphic units according to the agreed rules (such as the parity of the pixels) and store them separately. The first graphic unit uploaded by the user will be compared with the multiple second graphic units stored in the database in sequence. If it is found that the current second graphic unit can perfectly match the first graphic unit in space to form a standard QR code matrix structure, it is confirmed that the current second graphic unit corresponds to the first graphic unit.

[0039] The server can balance efficiency with encryption by using the spatial structure matching method. In the specific implementation, a special graphic algorithm and data structure can be used to quickly find the matching graphic unit. At the same time, this matching method has good fault tolerance. Even if the graphic code is slightly deformed, it will not affect the recognition, which improves the robustness of the server's first graphic unit matching.

[0040] S103: If it is detected that there is a target second graphic unit corresponding to the first graphic unit in the database, the first graphic unit and the target second graphic unit are combined to generate a complete target two-dimensional code.

[0041] When the second graphic unit corresponding to the first graphic unit (ie, the target second graphic unit) is successfully found in the database, the two graphic units are merged to restore the original complete two-dimensional code.

[0042] Specifically, the server interlaces the graphic blocks of the first and second graphic units according to the rules used when splitting the QR code, restores the original geometric shape and pixel arrangement of the QR code, and makes it a QR code matrix that meets the standard specifications. This process can be regarded as the reverse operation of the original QR code splitting. After the server confirms that the two graphic units are completely consistent in spatial structure, it can directly apply the preset mapping relationship, return the scattered pixels to their original positions, and reshape the complete QR code.

[0043] Continuing with the example of the restaurant meal coupon, when the server matches the second graphic unit corresponding to the meal coupon, it immediately merges the graphics. If the server splits the QR code according to the odd and even rows and columns of the pixels, then during reconstruction, the pixels of the first and second graphic units are filled in sequentially in row and column order, with the odd rows and columns coming from the first graphic unit and the even rows and columns coming from the second graphic unit. Through this staggered filling, a standard square QR code matrix is ​​obtained.

[0044] S104: Send the decoding result of the target QR code to the client.

[0045] After the server generates a complete target QR code based on the first graphic unit and the target second graphic unit, the server decodes the target QR code, extracts the data to be encrypted corresponding to the target QR code, and obtains the decoding result. Then, the decoding result is transmitted back to the client to complete the entire interaction process. Specifically, the server uses a special QR code decoding engine to read the information carried by the target QR code, and converts it into a user-readable format (such as text, URL, command, etc.), and pushes it to the client through the network interface. After receiving the response from the server, the client presents the decoding result to the user in the form of a pop-up window, jump, etc. to complete the business process.

[0046] Still using the example of restaurant meal coupons, when the server assembles the complete QR code, it immediately decodes it and obtains information such as the coupon number and usage rules. Then, the server pushes this information to the app or mini program on the user's mobile phone through an encrypted channel. This allows users to see the specific content of the coupon in real time on the code scanning interface, and can complete subsequent operations such as coupon verification and consumption according to the prompts. Since the verification work is completed entirely on the server side and the client is only responsible for receiving the results, the entire process is opaque and cannot be tampered with, which effectively guarantees the legal use of the coupon.

[0047] It should be noted that, in specific implementation, the server can adopt various secure transmission mechanisms when sending the decoding results, such as SSL, digital signatures, etc., to prevent the intermediate links from being hijacked or tampered with, which is not limited here.

[0048] The server splits the original QR code into two complementary graphic units, and stores one of the graphic units in the server and distributes the other through public channels, thus achieving segmented management of the QR code information. This method can effectively prevent the illegal acquisition and interpretation of the QR code information, greatly improving the security of the QR code. Even if someone obtains the publicly distributed graphic unit, the complete QR code information cannot be restored due to the lack of the other half of the graphic unit that is paired with it. At the same time, the accuracy and integrity of the QR code information are guaranteed through structural matching and merging on the server side. This improves the security protection level of the QR code without sacrificing the convenience of using the QR code.

[0049] The following is a more detailed description of the process of the method provided by this implementation. Figure 2 , is another flow chart of a complementary two-dimensional code encryption and verification method in an embodiment of the present application.

[0050] S201. Split a plurality of original two-dimensional codes according to a preset splitting rule to obtain a plurality of first graphic units and corresponding second graphic units.

[0051] The server first generates the corresponding original QR code from the information to be encrypted. Then, the server divides each original QR code into two according to the preset splitting rule, thereby obtaining equal numbers of first graphic units and second graphic units. Specifically, the server extracts the pixels of odd rows and odd columns in the matrix corresponding to each original QR code as the content of the first graphic unit to obtain the first graphic unit, and extracts the pixels of even rows and even columns in the original QR code matrix as the content of the second graphic unit to obtain the second graphic unit.

[0052] For example, a car 4S store launched a promotion based on QR codes. The activity background first generated 100 electronic coupons according to the discount plan, and each electronic coupon corresponded to a complete QR code. Before the activity started, the server first classified the odd-numbered rows of pixels in each QR code matrix into the first graphic unit and the even-numbered rows of pixels into the second graphic unit in units of pixels. In this way, each original QR code was divided into two seemingly chaotic fragments. Customers only got one of the fragments and could not directly scan the code to obtain information or could only scan the code to get prompt information.

[0053] It should be noted that the specific splitting rules can be flexibly designed according to needs. For example, the QR code matrix can be interlacedly split based on a complex and customized algorithm. As long as the two graphic units can be combined to reconstruct the original QR code, there is no limitation here.

[0054] S202: Distribute the first graphic unit through a public channel, and store the second graphic unit in a database of a server.

[0055] When the server generates the paired first and second graphic units according to the preset rules, it will enter step S202 to distribute and store the split first and second graphic units. Specifically, the server will distribute the first graphic unit to the public through public channels, so that the public users can directly scan the first graphic unit through the scanning software of the client to obtain part of the data information corresponding to the first graphic unit; and the second graphic unit will be stored in a database with permission control. The segmented management of encrypted data information is realized, which is convenient for users to obtain part of the publicly available data information through the first graphic unit, and the complete presentation of information is controlled by the server, so as to realize the security protection of core key information.

[0056] S203: Determine whether the scanning software is authorized.

[0057] When the server detects that the user scans the first graphic unit through the client, it will determine whether the client's scanning software is authorized. Specifically, since the first graphic unit has been distributed to users through various channels. When the user attempts to scan these two-dimensional code fragments (first graphic units), the server will receive a connection request sent by the user's client or the client's scanning software, and detect whether the client or the client's scanning software is authorized based on the connection request. If so, it proceeds to step S204, and if not, it proceeds to step S205. In this way, only officially certified scanning tools can pass the server's security check, allowing users to enter the verification process of complementary graphics.

[0058] For example, in a promotional event at a car 4S store, the store will develop a customized version of the code scanning APP for this event, and require customers to use this APP to scan the first graphic unit posted everywhere. When the APP starts the code scanning action, the server will send a request to ask it to present the authenticated digital certificate. The APP will feedback a pre-embedded authorization code, or dynamically generate a unique signature based on the device fingerprint. Only if the code scanning request passes the signature verification, the server will allow the APP to upload the graphic data, otherwise it will directly reject the connection.

[0059] The server will only perform pairing verification in the database after receiving the first graphic unit sent by the authorized dedicated scanning software. Even if the unauthorized scanning software obtains the public graphic unit, it cannot communicate with the server, let alone decode the complete QR code content. This further limits the illegal access to the QR code information and improves the information security level of the QR code.

[0060] S204: Receive a first graphic unit sent by the client.

[0061] After detecting that the client or the scanning software of the client has been authorized, the server receives the first graphic unit sent by the client or the scanning software of the client for subsequent structural matching with the second graphic unit.

[0062] S205: Refuse to receive the first graphic unit sent by the client.

[0063] When the server detects that the scanning software of the client is unauthorized, the server will refuse to receive the first graphic unit uploaded by the client and return an error response to the client, prompting the user that the current scanning behavior is invalid.

[0064] S206: sequentially splice the first graphic unit with a plurality of second graphic units pre-stored in a database of the server according to a preset rule to obtain a combined two-dimensional code.

[0065] After acquiring the first graphic unit, the server performs a pairing test on the received first graphic unit and a plurality of second graphic units pre-stored in the server database, in order to find a target second graphic unit that can form a complete two-dimensional code with the first graphic unit.

[0066] Specifically, the server regards the first graphic unit as part of the puzzle, and regards each second graphic unit stored in the database as another possible part. The server uses the pixel points of the first graphic unit as a reference, and embeds the pixel points of the second graphic unit into the vacant position of the first graphic unit according to a preset mapping relationship, forming a complete matrix structure to obtain a combined QR code. The preset mapping relationship corresponds to the rule for splitting the QR code matrix before, which is usually staggered filling according to the parity of rows and columns.

[0067] For example, taking the promotion activities of a car 4S store as an example, when the server receives the QR code fragment (first graphic unit) uploaded by the customer, it starts to match it with several second graphic units in the database. The server first parses the first graphic unit into a 01 matrix and records the position of each pixel. Then, the server takes out a second graphic unit from the database and parses it into a 01 matrix. Then, the server cross-inserts the pixels of the two matrices according to the preset filling rules (such as the first graphic unit is an odd-numbered row and column, and the second graphic unit is an even-numbered row and column) to form a new combined matrix and obtain a combined QR code.

[0068] S207: Determine whether the combined two-dimensional code conforms to a preset matrix structure.

[0069] After the combined QR code is reassembled through the spatial splicing rules, the server will further verify the validity of the combined QR code, that is, determine whether it meets the basic requirements of QR code encoding. Because not all graphic splicing results are legal QR codes, it is possible that a meaningless noise image is generated due to the mismatch between the first and second graphic units.

[0070] Specifically, the server will pre-build some rules for determining the validity of the matrix combination two-dimensional code, that is, the data matrix structure of the two-dimensional code standard. After obtaining a combined two-dimensional code, the server immediately extracts its key parameters and compares them one by one with the preset rules, and judges whether the combined two-dimensional code meets the preset data matrix structure of the two-dimensional code standard based on the comparison results. If the parameters of the combined two-dimensional code meet all the rule requirements, it is determined that the splicing is successful, and the first graphic unit and the second graphic unit currently being processed are corresponding, and step S208 is entered. On the contrary, if the parameters of the combined two-dimensional code violate the rules in any one item, the server considers that the current two graphic unit structures do not match and cannot form a valid two-dimensional code, and it is necessary to replace other second graphic units and try again, specifically refer to step S209.

[0071] The server can restore the standard QR code data matrix by staggering the pixels of the two graphic units. This reconstruction method is based on the inherent rules of the preset QR code matrix and can quickly identify the correct matching graphic unit combination, improving the verification efficiency. At the same time, the combination QR code with non-standard structure will not pass the verification, which is convenient for timely detection of illegal forgery or tampering.

[0072] S208. Obtain the decoding result of the target QR code, and verify the integrity and legality of its information content.

[0073] When the server detects that a certain combined QR code conforms to the preset matrix structure, it means that the complete target QR code has been successfully restored, that is, the current second graphic unit corresponds to the first graphic unit. At this time, the server will immediately start the decoding program, read the data information to be encrypted carried by the target QR code, and obtain the decoding result. Specifically, you can call a mature QR code recognition library to convert the image information into the corresponding encoded data. Common QR code libraries such as ZXing, ZBar, etc., all provide simple and easy-to-use API interfaces. You only need to pass the QR code image into the specified function to decode it with one click to get the original byte stream. There is no limitation here.

[0074] In addition, after obtaining the decoding result, the server will also perform a content verification on the encoding result to ensure the integrity and validity of the data. This can avoid the problem of incomplete or ambiguous decoding results due to damage to the QR code image, partial occlusion, etc. At the same time, the verification of data format and value range can also promptly detect illegal information constructed maliciously and strengthen the server's own defense capabilities. Common verification methods include data length verification, character set detection, regular matching, verification and comparison, etc. Only when the decoded data passes a series of checks can it be confirmed that the current target QR code and the information it contains are completely valid and can be safely delivered to the user.

[0075] S209: Match the next second graphic unit or send a prompt message of scanning failure or invalidity to the user's client.

[0076] Since the structure verification of the combined QR code is an iterative process, if the second graphic unit currently in use cannot form a valid QR code structure with the first graphic unit, it means that the current second graphic unit does not correspond to the first graphic unit, and the server will continue to take out the next second graphic unit from the candidate set in the database until a target second graphic unit that matches the structure of the first graphic unit is found.

[0077] Of course, if the server traverses all the second graphic units stored in the database and cannot find the target second graphic unit corresponding to the first graphic unit, it is considered that the code scanning is a failure. The server will send a prompt message to the user's client to inform the user that the currently scanned QR code cannot be recognized or has expired, and guide the user to re-acquire a valid QR code image. For example, in the scenario of a car 4S store promotion, if the QR code fragment uploaded by a customer cannot form a complete target QR code with any alternative second graphic unit during the matching stage of the server, the server will push a prompt message to the customer's APP through an HTTP response, with the content "Unable to recognize the QR code, the coupon may have been used or expired, please try to scan other coupons". After receiving the pop-up reminder, the customer will realize that the fragment in his hand has been invalidated and needs to go to the front desk to collect a new coupon for another try. Therefore, when the verification fails, the server can give timely feedback to the user, avoiding unnecessary waiting and improving the user experience.

[0078] S210: If it is detected that the decoding result passes the integrity and legality verification, the permission to send the decoding result to the client is enabled.

[0079] When the server successfully extracts the target QR code and detects that the decoding result corresponding to the target QR code has passed the integrity and legality verification, it will authorize the decoding result to be sent to the client through the network interface.

[0080] The server verifies the integrity and legality of the decoded result of the QR code. Only the verified content will be authorized to be sent to the client. This avoids the server from sending incomplete or tampered data to the client, further improving the reliability and security of server data transmission.

[0081] S211, sending the encrypted decoding result to the client.

[0082] To prevent sensitive information from being stolen and tampered with on the network, the server will encrypt the decoded result before sending it to the client. The encryption can be based on a symmetric algorithm such as AES, or an asymmetric algorithm such as RSA. The choice of the specific encryption algorithm depends on factors such as data size, performance requirements, and security level, and is not limited here.

[0083] The encrypted decoding result is passed to the client through the server's API interface. At the same time, the server and the client generally interact through encrypted channels such as HTTPS. Even if the data is intercepted, it is difficult to crack its true content. In addition, verification mechanisms such as digital signatures can be attached to the transmitted data packets to ensure the integrity and non-repudiation of the data. After receiving the ciphertext, the client uses the pre-negotiated key to decrypt it, restore the original decoding result, and update the interface display.

[0084] S212: Record the client and the decoding result.

[0085] When the decoding result is successfully sent to the client, the server will also record the key information of the session for subsequent auditing and troubleshooting. This information usually includes but is not limited to the client's device ID, operating server and software version, timestamp of the operation, complete request content and server response, etc. The specific information recorded needs to consider the size of the storage space and the actual demand for information, which is not limited here.

[0086] The server uses an end-to-end encrypted transmission method to encrypt the decoding result of the QR code before sending it to the client, and requires a record to be kept. This transmission method can prevent sensitive information from being stolen during network transmission, and the record also facilitates subsequent audits and problem location, thereby expanding the practical value of the server in the field of secure communications.

[0087] For ease of understanding, the disassembly process of the original two-dimensional code is introduced below in conjunction with a specific embodiment.

[0088] Specific as Figure 3 The figure is a schematic diagram of an exemplary scenario in which the server disassembles the original QR code in an embodiment of the present application.

[0089] After the server generates the original QR code based on the information to be encrypted, it will decompose the original QR code to obtain complementary and mutually independent first and second graphic units. Figure 3 As shown in (a), it is an exemplary scene diagram of the original QR code. If the user scans the original QR code through a device such as a client scanning software, the encrypted information corresponding to the original QR code can be read. To prevent the leakage of the encrypted information, the server splits the original QR code according to the preset splitting rules to obtain the first graphic unit and the second graphic unit. Figure 3 As shown in (b), it is a schematic diagram of an exemplary scenario of disassembling the original QR code according to the disassembly rule. In Figure (b), all red areas are components of the second graphic unit. All red areas are combined to obtain the second graphic unit. Figure 3 As shown in (d), it is a schematic diagram of an exemplary scene of splitting the original two-dimensional code to obtain the second graphic unit. The black area is a component of the first graphic unit, and all black areas are combined to obtain the first graphic unit.

[0090] The first graphic unit is open to the public and stores the publicly available information set in the information to be encrypted. Users can scan the first graphic unit through the client to read the publicly available information, while the second graphic unit stores key information or confidential information and is stored in the database of the server. Only authorized clients or scanning software can apply to access the second graphic information. This realizes segmented management and security verification of QR code information and improves the security protection level of QR codes.

[0091] The server in the embodiment of the present invention is an electronic device. Figure 4 A schematic diagram of the architecture of an electronic device suitable for implementing an embodiment of the present invention is shown.

[0092] It should be noted that Figure 4 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0093] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments can be completed by instructions (computer programs), or by controlling related hardware through instructions (computer programs), and the instructions can be stored in a computer-readable storage medium and loaded and executed by a processor. The electronic device of this embodiment includes a storage medium and a processor, wherein a plurality of instructions are stored in the storage medium, and the instructions can be loaded by the processor to execute any step of the method provided in the embodiment of the present invention.

[0094] Specifically, the storage medium and the processor are electrically connected directly or indirectly to realize data transmission or interaction. For example, these elements can be electrically connected to each other through one or more signal lines. The storage medium stores computer execution instructions for implementing the data access control method, including at least one software function module that can be stored in the storage medium in the form of software or firmware. The processor executes various functional applications and data processing by running the software program and module stored in the storage medium. The storage medium can be, but is not limited to, random access storage medium (Random Access Memory, referred to as: RAM), read-only storage medium (Read Only Memory, referred to as: ROM), programmable read-only storage medium (Programmable Read-Only Memory, referred to as: PROM), erasable read-only storage medium (Erasable Programmable Read-Only Memory, referred to as: EPROM), electrically erasable read-only storage medium (Electric Erasable Programmable Read-Only Memory, referred to as: EEPROM), etc. Among them, the storage medium is used to store programs, and the processor executes the program after receiving the execution instruction.

[0095] Furthermore, the software programs and modules in the above-mentioned storage medium may also include an operating system, which may include various software components and / or drivers for managing system tasks (such as memory management, storage device control, power management, etc.), and may communicate with various hardware or software components to provide an operating environment for other software components. The processor may be an integrated circuit chip having signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc., which may implement or execute the various methods, steps, and logic flow diagrams disclosed in this embodiment. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0096] Since the instructions stored in the storage medium can execute the steps in any method provided in the embodiments of the present invention, the beneficial effects of any method provided in the embodiments of the present invention can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0097] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A complementary two-dimensional code encryption and verification method, applied to a server, It is characterized in that The method comprises: When it is detected that a user scans a first graphic unit through a client, receiving the first graphic unit sent by the client, wherein the first graphic unit is obtained by splitting an original two-dimensional code, and the original two-dimensional code is generated according to information data to be encrypted; Performing structural matching on the first graphic unit and a plurality of second graphic units pre-stored in a database of a server, wherein the second graphic unit is obtained by splitting the original two-dimensional code, wherein the structural matching refers to determining whether there is a target second graphic unit corresponding to the first graphic unit in the database, wherein the target second graphic unit and the first graphic unit can be complementary and spliced ​​to obtain a complete original two-dimensional code, and the target second unit is one of the plurality of second graphic units; If it is detected that there is a target second graphic unit corresponding to the first graphic unit in the database, the first graphic unit and the target second graphic unit are complementary spliced ​​to generate a complete target two-dimensional code, wherein one or more original two-dimensional codes are stored in the database, and the target two-dimensional code is one of the one or more original two-dimensional codes; The decoding result of the target two-dimensional code is sent to the client, where the decoding result is the information data to be encrypted corresponding to the target two-dimensional code.

2. The method according to claim 1, It is characterized in that Before the step of receiving the first graphic unit sent by the client when it is detected that the user scans the first graphic unit through the client, the method further includes: Splitting the plurality of original two-dimensional codes according to a preset splitting rule to obtain a plurality of first graphic units and corresponding second graphic units, wherein the preset splitting rule is to use the pixels of odd rows and odd columns in the matrix corresponding to the original two-dimensional code as the content of the first graphic unit, and to use the pixels of even rows and even columns in the matrix corresponding to the original two-dimensional code as the content of the second graphic unit; distributing the first graphic unit through a public channel; The second graphic unit is stored in a database, and access rights for the second graphic unit are set.

3. The method according to claim 1, It is characterized in that When it is detected that a user scans a first graphic unit through a client, the step of receiving the first graphic unit sent by the client specifically includes: When it is detected that the user scans the first graphic unit through the client, determining whether the scanning software of the client is authorized; If not, refusing to receive the first graphic unit sent by the client, and sending a prompt message that authorization cannot be obtained to the client; If yes, the first graphics unit sent by the client is received.

4. The method according to claim 1, It is characterized in that The step of structurally matching the first graphic unit with a plurality of second graphic units pre-stored in a database of the server specifically includes: The first graphic unit is sequentially spliced ​​with a plurality of second graphic units pre-stored in the database according to a preset rule to obtain a combined two-dimensional code, wherein the preset rule is to use the pixels of the first graphic unit as odd rows and odd columns of the combined two-dimensional code, and to use the pixels of the second graphic unit as even rows and even columns of the combined two-dimensional code; Determining whether the combined two-dimensional code conforms to a data matrix structure of a preset two-dimensional code standard; If yes, then the second graphic unit currently corresponds to the first graphic unit; If not, the second graphic unit currently does not correspond to the first graphic unit.

5. The method according to claim 1, It is characterized in that After the step of structurally matching the first graphic unit with a plurality of second graphic units pre-stored in the database of the server, the method further includes: If it is detected that the target second graphic unit corresponding to the first graphic unit does not exist in the database, a prompt message indicating that the scan has failed or is invalid is sent to the client of the user.

6. The method according to claim 1, It is characterized in that Before the step of sending the decoding result of the target two-dimensional code to the client, the method further includes: Obtaining a decoding result of the target two-dimensional code; Verifying the integrity and legality of the information content corresponding to the decoding result; If it is detected that the decoding result passes the integrity and legality verification, the permission to send the decoding result to the client is enabled.

7. The method according to claim 1, It is characterized in that The step of sending the decoding result of the target two-dimensional code to the client specifically includes: Encrypting the decoding result according to a preset encryption algorithm; Sending the encrypted decoding result to the client; The client and the decoding result are recorded for filing.

8. A server, It is characterized in that The server includes: one or more processors and memory; The memory is coupled to the one or more processors, and the memory is used to store computer program codes, where the computer program codes include computer instructions. The one or more processors call the computer instructions to enable the server to execute the method according to any one of claims 1 to 7.

9. A computer-readable storage medium comprising instructions, It is characterized in that When the instructions are executed on a server, the server is caused to execute the method according to any one of claims 1 to 7.

10. A computer program product, It is characterized in that When the computer program product is run on a server, the server is caused to execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Two-dimensional code layering and verification method

    CN105426946A

  • Two-dimensional code scanning-based safety detection and verification method and system

    CN107704790A

  • Static two-dimensional code security storage method and device, static two-dimensional code security verification method and device and electronic equipment

    CN113420316A

  • Encryption and decryption method and system of two-dimensional code

    CN116258162A

  • Two-dimensional code processing method and apparatus

    US20180232552A1