CN118761432B - Anti-counterfeiting code generation method, anti-counterfeiting code decoding method and device - Google Patents
Anti-counterfeiting code generation method, anti-counterfeiting code decoding method and device Download PDFInfo
- Publication number
- CN118761432B CN118761432B CN202410796999.9A CN202410796999A CN118761432B CN 118761432 B CN118761432 B CN 118761432B CN 202410796999 A CN202410796999 A CN 202410796999A CN 118761432 B CN118761432 B CN 118761432B
- Authority
- CN
- China
- Prior art keywords
- information
- random number
- area
- coding pattern
- message information
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/08—Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
- H04L9/0861—Generation of secret information including derivation or calculation of cryptographic keys or passwords
- H04L9/0869—Generation of secret information including derivation or calculation of cryptographic keys or passwords involving random numbers or seeds
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K19/00—Record carriers for use with machines and with at least a part designed to carry digital markings
- G06K19/06—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
- G06K19/06009—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
- G06K19/06037—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking multi-dimensional coding
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K19/00—Record carriers for use with machines and with at least a part designed to carry digital markings
- G06K19/06—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
- G06K19/06009—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
- G06K19/06046—Constructional details
- G06K19/06056—Constructional details the marking comprising a further embedded marking, e.g. a 1D bar code with the black bars containing a smaller sized coding
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/06—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
- H04L9/0643—Hash functions, e.g. MD5, SHA, HMAC or f9 MAC
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Power Engineering (AREA)
- Editing Of Facsimile Originals (AREA)
Abstract
The present disclosure provides an anti-counterfeit code generation method, an anti-counterfeit code decoding method and a device, wherein the method comprises determining a random number, and encrypting a first message information by using the random number as a key to obtain encrypted message information; determining summary information of the first message information based on a hash algorithm; the method comprises the steps of obtaining a random number cipher text by encrypting a random number based on a private key, writing encrypted message information into an information area based on an encoding rule, writing the random number cipher text into an encryption area, writing abstract information into a verification area, writing a public key corresponding to the private key into a watermark area as digital watermark information to generate corresponding anti-fake codes, combining a random number technology, a password technology and a digital watermark technology with a two-dimensional code encoding mode, realizing one-object one-code one-cipher by adopting the random number, realizing encryption protection of the message information by adopting the password technology, and realizing encryption transmission on the two-dimensional code anti-fake basis by adopting the digital watermark technology.
Description
Technical Field
The disclosure relates to the field of anti-counterfeiting technologies of graphic codes and image codes, in particular to an anti-counterfeiting code generation method, an anti-counterfeiting code decoding method and an anti-counterfeiting code decoding device.
Background
In the present informatization age, the two-dimensional code is used as a convenient and efficient tool, and is widely applied. The method provides a quick verification mode in the product traceability field, simplifies the data collection flow in the aspect of information collection, and expands the information propagation way in the advertising field.
However, although two-dimensional codes bring convenience, data security is often ignored in the process of its wide application. With the continuous increase of information value, the security protection of user data becomes critical. In many situations, the information carried by the two-dimensional code may include sensitive personal data, business secrets, and the like, and if the information is not properly protected, security risks such as data leakage, tampering, and the like are easily faced.
Disclosure of Invention
The present disclosure provides an anti-counterfeit code generation method, an anti-counterfeit code decoding method and an anti-counterfeit code decoding device, so as to at least solve the above technical problems in the prior art.
According to a first aspect of the present disclosure, there is provided an anti-counterfeit code generation method, the method comprising:
Determining a random number, and encrypting the first message information by taking the random number as a secret key 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 an encoding rule, writing a random number ciphertext into the encryption area, writing abstract information into a verification area, writing a public key corresponding to the private key into a watermark area as digital watermark information, and generating a corresponding anti-fake code.
In the above scheme, the determining the random number, encrypting the first message information by using the random number as a key to obtain encrypted message information, includes:
And generating a random number, and encrypting the first message information by taking the random number as a key of a symmetric algorithm to obtain encrypted message information.
In the above scheme, the writing of the encrypted message information into the information area based on the encoding rule, writing of the random number ciphertext into the encryption area, writing of the abstract information into the verification area, writing of the public key corresponding to the private key into the watermark area as the digital watermark information, and generating of the corresponding anti-counterfeiting code includes:
coding the encrypted message information based on coding rules to form an information area coding pattern;
Encoding the random number ciphertext based on an encoding rule to form an encryption area encoding pattern;
Encoding the abstract information based on an encoding rule to form a check region encoding pattern;
Encoding the public key based on an encoding rule to form a watermark region encoding pattern;
And arranging the information region coding pattern, the encryption region coding pattern, the check region coding pattern and the watermark region coding pattern according to the respective subareas to obtain corresponding anti-counterfeiting codes.
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 the respective subareas to obtain the corresponding anti-counterfeiting codes, and the method further comprises the steps of;
Re-partitioning the information region coding pattern, the encryption region coding pattern, the check region coding pattern and the watermark region coding pattern after arrangement, so that the partition corresponding to the coding pattern is different from the actually arranged partition, and re-arranging the coding patterns of the re-arranged partition to obtain a corresponding anti-counterfeiting code;
each coding pattern comprises an information area coding pattern, an encryption area coding pattern, a check area coding pattern and a watermark area coding pattern.
According to a second aspect of the present disclosure, there is provided an anti-counterfeit code decoding method, including:
acquiring an information area coding pattern, an encryption area coding pattern, a check area coding pattern and a watermark area coding pattern in the anti-counterfeiting code, and respectively decoding the information area coding pattern, the encryption area coding pattern, the check area coding pattern and the watermark area coding pattern into encrypted message information, random number ciphertext, abstract information and a public key;
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;
And confirming the hash value of the first message information, comparing the hash value with the abstract information, and if the hash value of the first message information is consistent with the abstract information, not falsifying the first message information.
In the above scheme, the obtaining the information area coding pattern, the encryption area coding pattern, the check area coding pattern and the watermark area coding pattern in the anti-counterfeiting code, and decoding the information area coding pattern, the encryption area coding pattern, the check area coding pattern and the watermark area coding pattern into encrypted message information, random number ciphertext, summary information and public key respectively includes:
According to the coding pattern partitioning rule and the arrangement rule, determining an information area coding pattern, an encryption area coding pattern, a check area coding pattern and a watermark area coding pattern in the anti-counterfeiting code;
And respectively decoding the information area coding pattern, the encryption area coding pattern, the check area coding pattern and the watermark area coding pattern into encrypted message information, random number ciphertext, summary information and a public key based on a decoding rule.
In the above scheme, the method further comprises:
and confirming whether the decoding place is included in the authorized area of the first message information, and if not, sending the first alarm information.
According to a third aspect of the present disclosure, there is provided an anti-counterfeit code generation apparatus, the apparatus comprising:
The first encryption unit is used for determining a random number, and encrypting the first message information by taking the random number as a key to obtain encrypted message information;
the second encryption unit is used for determining summary information of the first message information based on a hash algorithm;
the third encryption unit is used for encrypting the random number based on a private key to obtain a random number ciphertext;
The encoding unit is used for writing the encrypted message information into the information area based on the encoding rule, writing the random number ciphertext into the encryption area, writing the abstract information into the verification area, writing the public key corresponding to the private key into the watermark area as the digital watermark information, and generating the corresponding anti-counterfeiting code.
According to a fourth aspect of the present disclosure, there is provided an anti-counterfeit code decoding device, the device comprising:
the decoding unit is used for acquiring an information area coding pattern, an encryption area coding pattern, a check area coding pattern and a watermark area coding pattern in the anti-counterfeiting code and respectively decoding the information area coding pattern, the encryption area coding pattern, the check area coding pattern and the watermark area coding pattern into encrypted message information, random number ciphertext, abstract information and a public key;
the first decryption unit is used for decrypting the random number ciphertext based on the public key to obtain a random number;
the second decryption unit is used for decrypting the encrypted message information based on the random number to obtain first message information;
and the verification unit is used for confirming the hash value of the first message information and comparing the hash value with the abstract information, and if the hash value of the first message information is consistent with the abstract information, the first message information is not tampered.
According to a fifth aspect of the present disclosure, there is provided an electronic device comprising:
At least one processor, and
And a memory communicatively coupled to the at least one processor, wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the methods described in the present disclosure.
The anti-counterfeiting code generation method includes the steps of determining a random number, encrypting first message information by taking the random number as a secret key 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 an encoding rule, writing the random number ciphertext into an encryption area, writing the summary information into a verification area, and writing a public key corresponding to the private key into a watermark area as digital watermark information to generate corresponding anti-counterfeiting codes. In addition, in the decoding process of the anti-fake code, the information of the information area, the encryption area, the verification area and the watermark area is extracted in a partition mode, and the anti-fake code can be verified offline according to a corresponding digital watermark extraction algorithm, a corresponding password algorithm and corresponding operation steps without networking, so that the verification speed is improved.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The above, as well as additional purposes, features, and advantages of exemplary embodiments of the present disclosure will become readily apparent from the following detailed description when read in conjunction with the accompanying drawings. Several embodiments of the present disclosure are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings, in which:
In the drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
Fig. 1 is a schematic flow chart of a first alternative method for generating an anti-counterfeit code according to an embodiment of the disclosure;
fig. 2 is a schematic flow chart of a second alternative method for generating an anti-counterfeit code according to an embodiment of the disclosure;
fig. 3 shows a schematic diagram of anti-counterfeit code generation provided by an embodiment of the present disclosure;
fig. 4 is a schematic flow chart of a first alternative method for decoding an anti-counterfeit code according to an embodiment of the disclosure;
fig. 5 is a schematic flow chart of a second alternative method for decoding an anti-counterfeit code according to an embodiment of the disclosure;
FIG. 6 illustrates a schematic diagram of decoding an security code of the present disclosure;
fig. 7 is a schematic diagram illustrating an alternative structure of an anti-counterfeit code generation apparatus according to an embodiment of the present disclosure;
fig. 8 is a schematic diagram illustrating an alternative structure of an anti-counterfeit code decoding device according to an embodiment of the present disclosure;
Fig. 9 shows a schematic diagram of a composition structure of an electronic device according to an embodiment of the present disclosure.
Detailed Description
In order to make the objects, features and advantages of the present disclosure more comprehensible, the technical solutions in the embodiments of the present disclosure will be clearly described in conjunction with the accompanying drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are only some embodiments of the present disclosure, but not all embodiments. Based on the embodiments in this disclosure, all other embodiments that a person skilled in the art would obtain without making any inventive effort are within the scope of protection of this disclosure.
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is to be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with one another without conflict.
In the following description, the terms "first", "second", and the like are merely used to distinguish between similar objects and do not represent a particular ordering of the objects, it being understood that the "first", "second", or the like may be interchanged with one another, if permitted, to enable embodiments of the disclosure described herein to be implemented in an order other than that illustrated or described herein.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure belongs. The terminology used in the present disclosure is for the purpose of describing embodiments of the present disclosure only and is not intended to be limiting of the present disclosure.
It should be understood that, in various embodiments of the present disclosure, the size of the sequence number of each implementation process does not mean that the execution sequence 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.
The terms mentioned in the embodiments of the present disclosure are explained first.
Digital watermarking refers to embedding hidden information in digitized multimedia data (images, audio, video, etc.) by means of signal processing, which information is usually not visible and can only be extracted by means of a dedicated detector or reader. The digital watermarking process is to embed some information, such as the author's serial number, company logo, meaningful text, into the protected carrier data (e.g., still image, video, audio, etc.), which is often referred to as watermark, that can prove copyright ownership or follow-up infringement, without affecting the protected digital object. According to different characteristics of the digital watermark, digital watermark algorithms suitable for different scenes can be designed, such as robust invisible watermark can be used for copyright protection, copy control, fingerprint identification and the like, fragile invisible watermark can be used for content authentication, file modification detection and the like, and semi-fragile watermark can be used for printed matter anti-counterfeiting and the like.
The two-dimensional code encryption technology is used for encrypting data in the process of generating the two-dimensional code, so that the data is prevented from being illegally acquired or tampered. The method mainly comprises three aspects of an encryption algorithm, an encryption mode and a key using method.
1. Encryption algorithm
1. The hash algorithm (such as SHA-256 algorithm and SM3 algorithm) can convert information with any length into digital digests with fixed length, and the digital digests generated by any different messages or files are different, so the digital digests have error detection capability 9, namely, any one or more bits of the message are changed, which can lead to the change of the digital digests, and therefore, the tampering of the message data can be prevented.
2. Asymmetric algorithms (e.g., RSA algorithm, SM2 algorithm, SM9 algorithm, etc.), which require two keys, a Public key and a private key (PRIVATE KEY ). The public key and the private key are a pair, if the public key is used for encrypting the message data, the message data can be decrypted only by the corresponding private key, and if the private key is used for encrypting the message data, the message data can be decrypted only by the corresponding public key.
3. Symmetric algorithms (e.g., AES algorithm, SM1 algorithm, SM4 algorithm, etc.), the symmetric algorithm requires only one key, i.e., the same key is used for encryption and decryption.
In the related art, the following methods are mainly adopted to apply the encryption algorithm to the two-dimensional code generation:
1. Direct encryption of data in two-dimensional code
The method is that the first message information before the two-dimension code is encoded is encrypted through an encryption algorithm to obtain ciphertext information, and the two-dimension code is regenerated. And after decoding the two-dimensional code, decrypting the ciphertext information by using a decryption algorithm to obtain original plaintext information.
2. Encryption is performed after the two-dimensional code is generated
Because the two-dimensional code is an image after being encoded, the image can be encrypted by an encryption algorithm.
In the two modes, the key is generally distributed to users needing to be used before the two-dimensional code is used. When a user analyzes the two-dimensional code, the user needs to use the distributed secret key to perform decryption operation. Since the same key is used for encryption and decryption when using the symmetric algorithm, and there may be a risk of leakage in the process of distributing the symmetric algorithm key, it is necessary to protect the symmetric algorithm key and transmit the key to the designated user in a corresponding manner.
Therefore, aiming at the defects existing in the related two-dimensional code encryption process, the embodiment of the disclosure provides an anti-counterfeiting code generation method and a corresponding anti-counterfeiting code decoding method, and the protective distribution of the secret key is realized by using a digital watermark algorithm, so that the technical problems of part or all of the above are solved.
Fig. 1 is a schematic flow chart of a first alternative method for generating an anti-counterfeit code according to an embodiment of the present disclosure, and will be described according to various steps.
Step S101, determining a random number, and encrypting the first message information by taking the random number as a secret key to obtain encrypted message information.
In some embodiments, the first message information, that is, the information to be encrypted, includes information related to commodity information, unique identification information of the commodity, production information of the commodity, such as manufacturer, production place, commodity process flow, etc., where the first message information further includes related information such as sales destination, sales object, sales market, etc., and may also include related information such as transportation route, transportation mode, transportation process, etc. Embodiments of the present disclosure are not limited to the content and form of the first message information, and the first message information may exist in the form of text data, video, audio, graphics, or image data.
In some embodiments, the random number is a key of a symmetric algorithm, the length of the random number is determined based on the symmetric algorithm, the length of the random number is different in different symmetric algorithms, for example, the random number is 56 bits (or bits) if the symmetric algorithm is DES (Data Encryption Standard), the random number is 128 bits, 192 bits or 256 bits if the symmetric algorithm is AES (Advanced Encryption Standard), the random number is 128 bits if the symmetric algorithm is SM1 algorithm, and the random number is 128 bits if the symmetric algorithm is SM4 algorithm.
In some embodiments, a carrier (hereinafter referred to as a first carrier) implementing the anti-counterfeiting code generation method 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 may be a computer program, an electronic circuit, a database, a mobile application program, an electronic device, a cloud computing platform, a distributed system, an artificial intelligence framework, a mathematical model, an automation tool, a microcontroller, or the like, and software or hardware capable of implementing an algorithm, a method flow.
The random number used as the key can be obtained by an encryption mode and an authorized decryption mode, so that the confidentiality effect is better. That is, only knowing the encryption scheme can the length of the random number be determined for decryption.
Step S102, determining summary information of the first message information based on a hash algorithm.
In some embodiments, the first carrier hashes the first message information by using a hash algorithm (SM 3) to obtain summary information of the first message information, and determines whether the first message information is tampered by comparing the summary information with the decrypted message information when decrypting.
And step S103, encrypting the random number to obtain a random number ciphertext.
In some embodiments, the first carrier encrypts the random number using an asymmetric algorithm to obtain a random number ciphertext.
In some embodiments, the first carrier sets a public key and a private key, encrypts the random number with the private key to obtain a random number ciphertext as digital watermark information, and 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 two-dimensional code watermark, and is carried into an encrypted graph corresponding to the encrypted first message information, and the encrypted graph is guided to a set server or background through the two-dimensional code, so that the random number serving as a key in the two-dimensional code can be obtained after corresponding identity authentication or authentication.
Step S104, based on the coding rule, the encrypted message information is written into the information area, the random number ciphertext is written into the encryption area, the abstract information is written into the check area, the public key corresponding to the private key is used as the digital watermark information to be written into the watermark area, and the corresponding anti-fake code is generated.
In some embodiments, the first carrier encodes the encrypted message information into an information area encoding pattern, encodes the random number ciphertext into an encryption area encoding pattern, encodes the digest information into a check area encoding pattern, encodes the public key into a watermark area encoding pattern, and generates the anti-counterfeiting code corresponding to the first message information based on the information area encoding pattern, the encryption area encoding pattern, the check area encoding pattern and the watermark area encoding pattern. The anti-counterfeiting code can be various codes in a Chinese MA identification code system, such as a two-dimensional code, a Chinese letter code, a QR code, a dragon Bei Ma, a GM code and the like, the two-dimensional code is taken as an example for illustration in the present disclosure, and a person skilled in the art should understand that the anti-counterfeiting code generation method and the anti-counterfeiting code decoding method related to the present disclosure are also applicable to other codes in the Chinese MA identification code system.
Thus, by the anti-counterfeiting code generation method provided by the embodiment of the disclosure, the random number technology, the password technology and the digital watermark technology are combined with the encoding mode of the two-dimensional code, one object and one code and one cipher are realized by adopting the random number, the encryption protection of the message information is realized by adopting the password technology, the encryption transmission on the anti-counterfeiting basis of the two-dimensional code is realized by adopting the digital watermark technology, and the security of encrypting the first message information is improved.
Fig. 2 shows a second alternative flow chart of the anti-counterfeit code generation method provided by the embodiment of the present disclosure, and fig. 3 shows the anti-counterfeit code generation method provided by the embodiment of the present disclosure, which will be described with reference to fig. 2 and 3.
Step S201, obtain the first message information.
In some embodiments, the first message information is various information to be encrypted, and may be related information such as merchandise information, unique identification information of merchandise, production information of merchandise, such as manufacturer, production place, merchandise process flow, etc. The first message information may also include information related to a sales destination, a sales object, and a sales duration. And can also be related information of the transportation route, the transportation mode and the transportation process. 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 text data, video, audio, graphics, or images.
Step S202, generating a random number, and performing first-stage encryption on the first message information by using the random number.
In some embodiments, the first level encryption may employ a symmetric encryption algorithm, such as SM4 encryption, which encrypts in a packet data algorithm with a key length and a packet length of 128 bits. Specifically, a random number is generated, and the random number is used as a key of a symmetric algorithm (SM 4), namely, the first message information is encrypted by using the random number to obtain encrypted message information. The random number used as the secret key can be known by the encrypting party and the authorized decrypting party, so that the secret effect is better.
Step S203, encrypting the random number by using the second-stage encryption to obtain a random number ciphertext, and taking the random number ciphertext as digital watermark information.
In some embodiments, the second-level encryption algorithm may include asymmetric algorithm (SM 2) encryption. Firstly, 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 Public key is used for encrypting the message data, the message data can be decrypted only by the corresponding private key, and if the private key is used for encrypting the message data, the message data can be decrypted only by the corresponding Public key. In the embodiment of the disclosure, the random number decrypted by the first-stage encryption algorithm is encrypted again, so that the random number ciphertext can be used as digital watermark information to be carried in the encryption graph, so that a decryption party can learn the random number. Therefore, the encryption mode of the embodiment of the disclosure has stronger confidentiality.
As a carrying manner, when the encrypted first message information is carried in a graphic manner, watermark information may be loaded into the graphic. For example, the random number ciphertext can be set as a two-dimensional code watermark, and is carried into an encrypted graph corresponding to the encrypted first message information, and the encrypted random number in the two-dimensional code can be obtained after the encrypted random number ciphertext is guided to a set server or background through the two-dimensional code and is subjected to corresponding identity authentication or authentication.
Step S204, encrypting the first message information by adopting a third-level encryption algorithm to obtain abstract information.
As an example, in the embodiment of the present disclosure, a hash algorithm (SM 3) is used to perform hash operation on the first message information to obtain summary information of the first message information, and the summary information is used as a criterion for judging whether to tamper or adjust content of the first message information, so as to ensure integrity of the first message information.
It will be appreciated by those skilled in the art that steps S202, S203 and S204 may be performed in parallel without strict time and sequence requirements.
Step S205, carrying out graphic coding on the encrypted message information, the random number ciphertext, the abstract information and the digital watermark information, generating corresponding coding patterns according to corresponding coding rules, arranging the coding patterns according to corresponding arrangement rules, and setting the arranged coding patterns on corresponding products.
In the embodiment of the disclosure, the encrypted message information, the random number ciphertext, the abstract information and the digital watermark information can be respectively encoded according to corresponding graphic encoding rules to generate corresponding encoding patterns. An information area, an encryption area, a check area and a watermark area can be respectively arranged on the generated coding patterns, and the coding patterns are arranged according to the arranged areas to obtain the coding patterns arranged on the product.
In the embodiment of the disclosure, after each coding pattern is arranged according to a corresponding arrangement rule, the arranged coding patterns can be partitioned again, rearranged according to a set transformation rule, and arranged on corresponding products according to an arranged pattern. Therefore, even if a decryptor obtains the distribution of the information area, the encryption area, the verification area and the watermark area, after the partition of the coding pattern is rearranged, the original coding pattern is difficult to obtain, and decoding of the coding pattern is not realized.
As an implementation mode, the graphic which is rearranged in a disordered manner in the re-partition can be partitioned again and rearranged, namely, the graphic is partitioned in different area areas for multiple times, and the partition arrangement is performed again, so that the confidentiality of the coding pattern can be realized to the greatest extent. As an example, the image scrambling process may be performed using an Arnold (Arnold) transformation.
Thus, by the anti-counterfeiting code generation method provided by the embodiment of the disclosure, the random number technology, the password technology and the digital watermark technology are combined with the encoding mode of the two-dimensional code, one object and one code and one cipher are realized by adopting the random number, the encryption protection of the message information is realized by adopting the password technology, the encryption transmission on the anti-counterfeiting basis of the two-dimensional code is realized by adopting the digital watermark technology, and the security of encrypting the first message information is improved.
Fig. 4 is a schematic flow chart of a first alternative method for decoding an anti-counterfeit code according to an embodiment of the present disclosure, and will be described according to the steps.
Step S401, an information area coding pattern, an encryption area coding pattern, a check area coding pattern and a watermark area coding pattern in the anti-counterfeiting code are obtained and are respectively decoded into encrypted message information, random number ciphertext, abstract information and a public key.
In some embodiments, a carrier (hereinafter referred to as a second carrier) for implementing the decoding method of the security code obtains the security code, reads the security code, obtains an information area coding pattern, an encryption area coding pattern, a check area coding pattern and a watermark area coding pattern in the security code, obtains encrypted message information based on the information area coding pattern, obtains a random number ciphertext based on the encryption area coding pattern, obtains summary information based on the check area coding pattern, and obtains a public key based on the watermark area coding pattern.
And step S402, decrypting the random number ciphertext based on the public key to obtain a random number.
In some embodiments, the random number ciphertext is encrypted using a private key based on an asymmetric algorithm, and thus the random number ciphertext is decrypted based on a public key, resulting in a random number.
Step S403, decrypting the encrypted message information based on the random number, to obtain first message information.
In some embodiments, the encrypted message information is obtained by encrypting the first message information using a key (a random number) based on a symmetric algorithm, and thus, the encrypted message information is decrypted using the random number as the key, so that the first message information can be obtained.
Step S404, confirming the hash value of the first message information, comparing the hash value with the abstract information, and if the hash value of the first message information is consistent with the abstract information, not falsifying the first message information.
In some embodiments, after the first message information is obtained, in order to verify whether the first message information is tampered, the hash value based on the obtained first message information is compared with the digest information, if the hash value and the digest information are the same, the first message information is not tampered, if the hash value and the digest information are different, the first message information is tampered, and a commodity corresponding to the anti-counterfeiting code may have a problem.
Optionally, the second carrier may further send the first alarm information in response to the first message information being tampered.
Thus, according to the anti-counterfeiting code decoding method provided by the embodiment of the disclosure, the information of the information area, the encryption area, the verification area and the watermark area is extracted in a partitioning manner, and the anti-counterfeiting code can be verified offline according to the corresponding digital watermark extraction algorithm, the corresponding password algorithm and the corresponding operation steps, so that networking is not needed, and the verification speed is improved.
Fig. 5 shows a second alternative flow chart of the decoding method of the security code provided by the embodiment of the present disclosure, fig. 6 shows a decoding schematic diagram of the security code of the present disclosure, and will be described with reference to fig. 5 and 6.
Step S501, the coding pattern in the anti-fake code is read.
In some embodiments, the second carrier obtains the security code disposed on the article by scanning or image acquisition.
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, the encryption area, the verification area and the watermark area in the anti-counterfeiting code, decrypts the corresponding information respectively by using the encryption mode in each partition, and finally obtains the related information such as the first message information, and obtains the original information based on the first message information, so as to realize the related verification of identity, authenticity, operation circuit, product quality and the like of the commodity, and ensure the authenticity of the commodity channel and quality.
As an implementation manner, if each coding pattern in the anti-fake code is subjected to Arnold transformation, the coding pattern is transformed into an initial coding pattern according to Arnold transformation rules, and then the corresponding information is decoded by partitioning.
Step S502, obtaining the watermark region coding pattern, and carrying out pattern recognition on the data carried by the watermark region to obtain the public key.
In some embodiments, the second carrier identifies the watermark region encoding pattern to obtain a public key, and decrypts the random number ciphertext in the encryption region encoding pattern based on a decryption method corresponding to the second-stage encryption to obtain the random number.
Step S503, obtaining the information area coding pattern, carrying out pattern recognition on the information area to obtain encrypted message information, and decrypting the encrypted message information by using a random number to obtain first message information.
In some embodiments, the second carrier identifies the information area coding pattern, obtains encrypted message information, and decrypts the encrypted message information by using a random number to obtain the first message information.
Step S504, the code pattern of the check area is obtained, the check area is subjected to pattern recognition to obtain abstract information, and the first message information is verified based on the abstract information.
In some embodiments, the second bearer obtains digest information, that is, a hash value of the first message information. And carrying out hash operation on the decrypted first message information by utilizing a hash algorithm to obtain an operated hash value. And matching the calculated hash value with the abstract information to determine whether the first message information is tampered.
In some embodiments, based on the result of whether the first message information is tampered, it may be determined whether the commodity information is consistent with the commodity carried in the encoding pattern, and further whether the commodity is genuine.
For example, if the first message information is tampered, the commodity information is inconsistent with the commodity information carried in the anti-counterfeiting code, and the commodity can be determined to be a counterfeit commodity or a counterfeit commodity, otherwise, if the first message information is not tampered, the commodity information is consistent with the commodity information carried in the anti-counterfeiting code, and the commodity is determined to be a genuine commodity.
In some embodiments, the commodity is an authorized commodity and traceable and genuine commodity is ensured not to be imitated by commodity information, unique identification information of the commodity, production information of the commodity such as manufacturer, production place, commodity technological process and the like, and related information of sales destination, sales object and sales time, transportation route, transportation mode and transportation process.
In some optional embodiments, when the user scans, identifies and decrypts the coding pattern through the terminal, the second carrier may further collect terminal information of the user, so as to obtain related information such as a class, a price, and the like of the scanning terminal, so as to obtain a corresponding user portrait. The user's scan location, etc. may also be collected to determine if the merchandise sales location is an authorized location, etc.
Thus, according to the anti-counterfeiting code decoding method provided by the embodiment of the disclosure, the information of the information area, the encryption area, the verification area and the watermark area is extracted in a partitioning manner, and the anti-counterfeiting code can be verified offline according to the corresponding digital watermark extraction algorithm, the corresponding password algorithm and the corresponding operation steps, so that networking is not needed, and the verification speed is improved.
Fig. 7 is a schematic diagram showing an alternative structure of an anti-counterfeit code generation apparatus according to an embodiment of the present disclosure, and will be described in terms of various parts.
In some embodiments, the security code generation apparatus 700 includes a first encryption unit 701, a second encryption unit 702, a third encryption unit 703, and a coding unit 704.
The first encryption unit 701 is configured to determine a random number, and encrypt the first message information with the random number as a key to obtain encrypted message information;
The second encryption unit 702 is configured to determine digest information of the first message information based on a hash algorithm;
The third encryption unit 703 is configured to encrypt the random number based on a private key to obtain a random number ciphertext;
The encoding unit 704 is configured to write the encrypted message information into the information area, write the random number ciphertext into the encryption area, write the digest information into the verification area, and write the public key corresponding to the private key into the watermark area as digital watermark information, thereby generating a corresponding anti-counterfeiting code.
The first encryption unit 701 is specifically configured to generate a random number, and encrypt the first message information with the random number as a key of a symmetric algorithm to obtain encrypted message information.
The encoding unit 704 is specifically configured to encode the encrypted message information based on an encoding rule to form an information area encoding pattern, encode the random number ciphertext based on the encoding rule to form an encryption area encoding pattern, encode the summary information based on the encoding rule to form a check area encoding pattern, encode the public key based on the encoding rule to form a watermark area encoding pattern, and arrange the information area encoding pattern, the encryption area encoding pattern, the check area encoding pattern and the watermark area encoding pattern according to respective partitions to obtain the corresponding anti-counterfeiting code.
The encoding unit 704 is further configured to re-partition the information area encoding pattern, the encryption area encoding pattern, the check area encoding pattern, and the watermark area encoding pattern after being arranged, so that the partition corresponding to the encoding pattern is different from the actually arranged partition, and re-arrange each encoding pattern of the re-arranged partition to obtain a corresponding anti-counterfeiting code, where each encoding pattern includes the information area encoding pattern, the encryption area encoding pattern, the check area encoding pattern, and the watermark area encoding pattern.
Fig. 8 is a schematic diagram showing an alternative structure of an anti-counterfeit decoding device according to an embodiment of the present disclosure, and will be described in terms of various parts.
In some embodiments, the security code decoding apparatus 900 includes a decoding unit 901, a first decryption unit 902, a second decryption unit 903, and a verification unit 904.
The decoding unit 901 is configured to obtain an information area coding pattern, an encryption area coding pattern, a check area coding pattern, and a watermark area coding pattern in the anti-counterfeit code, and decode the information into encrypted message information, a random number ciphertext, summary information, and a public key, respectively;
A first decryption unit 902, configured to decrypt the random number ciphertext based on a public key, to obtain a random number;
A second decryption unit 903, configured to decrypt the encrypted message information based on the random number, to obtain first message information;
And the verification unit 904 is configured to confirm the hash value of the first message information, compare the hash value with the summary information, and if the hash value of the first message information is consistent with the summary information, the first message information is not tampered.
The decoding unit 901 is specifically configured to determine an information area coding pattern, an encryption area coding pattern, a check area coding pattern and a watermark area coding pattern in the anti-counterfeiting code according to a coding pattern partitioning rule and an arrangement rule;
And respectively decoding the information area coding pattern, the encryption area coding pattern, the check area coding pattern and the watermark area coding pattern into encrypted message information, random number ciphertext, summary information and a public key based on a decoding rule.
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 alarm information.
According to embodiments of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
Fig. 9 shows a schematic block diagram of an example electronic device 800 that may be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 9, the electronic device 800 includes a computing unit 801 that 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 by a bus 804. An input/output (I/O) interface 805 is also connected to the bus 804.
Various 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 magnetic 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.
The computing unit 801 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 801 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as the security code generation method and/or the security code decoding method. For example, in some embodiments, the security code generation method and/or the security code decoding method may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as the storage unit 808. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 800 via the ROM 802 and/or the communication unit 809. When the computer program is loaded into RAM 803 and executed by computing unit 801, one or more steps of the security code generation method and/or the security code decoding method described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to perform the security code generation method and/or the security code decoding method in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include being implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be a special or general purpose programmable processor, operable to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here 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 a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user, for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback), and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can 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.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel or sequentially or in a different order, provided that the desired results of the technical solutions of the present disclosure are achieved, and are not limited herein.
Furthermore, the terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In the description of the present disclosure, the meaning of "a plurality" is two or more, unless explicitly defined otherwise.
The foregoing is merely specific embodiments of the disclosure, but the protection scope of the disclosure is not limited thereto, and any person skilled in the art can easily think about changes or substitutions within the technical scope of the disclosure, and it is intended to cover the scope of the disclosure. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410796999.9A CN118761432B (en) | 2024-06-19 | 2024-06-19 | Anti-counterfeiting code generation method, anti-counterfeiting code decoding method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410796999.9A CN118761432B (en) | 2024-06-19 | 2024-06-19 | Anti-counterfeiting code generation method, anti-counterfeiting code decoding method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN118761432A CN118761432A (en) | 2024-10-11 |
CN118761432B true CN118761432B (en) | 2025-03-07 |
Family
ID=92936859
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410796999.9A Active CN118761432B (en) | 2024-06-19 | 2024-06-19 | Anti-counterfeiting code generation method, anti-counterfeiting code decoding method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118761432B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107222501A (en) * | 2017-07-06 | 2017-09-29 | 中国电子科技集团公司第二十九研究所 | A kind of information interaction security transmission method and system based on the non-electromagnetic signal of message identification code |
CN109034333A (en) * | 2018-08-02 | 2018-12-18 | 武汉大学 | QR code dual anti-counterfeiting method based on rsa encryption and digital watermarking |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106452756B (en) * | 2016-11-08 | 2018-03-30 | 王栋 | Can the safe Quick Response Code construction verification method of off-line verification and device |
CN108596309B (en) * | 2018-04-24 | 2020-04-21 | 重庆大学 | QR code generation and verification method |
CN113077264B (en) * | 2020-01-06 | 2025-02-18 | 浙江甲骨文超级码科技股份有限公司 | A copyright protection method and system based on blockchain and timestamp technology |
US20230134651A1 (en) * | 2021-10-28 | 2023-05-04 | Akporefe Agbamu | Synchronized Identity, Document, and Transaction Management |
-
2024
- 2024-06-19 CN CN202410796999.9A patent/CN118761432B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107222501A (en) * | 2017-07-06 | 2017-09-29 | 中国电子科技集团公司第二十九研究所 | A kind of information interaction security transmission method and system based on the non-electromagnetic signal of message identification code |
CN109034333A (en) * | 2018-08-02 | 2018-12-18 | 武汉大学 | QR code dual anti-counterfeiting method based on rsa encryption and digital watermarking |
Also Published As
Publication number | Publication date |
---|---|
CN118761432A (en) | 2024-10-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP3673393B1 (en) | Identifying copyrighted material using embedded copyright information | |
Patel et al. | Image encryption using different techniques: A review | |
US11062000B2 (en) | Identifying copyrighted material using embedded copyright information | |
EP3673392B1 (en) | Copyright protection based on hidden copyright information | |
EP3662637B1 (en) | Identifying copyrighted material using embedded copyright information | |
US20230038922A1 (en) | Blockchain Implemented Data Hiding Solutions For Improvements In Secure Communication, Storage And Transmission Of Data | |
EP3673453B1 (en) | Identifying copyrighted material using copyright information embedded in tables | |
CN105405035B (en) | Method for judging authenticity of two-dimensional code electronic ticket based on external standard time | |
EP3673390B1 (en) | Identifying copyrighted material using embedded copyright information | |
CN111177666A (en) | Forensic document anti-counterfeiting and anti-tampering method and system based on fragile watermark | |
Anees et al. | A robust watermarking scheme for online multimedia copyright protection using new chaotic map | |
Kshirsagar et al. | Anatomized study of security solutions for multimedia: deep learning-enabled authentication, cryptography and information hiding | |
CN103220455A (en) | Apparatus and method for hiding secret information, and secret information restoring device and method | |
CN114880687A (en) | Document security protection method, device, electronic device and storage medium | |
JP5913041B2 (en) | Secret information concealment device, secret information restoration device, secret information concealment program, and secret information restoration program | |
CN113177214A (en) | Image publishing and auditing method, related device and computer program product | |
Lin et al. | A copyright protection scheme based on PDF | |
CN118761432B (en) | Anti-counterfeiting code generation method, anti-counterfeiting code decoding method and device | |
Shen et al. | A novel approach by applying image authentication technique on a digital document | |
Chaudhary et al. | An elucidation on steganography and cryptography | |
Lee et al. | The Usefulness Of Visual Cryptography Techniques: A Literature Review. | |
Vasilakis et al. | Copyright Protection on Electronic Books: Study and Design of a New Approach | |
CN118784314B (en) | Method and device for generating user unique identification | |
CN116366232B (en) | Digital asset processing method, device, equipment and medium based on quantum-resistant key | |
Herviana et al. | Implementation of Least Significant Bit Steganography to Secure Text Messages in Images |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |