Anti-counterfeiting code generation method, anti-counterfeiting code decoding method and device

By using random number encryption, hash algorithm summary and digital watermarking technology in QR code technology, anti-counterfeiting codes are generated, and the problem of insufficient security of QR code data is solved, and efficient data encryption and verification are achieved.

CN118761432BActive Publication Date: 2025-03-07BEIJING SHENZHOU LOONGSON ANCHUANG INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410796999.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2025-03-07
Estimated Expiration
2044-06-19

AI Technical Summary

Technical Problem

The existing QR code technology has defects in data security and is prone to the risk of data leakage and tampering, especially when carrying sensitive information.

Method used

By determining the random number as the key, the message information is encrypted, combined with hashing algorithm, asymmetric algorithm and digital watermarking technology, anti-counterfeiting code is generated, and the encrypted message information, random number ciphertext, digest information and public key are written into the information area, encryption area, verification area and watermark area respectively.

Benefits of technology

It realizes encryption protection of QR code data, ensures the security and integrity of information, and uses digital watermark technology to realize encrypted transmission on the basis of QR code anti-counterfeiting, improving data security and verification speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118761432B_ABST
    Figure CN118761432B_ABST
Patent Text Reader

Abstract

The present invention provides an anti-counterfeiting code generation method, an anti-counterfeiting code decoding method and a device, the method comprising: determining a random number, using the random number as a key to encrypt first message information to obtain encrypted message information; determining summary information of the first message information based on a hash algorithm; encrypting the random number based on a private key to obtain a random number ciphertext; writing the encrypted message information into an information area based on a coding rule, writing the random number ciphertext into an encryption area, writing the summary information into a verification area, and writing the public key corresponding to the private key into a watermark area as digital watermark information to generate a corresponding anti-counterfeiting code; in this way, random number technology, cryptographic technology, digital watermark technology and a two-dimensional code coding method are combined, random numbers are used to realize one object one code, one code one password, cryptographic technology is used to realize encryption protection of message information, and digital watermark technology is used to realize encrypted transmission based on two-dimensional code anti-counterfeiting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of anti-counterfeiting of graphic coding and image coding, and in particular to an anti-counterfeiting code generation method, an anti-counterfeiting code decoding method and a device. Background Art

[0002] In today's information age, QR code has been widely used as a convenient and efficient tool. It provides a quick verification method in the field of product traceability, simplifies the data collection process in information collection, and expands the channels for information dissemination in the field of advertising.

[0003] However, despite the many conveniences brought by QR codes, data security is often overlooked during their widespread use. As the value of information continues to increase, the security of user data has become critical. In many scenarios, the information carried by QR codes may contain sensitive personal data, commercial secrets, etc. If not properly protected, it is prone to security risks such as data leakage and tampering. Summary of the invention

[0004] The present disclosure provides an anti-counterfeiting code generating method, an anti-counterfeiting code decoding method and a device, so as to at least solve the above technical problems existing in the prior art.

[0005] According to a first aspect of the present disclosure, a method for generating an anti-counterfeiting code is provided, the method comprising:

[0006] Determine a random number, and use the random number as a key to encrypt the first message information to obtain encrypted message information;

[0007] Determine summary information of the first message information based on a hash algorithm;

[0008] Encrypting the random number based on a private key to obtain a random number ciphertext;

[0009] Based on the coding rules, the encrypted message information is written into the information area, the random number ciphertext is written into the encryption area, the summary information is written into the verification area, and the public key corresponding to the private key is written into the watermark area as digital watermark information to generate a corresponding anti-counterfeiting code.

[0010] In the above scheme, the determining of the random number and encrypting the first message information using the random number as a key to obtain the encrypted message information includes:

[0011] Generate a random number, use the random number as a key of a symmetric algorithm, encrypt the first message information, and obtain encrypted message information.

[0012] In the above scheme, the encrypted message information is written into the information area based on the coding rule, the random number ciphertext is written into the encryption area, the summary information is written into the verification area, and the public key corresponding to the private key is written into the watermark area as digital watermark information to generate the corresponding anti-counterfeiting code, including:

[0013] Encoding the encrypted message information based on the encoding rule to form an information area encoding pattern;

[0014] Encoding the random number ciphertext based on the encoding rule to form an encryption area encoding pattern;

[0015] Encoding the summary information based on the encoding rule to form a verification area encoding pattern;

[0016] Encoding the public key based on the encoding rule to form a watermark area encoding pattern;

[0017] The information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern are arranged according to their respective partitions to obtain corresponding anti-counterfeiting codes.

[0018] In the above scheme, the information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern are arranged according to their respective partitions to obtain the corresponding anti-counterfeiting code, and further includes:

[0019] Re-partitioning the arranged information area coding pattern, encryption area coding pattern, verification area coding pattern and watermark area coding pattern so that the partition corresponding to the coding pattern is different from the actual arrangement partition, and rearrange the re-partitioned coding patterns to obtain corresponding anti-counterfeiting codes;

[0020] The coding patterns include an information area coding pattern, an encryption area coding pattern, a check area coding pattern and a watermark area coding pattern.

[0021] According to a second aspect of the present disclosure, there is provided an anti-counterfeiting code decoding method, comprising:

[0022] Obtaining the information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern in the anti-counterfeiting code, and decoding them into encrypted message information, random number ciphertext, summary information and public key respectively;

[0023] Decrypting the random number ciphertext based on the public key to obtain a random number;

[0024] Decrypting the encrypted message information based on the random number to obtain first message information;

[0025] Confirm the hash value of the first message information and compare it with the summary information. If the hash value of the first message information is consistent with the summary information, the first message information has not been tampered with.

[0026] In the above scheme, the step of obtaining the information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern in the anti-counterfeiting code, and decoding them into encrypted message information, random number ciphertext, summary information and public key respectively includes:

[0027] According to the coding pattern partitioning rules and arrangement rules, determine the information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern in the anti-counterfeiting code;

[0028] Based on the decoding rules, the information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern are respectively decoded into encrypted message information, random number ciphertext, summary information and public key.

[0029] In the above scheme, the method further includes:

[0030] Confirm whether the decoding location is included in the authorized area of ​​the first message information. If not, send the first alarm information.

[0031] According to a third aspect of the present disclosure, there is provided an anti-counterfeiting code generating device, the device comprising:

[0032] A first encryption unit, used to determine a random number, and use the random number as a key to encrypt the first message information to obtain the encrypted message information;

[0033] A second encryption unit, used to determine summary information of the first message information based on a hash algorithm;

[0034] A third encryption unit, used to encrypt the random number based on a private key to obtain a random number ciphertext;

[0035] The encoding unit is used to write the encrypted message information into the information area based on the encoding rules, write the random number ciphertext into the encryption area, write the summary information into the verification area, write the public key corresponding to the private key into the watermark area as digital watermark information, and generate a corresponding anti-counterfeiting code.

[0036] According to a fourth aspect of the present disclosure, there is provided an anti-counterfeiting code decoding device, the device comprising:

[0037] A decoding unit, used to obtain the information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern in the anti-counterfeiting code, and decode them into encrypted message information, random number ciphertext, summary information and public key respectively;

[0038] A first decryption unit, used to decrypt the random number ciphertext based on a public key to obtain a random number;

[0039] A second decryption unit, used to decrypt the encrypted message information based on the random number to obtain first message information;

[0040] The verification unit is used to confirm the hash value of the first message information and compare it with the summary information. If the hash value of the first message information is consistent with the summary information, the first message information has not been tampered with.

[0041] According to a fifth aspect of the present disclosure, there is provided an electronic device, including:

[0042] at least one processor; and

[0043] A memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the present disclosure.

[0044] The disclosed anti-counterfeiting code generation method determines a random number, uses the random number as a key to encrypt the first message information, and obtains the encrypted message information; determines the summary information of the first message information based on a hash algorithm; encrypts the random number based on a private key to obtain a random number ciphertext; writes the encrypted message information into the information area based on the coding rule, writes the random number ciphertext into the encryption area, writes the summary information into the verification area, writes the public key corresponding to the private key into the watermark area as digital watermark information, and generates a corresponding anti-counterfeiting code. In this way, the random number technology, the cryptographic technology, the digital watermark technology and the encoding method of the two-dimensional code are combined, and the random number is used to realize one object one code, one code one secret, the cryptographic technology is used to realize the encryption protection of the message information, and the digital watermark technology is used to realize the encrypted transmission based on the two-dimensional code anti-counterfeiting; in addition, in the decoding process of the anti-counterfeiting code, the information of the information area, the encryption area, the verification area and the watermark area are extracted by partition, and the anti-counterfeiting code can be verified offline according to the corresponding digital watermark extraction algorithm, the cryptographic algorithm and the corresponding operation steps, without the need for networking, thereby improving the verification speed.

[0045] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] The above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, in which:

[0047] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.

[0048] Figure 1 A first optional flow chart of the anti-counterfeiting code generation method provided by an embodiment of the present disclosure is shown;

[0049] Figure 2 A second optional flow chart of the anti-counterfeiting code generation method provided by an embodiment of the present disclosure is shown;

[0050] Figure 3 A schematic diagram of generating an anti-counterfeiting code provided by an embodiment of the present disclosure is shown;

[0051] Figure 4 A first optional flow chart of the anti-counterfeiting code decoding method provided by an embodiment of the present disclosure is shown;

[0052] Figure 5 A second optional flow chart of the anti-counterfeiting code decoding method provided by an embodiment of the present disclosure is shown;

[0053] Figure 6 A schematic diagram of decoding the anti-counterfeiting code disclosed in the present invention is shown;

[0054] Figure 7 An optional structural schematic diagram of an anti-counterfeiting code generating device provided by an embodiment of the present disclosure is shown;

[0055] Figure 8 An optional structural schematic diagram of an anti-counterfeiting code decoding device provided by an embodiment of the present disclosure is shown;

[0056] Fig. 9 A schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0057] In order to make the purpose, features, and advantages of the present disclosure more obvious and easy to understand, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.

[0058] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it can be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0059] In the following description, the terms "first\second" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.

[0060] Unless otherwise defined, all technical and scientific terms used in this disclosure have the same meaning as those commonly understood by those skilled in the art to which this disclosure belongs. The terms used in this disclosure are only for the purpose of describing the embodiments of this disclosure and are not intended to limit this disclosure.

[0061] It should be understood that in the various embodiments of the present disclosure, the size of the serial number of each implementation process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure.

[0062] First, the terms mentioned in the embodiments of the present disclosure are explained.

[0063] Digital watermarking refers to the use of signal processing methods to embed hidden information in digital multimedia data (images, audio, video, etc.). This information is usually invisible and can only be extracted through a dedicated detector or reader. The digital watermarking process is to embed certain information that can prove copyright ownership or track infringement into the protected carrier data (such as still images, videos, audio, etc.). It can be the author's serial number, company logo, meaningful text, and does not affect the protected digital object. The information used for embedding is usually called a watermark. In addition, according to the different characteristics of digital watermarks, digital watermark algorithms suitable for different scenarios can be designed. For example, robust invisible watermarks can be used for copyright protection, copy control, fingerprint recognition, etc.; fragile invisible watermarks can be used for content authentication, file modification detection, etc.; semi-fragile watermarks can be used for printed anti-counterfeiting, etc.

[0064] QR code encryption technology refers to the encryption of data during the QR code generation process to prevent the data from being illegally obtained or tampered with. It mainly consists of three aspects: encryption algorithm, encryption method, and key usage.

[0065] 1. Encryption Algorithm

[0066] 1. Hash algorithm (such as SHA-256 algorithm, SM3 algorithm). Hash algorithm can convert information of any length into a digital summary of fixed length, and the digital summary generated by any different message or file is different. Therefore, the digital summary has error detection capability9, that is, changing any one or more bits of the message will cause the digital summary to change, thus preventing tampering of the message data.

[0067] 2. Asymmetric algorithms (such as RSA algorithm, SM2 algorithm, SM9 algorithm, etc.). Asymmetric algorithms require two keys: a public key (Public key, referred to as public key) and a private key (Private key, referred to as private key). The public key and the private key are a pair. If the public key is used to encrypt the message data, only the corresponding private key can be used to decrypt it; if the private key is used to encrypt the message data, only the corresponding public key can be used to decrypt it.

[0068] 3. Symmetric algorithm (such as AES algorithm, SM1 algorithm, SM4 algorithm, etc.). Symmetric algorithm only requires one key, that is, the same key is used for encryption and decryption.

[0069] In related technologies, the following methods are mainly used to apply encryption algorithms to QR code generation:

[0070] 1. Directly encrypt the data in the QR code

[0071] This method is to encrypt the first message information before the two-dimensional code encoding by an encryption algorithm to obtain ciphertext information, and then generate a two-dimensional code. After decoding the two-dimensional code, the ciphertext information is decrypted by a decryption algorithm to obtain the original plaintext information.

[0072] 2. Encrypt after generating the QR code

[0073] Because the QR code itself is an image after being encoded, the image can be encrypted using an encryption algorithm.

[0074] In the above two methods, the key is usually distributed to the user who needs to use it before using the QR code. When the user parses the QR code, he needs to use the distributed key for decryption. Since the same key is used for encryption and decryption when using a symmetric algorithm, there may be a risk of leakage during the distribution of the symmetric algorithm key. Therefore, the symmetric algorithm key needs to be protected and transmitted to the designated user in an appropriate manner.

[0075] Therefore, in view of the defects existing in the relevant QR code encryption process, the embodiments of the present disclosure provide an anti-counterfeiting code generation method and a corresponding anti-counterfeiting code decoding method, which utilizes a digital watermark algorithm to achieve protective distribution of keys and solve some or all of the above-mentioned technical problems.

[0076] Figure 1 A first optional flow chart of the anti-counterfeiting code generation method provided by the embodiment of the present disclosure is shown, and will be explained according to each step.

[0077] Step S101, determine a random number, and use the random number as a key to encrypt the first message information to obtain encrypted message information.

[0078] In some embodiments, the first message information, i.e., the information to be encrypted, includes commodity information, unique identification information of the commodity, production information of the commodity such as the manufacturer, place of origin, commodity process flow and other related information; the first message information also includes relevant information such as the sales destination, sales object and sales market; it may also include relevant information such as the transportation route, transportation method and transportation process. The disclosed embodiments are not limited to the content and form of the first message information, and the first message information may exist in the form of data such as text data, video, audio, graphics or images.

[0079] In some embodiments, the random number is a key of a symmetric algorithm, and the length of the random number is determined based on the symmetric algorithm. Different symmetric algorithms have different lengths of random numbers. For example, if the symmetric algorithm is DES (Data Encryption Standard), the length of the random number is 56 bits (or bits); if the symmetric algorithm is AES (Advanced Encryption Standard), the length of the random number is one of 128 bits, 192 bits, and 256 bits; if the symmetric algorithm is SM1 algorithm, the length of the random number is 128 bits; if the symmetric algorithm is SM4 algorithm, the length of the random number is 128 bits.

[0080] In some embodiments, the carrier implementing the anti-counterfeiting code generation method (hereinafter referred to as the first carrier) uses a random number as a key and encrypts the first message information based on a symmetric algorithm to obtain encrypted message information. The first carrier can be a computer program, electronic circuit, database, mobile application, electronic device, cloud computing platform, distributed system, artificial intelligence framework, mathematical model, automation tool and microcontroller, etc., which can implement the algorithm, method flow software or hardware.

[0081] Among them, the random number used as the key can only be known by the encryption method and the authorized decryption method, so the confidentiality effect is better. In other words, only by knowing the encryption method can the length of the random number be determined and then decrypted.

[0082] Step S102: Determine summary information of the first message information based on a hash algorithm.

[0083] In some embodiments, the first carrier uses a hash algorithm (SM3) to hash the first message information to obtain summary information of the first message information; during decryption, it is determined whether the first message information has been tampered with by comparing the summary information with the decrypted message information.

[0084] Step S103, encrypt the random number to obtain a random number ciphertext.

[0085] In some embodiments, the first carrier uses an asymmetric algorithm to encrypt the random number to obtain a random number ciphertext.

[0086] In some embodiments, the first carrier sets a public key and a private key, and uses the private key to encrypt the random number to obtain a random number ciphertext as digital watermark information; when the encrypted first message information is carried in a graphic manner, the watermark information can be loaded into the graphic. For example, the random number ciphertext can be set as a QR code watermark, carried in the encrypted graphic corresponding to the encrypted first message information, and guided to the set server or background through the QR code. The random number used as the key in the QR code can only be obtained after the corresponding identity authentication or authorization.

[0087] Step S104, based on the coding rules, write the encrypted message information into the information area, write the random number ciphertext into the encryption area, write the summary information into the verification area, write the public key corresponding to the private key into the watermark area as digital watermark information, and generate a corresponding anti-counterfeiting code.

[0088] In some embodiments, the first carrier encodes the encrypted message information into an information area coding pattern according to the corresponding coding rules; encodes the random number ciphertext into an encryption area coding pattern; encodes the summary information into a verification area coding pattern, and encodes the public key into a watermark area coding pattern; based on the information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern, an anti-counterfeiting code corresponding to the first message information is generated. The anti-counterfeiting code can be various codes in the Chinese MA identification code system, such as a two-dimensional code, a Hanxin code, a QR code, a Longbei code and a GM code, etc. The present disclosure takes a two-dimensional code as an example for explanation, and those skilled in the art should understand that the anti-counterfeiting code generation method and the anti-counterfeiting code decoding method involved in the present disclosure are also applicable to other codes in the Chinese MA identification code system.

[0089] In this way, through the anti-counterfeiting code generation method provided by the embodiment of the present disclosure, random number technology, cryptographic technology, digital watermark technology and QR code encoding method are combined, random numbers are used to realize one code for one object and one code for one password, cryptographic technology is used to realize encryption protection of message information, and digital watermark technology is used to realize encrypted transmission based on QR code anti-counterfeiting, thereby improving the security of encryption of the first message information.

[0090] Figure 2 A second optional flow chart of the anti-counterfeiting code generation method provided by the embodiment of the present disclosure is shown. Figure 3 The schematic diagram of generating the anti-counterfeiting code provided by the embodiment of the present disclosure is shown. Figure 2 and Figure 3 Provide explanation.

[0091] Step S201, obtaining first message information.

[0092] In some embodiments, the first message information is various information to be encrypted, which may be commodity information, unique identification information of commodities, production information of commodities such as manufacturer, place of origin, commodity process flow and other related information. The first message information may also include relevant information about the sales destination, sales object and sales duration. It may also be relevant information about the transportation route, transportation method and transportation process. The embodiments of the present disclosure are not limited to the content and format of the first message information. The first message information may be in the form of data such as text data, video, audio, graphics or images.

[0093] Step S202: Generate a random number, and use the random number to perform a first-level encryption on the first message information.

[0094] In some embodiments, the first level encryption may use a symmetric encryption algorithm, such as SM4 encryption, which uses a packet data algorithm for encryption, and the key length and packet length are both 128 bits. Specifically, a random number is generated, and the random number is used as a key for the symmetric algorithm (SM4), that is, the first message information is encrypted with a key using the random number to obtain the encrypted message information. The random number used as the key can only be known by the encryption party and the authorized decryption party, so its confidentiality effect is better.

[0095] Step S203, encrypt the random number using the second level encryption to obtain a random number ciphertext, and use the random number ciphertext as digital watermark information.

[0096] In some embodiments, the second-level encryption algorithm may include an asymmetric algorithm (SM2) encryption. First, a public key (Public key) and a private key (Private key) are set. The public key and the private key are a pair. If the message data is encrypted with the public key, it can only be decrypted with the corresponding private key; if the message data is encrypted with the private key, it can only be decrypted with the corresponding public key. In the embodiment of the present disclosure, the random number used for decryption by the first-level encryption algorithm is encrypted again. In this way, the random number ciphertext can be carried as digital watermark information in the encrypted graph so that the decryption party can know the random number. Therefore, the encryption method of the embodiment of the present disclosure has a stronger confidentiality strength.

[0097] As a carrying method, when the encrypted first message information is carried in a graphic form, the watermark information can be loaded into the graphic. For example, the random number ciphertext can be set as a QR code watermark, carried in the encrypted graphic corresponding to the encrypted first message information, and guided to the set server or backend through the QR code. The encrypted random number in the QR code can only be obtained after the corresponding identity authentication or authorization.

[0098] Step S204: encrypt the first message information using the third-level encryption algorithm to obtain summary information.

[0099] As an example, in the embodiment of the present disclosure, a hash algorithm (SM3) is used to perform a hash operation on the first message information to obtain summary information of the first message information, and the summary information is used as a basis for judging whether the first message information has been tampered with or the content has been adjusted to ensure the integrity of the first message information.

[0100] Those skilled in the art should understand that step S202, step S203 and step S204 can be executed in parallel, and there are no strict time and sequence execution requirements.

[0101] Step S205, graphically encode the encrypted message information, random number ciphertext, summary information, and digital watermark information, and generate corresponding coding patterns according to corresponding coding rules; then arrange each coding pattern according to corresponding arrangement rules, and set the arranged coding patterns on corresponding products.

[0102] In the disclosed embodiment, the encrypted message information, random number ciphertext, summary information, and digital watermark information can be encoded using corresponding graphic encoding rules to generate corresponding coding patterns. The generated coding pattern can be provided with information area, encryption area, verification area, and watermark area, and each coding pattern can be arranged according to the set partitions to obtain the coding pattern provided on the product.

[0103] In the disclosed embodiment, after arranging each coding pattern according to the corresponding arrangement rule, the arranged coding pattern can be partitioned again, and rearranged according to the set transformation rule, and the arranged pattern is set on the corresponding product. In this way, even if the decryptor obtains the distribution of the information area, encryption area, verification area, and watermark area, it is difficult to know the original coding pattern after the partitioning and rearrangement of the coding pattern in the embodiment of the present application, and it is impossible to decode the coding pattern.

[0104] As an implementation method, the re-partitioned and shuffled graphics can be partitioned and rearranged again, that is, the graphics are partitioned into different area regions for multiple times and then partitioned and arranged again, so that the maximum confidentiality of the coding pattern can be achieved. As an example, the Arnold transform method can be used for image scrambling processing.

[0105] In this way, through the anti-counterfeiting code generation method provided by the embodiment of the present disclosure, random number technology, cryptographic technology, digital watermark technology and QR code encoding method are combined, random numbers are used to realize one code for one object and one code for one password, cryptographic technology is used to realize encryption protection of message information, and digital watermark technology is used to realize encrypted transmission based on QR code anti-counterfeiting, thereby improving the security of encryption of the first message information.

[0106] Figure 4A first optional flow chart of the anti-counterfeiting code decoding method provided by the embodiment of the present disclosure is shown, and will be explained according to each step.

[0107] Step S401, obtaining the information area coding pattern, encryption area coding pattern, verification area coding pattern and watermark area coding pattern in the anti-counterfeiting code, and decoding them into encrypted message information, random number ciphertext, summary information and public key respectively.

[0108] In some embodiments, a carrier (hereinafter referred to as the second carrier) that implements the anti-counterfeiting code decoding method obtains the anti-counterfeiting code, reads the anti-counterfeiting code, obtains the information area coding pattern, encryption area coding pattern, verification area coding pattern and watermark area coding pattern in the anti-counterfeiting code, obtains encrypted message information based on the information area coding pattern, obtains random number ciphertext based on the encryption area coding pattern, obtains summary information based on the verification area coding pattern, and obtains a public key based on the watermark area coding pattern.

[0109] Step S402: decrypt the random number ciphertext based on the public key to obtain a random number.

[0110] In some embodiments, the random number ciphertext is obtained by encrypting the random number using a private key based on an asymmetric algorithm, so the random number can be obtained by decrypting the random number ciphertext based on the public key.

[0111] Step S403: decrypt the encrypted message information based on the random number to obtain first message information.

[0112] In some embodiments, the encrypted message information is obtained by encrypting the first message information using a key (random number) based on a symmetric algorithm. Therefore, the first message information can be obtained by decrypting the encrypted message information using the random number as the key.

[0113] Step S404, confirming the hash value of the first message information and comparing it with the summary information. If the hash value of the first message information is consistent with the summary information, the first message information has not been tampered with.

[0114] In some embodiments, after obtaining the first message information, in order to verify whether the first message information has been tampered with, the hash value of the first message information is compared with the summary information. If the two are the same, the first message information has not been tampered with; if the two are different, the first message information has been tampered with, and the product corresponding to the anti-counterfeiting code may have problems.

[0115] Optionally, the second carrier may also send first warning information in response to the first message information being tampered with.

[0116] In this way, through the anti-counterfeiting code decoding method provided by the embodiment of the present disclosure, the information of the information area, encryption area, verification area and watermark area can be extracted by partitioning, and the anti-counterfeiting code can be verified offline according to the corresponding digital watermark extraction algorithm, cryptographic algorithm and corresponding operation steps, without the need for Internet access, thereby improving the verification speed.

[0117] Figure 5 A second optional flow chart of the anti-counterfeiting code decoding method provided by the embodiment of the present disclosure is shown. Figure 6 The schematic diagram of the anti-counterfeiting code decoding of the present invention is shown. Figure 5 and Figure 6 Provide explanation.

[0118] Step S501, reading the coding pattern in the anti-counterfeiting code.

[0119] In some embodiments, the second carrier obtains the anti-counterfeiting code set on the product by scanning or image acquisition.

[0120] In some embodiments, the second carrier obtains the partition of each coding pattern in the anti-counterfeiting code according to the partition arrangement rule of the coding pattern, that is, at least obtains the distribution of the information area, encryption area, verification area and watermark area in the anti-counterfeiting code, and then uses the encryption method in each partition to decrypt the corresponding information respectively, and finally obtains the first message information and other related information, and obtains the original information based on the first message information to realize relevant verification of the identity, authenticity, operation circuit, product quality, etc. of the goods, so as to ensure the authenticity of the product channel and quality.

[0121] As an implementation method, if each coding pattern in the anti-counterfeiting code is processed by Arnold transformation, it is necessary to first transform it into an initial coding pattern according to the Arnold transformation processing rule, and then perform partition decoding to obtain corresponding information.

[0122] Step S502, obtaining the coding pattern of the watermark area, performing graphic recognition on the data carried by the watermark area, and obtaining the public key.

[0123] In some embodiments, the second carrier identifies the coding pattern in the watermark area to obtain a public key; and decrypts the random number ciphertext in the coding pattern in the encryption area based on a decryption method corresponding to the second-level encryption to obtain a random number.

[0124] Step S503, obtaining the information area coding pattern, performing graphic recognition on the information area to obtain encrypted message information, and using a random number to decrypt the encrypted message information to obtain first message information.

[0125] In some embodiments, the second carrier identifies the coding pattern of the information area, obtains the encrypted message information, and decrypts the encrypted message information using a random number to obtain the first message information.

[0126] Step S504, obtaining a coding pattern of the verification area, performing graphic recognition on the verification area to obtain summary information, and verifying the first message information based on the summary information.

[0127] In some embodiments, the second carrier obtains summary information, that is, a hash value of the first message information, performs a hash operation on the decrypted first message information using a hash algorithm to obtain a calculated hash value, and matches the calculated hash value with the summary information to determine whether the first message information has been tampered with.

[0128] In some embodiments, based on the result of whether the first message information has been tampered with, it can be determined whether the product information is consistent with that carried in the coding pattern, and then whether the product is authentic.

[0129] For example, if the first message information has been tampered with, the product information is inconsistent with the product information carried in the anti-counterfeiting code, and the product can be determined to be a counterfeit or fake product; conversely, if the first message information has not been tampered with, the product information is consistent with the product information carried in the anti-counterfeiting code, and the product is determined to be authentic.

[0130] In some embodiments, product information, unique identification information of the product, production information of the product such as manufacturer, place of origin, product process flow, and other related information, as well as relevant information on the sales destination, sales object and sales duration, transportation route, transportation method and relevant information on the transportation process can be used to ensure that the product is authorized, and the traceability and genuine quality of the product will not be counterfeited.

[0131] In some optional embodiments, when the user scans, identifies and decrypts the coded pattern through the terminal, the second carrier can also collect the user's terminal information to obtain the category, price and other related information of the scanning terminal to obtain the corresponding user portrait. The user's scanning location can also be collected to determine whether the sales location of the product is an authorized area.

[0132] In this way, through the anti-counterfeiting code decoding method provided by the embodiment of the present disclosure, the information of the information area, encryption area, verification area and watermark area can be extracted by partitioning, and the anti-counterfeiting code can be verified offline according to the corresponding digital watermark extraction algorithm, cryptographic algorithm and corresponding operation steps, without the need for Internet access, thereby improving the verification speed.

[0133] Figure 7 An optional structural schematic diagram of the anti-counterfeiting code generating device provided by an embodiment of the present disclosure is shown, and will be described according to each part.

[0134] In some embodiments, the anti-counterfeiting code generating device 700 includes a first encryption unit 701 , a second encryption unit 702 , a third encryption unit 703 and an encoding unit 704 .

[0135] The first encryption unit 701 is used to determine a random number, and use the random number as a key to encrypt the first message information to obtain the encrypted message information;

[0136] The second encryption unit 702 is used to determine the summary information of the first message information based on a hash algorithm;

[0137] The third encryption unit 703 is used to encrypt the random number based on the private key to obtain a random number ciphertext;

[0138] The encoding unit 704 is used to write the encrypted message information into the information area, write the random number ciphertext into the encryption area, write the summary information into the verification area, write the public key corresponding to the private key as digital watermark information into the watermark area based on the encoding rules, and generate a corresponding anti-counterfeiting code.

[0139] The first encryption unit 701 is specifically used to generate a random number, and use the random number as a key of a symmetric algorithm to encrypt the first message information to obtain encrypted message information.

[0140] The encoding unit 704 is specifically used to encode the encrypted message information based on the encoding rules to form an information area encoding pattern; encode the random number ciphertext based on the encoding rules to form an encryption area encoding pattern; encode the summary information based on the encoding rules to form a verification area encoding pattern; encode the public key based on the encoding rules to form a watermark area encoding pattern; arrange the information area encoding pattern, the encryption area encoding pattern, the verification area encoding pattern and the watermark area encoding pattern according to their respective partitions to obtain a corresponding anti-counterfeiting code.

[0141] The encoding unit 704 is also used to re-partition the arranged information area coding pattern, encryption area coding pattern, verification area coding pattern and watermark area coding pattern, so that the partition corresponding to the coding pattern is different from the actual arrangement partition, and to rearrange the re-partitioned coding patterns to obtain corresponding anti-counterfeiting codes; the coding patterns include information area coding pattern, encryption area coding pattern, verification area coding pattern and watermark area coding pattern.

[0142] Figure 8 An optional structural schematic diagram of the anti-counterfeiting code decoding device provided by an embodiment of the present disclosure is shown, and will be described according to each part.

[0143] In some embodiments, the anti-counterfeiting code decoding device 900 includes a decoding unit 901 , a first decryption unit 902 , a second decryption unit 903 and a verification unit 904 .

[0144] The decoding unit 901 is used to obtain the information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern in the anti-counterfeiting code, and decode them into encrypted message information, random number ciphertext, summary information and public key respectively;

[0145] A first decryption unit 902, configured to decrypt the random number ciphertext based on a public key to obtain a random number;

[0146] A second decryption unit 903, configured to decrypt the encrypted message information based on the random number to obtain first message information;

[0147] The verification unit 904 is used to confirm the hash value of the first message information and compare it with the summary information. If the hash value of the first message information is consistent with the summary information, the first message information has not been tampered with.

[0148] The decoding unit 901 is specifically used to determine the information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern in the anti-counterfeiting code according to the coding pattern partitioning rule and arrangement rule;

[0149] Based on the decoding rules, the information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern are respectively decoded into encrypted message information, random number ciphertext, summary information and public key.

[0150] The verification unit 904 is further configured to confirm whether the decoding location is included in the authorized area of ​​the first message information, and if not, send the first warning information.

[0151] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.

[0152] Fig. 9 A schematic block diagram of an example electronic device 800 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0153] like Fig. 9As shown, the electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0154] Multiple components in the electronic device 800 are connected to the I / O interface 805, including: an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the electronic device 800 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0155] The computing unit 801 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 801 performs the various methods and processes described above, such as anti-counterfeiting code generation methods and / or anti-counterfeiting code decoding methods. For example, in some embodiments, the anti-counterfeiting code generation method and / or the anti-counterfeiting code decoding method may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the anti-counterfeiting code generation method and / or the anti-counterfeiting code decoding method described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to execute the anti-counterfeiting code generating method and / or the anti-counterfeiting code decoding method in any other appropriate manner (for example, by means of firmware).

[0156] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0157] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0158] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0159] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0160] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0161] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0162] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0163] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0164] The above is only a specific embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A method for generating an anti-counterfeiting code, characterized in that: The method comprises: Determine a random number, and use the random number as a key to encrypt the first message information to obtain encrypted message information; Determine summary information of the first message information based on a hash algorithm; Encrypting the random number based on a private key to obtain a random number ciphertext; Based on the coding rules, the encrypted message information is written into the information area, the random number ciphertext is written into the encryption area, the summary information is written into the verification area, and the public key corresponding to the private key is written into the watermark area as digital watermark information to generate a corresponding anti-counterfeiting code.

2. The method according to claim 1, characterized in that The step of determining a random number and encrypting the first message information using the random number as a key to obtain the encrypted message information includes: Generate a random number, use the random number as a key of a symmetric algorithm, encrypt the first message information, and obtain encrypted message information.

3. The method according to claim 1, characterized in that The method of writing the encrypted message information into the information area, writing the random number ciphertext into the encryption area, writing the summary information into the verification area, and writing the public key corresponding to the private key into the watermark area as digital watermark information based on the encoding rule to generate the corresponding anti-counterfeiting code includes: Encoding the encrypted message information based on the encoding rule to form an information area encoding pattern; Encoding the random number ciphertext based on the encoding rule to form an encryption area encoding pattern; Encoding the summary information based on the encoding rule to form a verification area encoding pattern; Encoding the public key based on the encoding rule to form a watermark area encoding pattern; The information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern are arranged according to their respective partitions to obtain corresponding anti-counterfeiting codes.

4. The method according to claim 3, characterized in that: The step of arranging the information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern according to respective partitions to obtain corresponding anti-counterfeiting codes also includes: Re-partitioning the arranged information area coding pattern, encryption area coding pattern, verification area coding pattern and watermark area coding pattern so that the partition corresponding to the coding pattern is different from the actual arrangement partition, and rearrange the re-partitioned coding patterns to obtain corresponding anti-counterfeiting codes; The coding patterns include an information area coding pattern, an encryption area coding pattern, a check area coding pattern and a watermark area coding pattern.

5. A method for decoding an anti-counterfeiting code, characterized in that: The method comprises: Obtaining the information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern in the anti-counterfeiting code, and decoding them into encrypted message information, random number ciphertext, summary information and public key respectively; Decrypting the random number ciphertext based on the public key to obtain a random number; Decrypting the encrypted message information based on the random number to obtain first message information; Confirm the hash value of the first message information and compare it with the summary information. If the hash value of the first message information is consistent with the summary information, the first message information has not been tampered with.

6. The method according to claim 5, characterized in that The method of obtaining the information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern in the anti-counterfeiting code, and decoding them into encrypted message information, random number ciphertext, summary information and public key respectively, includes: According to the coding pattern partitioning rules and arrangement rules, determine the information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern in the anti-counterfeiting code; Based on the decoding rules, the information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern are respectively decoded into encrypted message information, random number ciphertext, summary information and public key.

7. The method according to claim 5, characterized in that The method further comprises: Confirm whether the decoding location is included in the authorized area of ​​the first message information. If not, send the first alarm information.

8. An anti-counterfeiting code generating device, characterized in that: The device comprises: A first encryption unit, used to determine a random number, and use the random number as a key to encrypt the first message information to obtain the encrypted message information; A second encryption unit, used to determine summary information of the first message information based on a hash algorithm; A third encryption unit, used to encrypt the random number based on a private key to obtain a random number ciphertext; The encoding unit is used to write the encrypted message information into the information area based on the encoding rules, write the random number ciphertext into the encryption area, write the summary information into the verification area, write the public key corresponding to the private key into the watermark area as digital watermark information, and generate a corresponding anti-counterfeiting code.

9. An anti-counterfeiting code decoding device, characterized in that: The device comprises: A decoding unit, used to obtain the information area coding pattern, the encryption area coding pattern, the verification area coding pattern and the watermark area coding pattern in the anti-counterfeiting code, and decode them into encrypted message information, random number ciphertext, summary information and public key respectively; A first decryption unit, used to decrypt the random number ciphertext based on a public key to obtain a random number; A second decryption unit, used to decrypt the encrypted message information based on the random number to obtain first message information; The verification unit is used to confirm the hash value of the first message information and compare it with the summary information. If the hash value of the first message information is consistent with the summary information, the first message information has not been tampered with.

10. An electronic device, characterized in that: include: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method according to any one of claims 1 to 4; Alternatively, the method according to any one of claims 5 to 7 can be performed.

Citation Information

Patent Citations

  • Information interaction safety transmission method and system based on information identification code electromagnetic signal

    CN107222501A

  • Double anti-counterfeit method of QR code based on RSA encryption and digital watermarking

    CN109034333A