Two-dimensional code generation method based on anti-counterfeiting encryption technology
Through the QR code generation method based on anti-counterfeiting encryption technology, the problem of degradation in the stability of QR code generation is solved. By adjusting the key expiration and unupdated ratio, configuration file backup frequency and encrypted data compression rate, the stability of QR code generation is ensured. The quality and quality reduce the probability of garbled code and the impact of data loss, and improve the generation speed.
Patent Information
- Application Number
- CN202411698631.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2024-12-24
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The problem of degradation in the stability of QR code generation in the prior art is mainly due to the incomplete processing of different data types in the encrypted data, resulting in erroneous encoding formats, resulting in the generation of garbled QR codes.
Using the QR code generation method based on anti-counterfeiting encryption technology, the QR code data is encrypted and anti-counterfeiting features are embedded through the encryption algorithm, and hash algorithm is used to verify, and the QR code graphics are optimized in combination with RIP technology, and the error words in the encrypted data are used. The variance of the savings proportion adjusts the expired and unupdated proportion of the key, the backup frequency of the configuration file, and the compression rate of the encrypted data to ensure the stability and quality of QR code generation.
It effectively reduces the probability of garbled code caused by incompatibility with QR code encoding, improves the stability and quality of QR code generation, reduces the impact of data loss, and speeds up the generation speed of QR codes.
Smart Images

Figure CN119180293A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of two-dimensional codes, and in particular to a two-dimensional code generation method based on anti-counterfeiting encryption technology. Background Art
[0002] In the prior art, the QR code, also known as the two-dimensional barcode, is a very popular encoding method on mobile devices. It can store more information and represent more data types than the traditional Bar Code. It uses black and white graphics on a two-dimensional plane to record data information based on certain specific geometric figures and rules. In the compilation of the code, the QR code cleverly uses the concept of the "0" and "1" bit stream that constitutes the internal logic basis of the computer, and uses several geometric shapes corresponding to the binary system to represent textual numerical information, which is automatically read by image input devices or photoelectric scanning devices to realize automatic information processing.
[0003] Chinese Patent Publication No.: CN118297091A discloses a method and system for generating and identifying deformed anti-counterfeiting QR codes based on AI image recognition, the method comprising: generating a QR code based on a QR code generation tool, simplifying the QR code data, and detecting it in real time to determine the fault tolerance range; randomly selecting at least one simplified dot matrix within the fault tolerance range, determining the printing ink shrinkage rule based on the simplified dot matrix, and updating the QR code; retaining and recording the updated QR code through a visual camera; when scanning the QR code, comparing the QR code with the retained record to determine the authenticity of the QR code. It can be seen that the method and system for generating and identifying deformed anti-counterfeiting QR codes based on AI image recognition have the problem that the QR code is easy to be copied, tampered with, and printed unclearly. Summary of the invention
[0004] To this end, the present invention provides a two-dimensional code generation method based on anti-counterfeiting encryption technology, which is used to overcome the problem in the prior art that the encrypted data may contain multiple data types, and the different data types in the encrypted data are not uniformly processed and converted into data types that meet the requirements of the two-dimensional code encoding, resulting in encoding format errors and thus reducing the stability of the two-dimensional code generation.
[0005] To achieve the above-mentioned purpose, the present invention provides a two-dimensional code generation method based on anti-counterfeiting encryption technology, comprising: using an encryption algorithm to encrypt two-dimensional code data to output encrypted data, and using the encryption algorithm to generate a key for encryption and decryption, encoding the original two-dimensional code and embedding the encrypted data, compressing the encryption algorithm and the key and storing them in a configuration file respectively, and updating the key when the key expires; embedding an anti-counterfeiting feature in the encoded original two-dimensional code and using a hash algorithm to verify the encrypted data, combining RIP technology to optimize the two-dimensional code graphic and then generate a two-dimensional code with an anti-counterfeiting feature; respectively obtaining the amount of error bytes in the encrypted data and the total amount of bytes in the encrypted data within several generation cycles; determining the generation stability of the two-dimensional code based on the variance of the proportion of error bytes in the encrypted data, wherein, if the generation stability does not meet the requirements, adjusting the proportion of keys that have expired and have not been updated, or, determining the generation quality of the two-dimensional code based on the proportion of lost data in the two-dimensional code data, if the generation quality does not meet the requirements, adjusting the backup frequency of the configuration file, or, adjusting the compression rate of the encrypted data based on the average delay time of generating the two-dimensional code.
[0006] Furthermore, the two-dimensional code includes a QR code, a PDF417 code and a data matrix code.
[0007] Further, determining the generation stability of the two-dimensional code includes:
[0008] Compare the variance of the proportion of error bytes in the encrypted data with a preset first variance;
[0009] If the variance of the proportion of the amount of error bytes in the encrypted data is greater than the preset first variance, it is determined that the generation stability of the QR code does not meet the requirements.
[0010] Further, determining the generation quality of the two-dimensional code includes:
[0011] Comparing the variance of the proportion of the amount of error bytes in the encrypted data with the preset first variance and the preset second variance respectively;
[0012] If the variance of the proportion of error bytes in the encrypted data is greater than the preset first variance and less than or equal to the preset second variance, it is preliminarily determined that the generation quality of the QR code does not meet the requirements, and whether the generation quality of the QR code meets the requirements is determined based on the proportion of lost data in the QR code data.
[0013] Furthermore, the ratio of keys that have expired and not been updated is adjusted, including:
[0014] Comparing the variance of the proportion of the amount of error bytes in the encrypted data with the preset second variance;
[0015] If the variance of the proportion of the amount of error bytes in the encrypted data is greater than a preset second variance, reducing the proportion of keys that have expired and have not been updated;
[0016] The reduction range of the key expired and unupdated ratio is determined by the difference between the variance of the proportion of error bytes in the encrypted data and a preset second variance.
[0017] Furthermore, the backup frequency of the configuration files is adjusted, including:
[0018] Compare the ratio of lost data in the two-dimensional code data with the preset first ratio and the preset second ratio respectively;
[0019] If the proportion of lost data in the two-dimensional code data is greater than the preset first proportion, it is determined that the generated quality of the two-dimensional code does not meet the requirements;
[0020] If the proportion of lost data in the two-dimensional code data is greater than the preset first proportion and less than or equal to the preset second proportion, increasing the backup frequency of the configuration file;
[0021] If the proportion of lost data in the QR code data is greater than the preset second proportion, it is preliminarily determined that the generation efficiency of the QR code does not meet the requirements, and whether the generation efficiency of the QR code meets the requirements is determined based on the average delay time of generating the QR code.
[0022] Furthermore, the proportion of lost data in the two-dimensional code data is the ratio of the lost data in the two-dimensional code data to the total data in the two-dimensional code data.
[0023] Furthermore, the increase range of the backup frequency of the configuration file is determined by the difference between the ratio of the amount of lost data in the two-dimensional code data and a preset first ratio.
[0024] Furthermore, the compression rate of the encrypted data is adjusted, including:
[0025] Comparing the average delay time of generating the QR code with the preset delay time;
[0026] If the average delay time for generating the two-dimensional code is greater than the preset delay time, it is determined that the generation efficiency of the two-dimensional code does not meet the requirements, and the compression rate of the encrypted data is increased.
[0027] Furthermore, the increase in the compression rate of the encrypted data is determined by the difference between the average delay time for generating the QR code and the preset delay time.
[0028] Compared with the prior art, the beneficial effect of the present invention lies in that the method of the present invention adjusts the proportion of expired and unupdated keys according to the variance of the proportion of erroneous bytes in the encrypted data. Since the encrypted data may contain multiple data types, the different data types in the encrypted data are not uniformly processed and converted into data types that meet the requirements of the two-dimensional code encoding, resulting in encoding format errors, thereby causing garbled codes to appear in the generated two-dimensional code. By reducing the proportion of expired and unupdated keys, it can be ensured that the format and encryption method of the encrypted data are better matched with the requirements of the two-dimensional code encoding, and the probability of garbled codes caused by the incompatibility of the encrypted data and the two-dimensional code encoding can be effectively reduced, thereby improving the stability and quality of the two-dimensional code generation. The backup frequency of the configuration file is adjusted according to the proportion of lost data in the two-dimensional code data. Since the software used to generate the two-dimensional code may update the configuration file when it is automatically upgraded, When performing operations such as overwriting, migration or format conversion, data loss occurs when overwriting the configuration file, which makes the software unable to read the parameters in the configuration file normally. By increasing the backup frequency of the configuration file, the impact of data loss can be reduced, and the time when the QR code generation fails due to configuration file problems can be reduced. The compression rate of encrypted data is adjusted according to the average delay time of generating the QR code. Since the generation of the QR code requires the storage of encrypted data, encoded intermediate data and graphic data in the memory, too much data leads to insufficient memory. Frequent data exchange will make the QR code generation process slow, resulting in delays in graphics drawing. By increasing the compression rate of encrypted data, the storage space of data in the memory can be effectively reduced, the time consumption caused by data exchange can be reduced, the QR code generation speed can be accelerated, the graphics drawing delay can be reduced, and the stability of QR code generation can be improved.
[0029] Furthermore, the method of the present invention adjusts the proportion of expired and unrenewed keys by setting a preset first variance and a preset second variance. Since the encrypted data may contain multiple data types, the different data types in the encrypted data are not uniformly processed and converted into data types that meet the requirements of the two-dimensional code encoding, resulting in encoding format errors, which in turn cause garbled characters in the generated two-dimensional code. By reducing the proportion of expired and unrenewed keys, it can be ensured that the format and encryption method of the encrypted data are better matched with the two-dimensional code encoding requirements, which can effectively reduce the probability of garbled characters caused by the incompatibility of the encrypted data and the two-dimensional code encoding, improve the stability and quality of the two-dimensional code generation, and further improve the stability of the two-dimensional code generation.
[0030] Furthermore, the method of the present invention adjusts the backup frequency of the configuration file by setting a preset first ratio and a preset second ratio. Since the software used to generate the QR code may overwrite, migrate or convert the configuration file during automatic upgrading, data loss may occur when the configuration file is overwritten, thereby making it impossible for the software to read the parameters in the configuration file normally. By increasing the backup frequency of the configuration file, the impact of data loss can be reduced, and the time for QR code generation failures due to configuration file problems can be reduced, thereby further improving the stability of QR code generation.
[0031] Furthermore, the method of the present invention adjusts the compression rate of encrypted data by setting a preset delay time. Since the generation of a QR code requires storing encrypted data, encoded intermediate data, and graphic data in the memory, too much data leads to insufficient memory, and frequent data exchange will make the QR code generation process slow, causing delays in graphics drawing. By increasing the compression rate of encrypted data, the storage space of data in the memory can be effectively reduced, the time consumption caused by data exchange can be reduced, the QR code generation speed can be accelerated, the graphics drawing delay can be reduced, and the generation stability of the QR code can be further improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 This is an overall flow chart of a method for generating a two-dimensional code based on anti-counterfeiting encryption technology according to an embodiment of the present invention;
[0033] Figure 2 It is a logic flow chart of a two-dimensional code generation method based on anti-counterfeiting encryption technology according to an embodiment of the present invention;
[0034] Figure 3 A specific flow chart of a process for adjusting the ratio of expired and unupdated keys according to an embodiment of the present invention;
[0035] Figure 4 The present invention is a specific flow chart of a process for adjusting the backup frequency of a configuration file according to an embodiment of the present invention. DETAILED DESCRIPTION
[0036] In order to make the objects and advantages of the present invention more clearly understood, the present invention is further described below in conjunction with embodiments; it should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0037] The preferred embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.
[0038] It should be noted that, in the description of the present invention, terms such as "up", "down", "left", "right", "inside" and "outside" indicating directions or positional relationships are based on the directions or positional relationships shown in the drawings. This is merely for the convenience of description and does not indicate or imply that the device or element must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it cannot be understood as a limitation on the present invention.
[0039] In addition, it should be noted that in the description of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0040] See also Figure 1 , Figure 2 , Figure 3 as well as Figure 4 As shown, they are respectively an overall flow chart of a two-dimensional code generation method based on anti-counterfeiting encryption technology according to an embodiment of the present invention, a logic flow chart, a specific flow chart of a process for adjusting the ratio of expired and unupdated keys, and a specific flow chart of a process for adjusting the backup frequency of a configuration file. A two-dimensional code generation method based on anti-counterfeiting encryption technology according to the present invention comprises:
[0041] Step S1, encrypting the two-dimensional code data using an encryption algorithm to output encrypted data, and using the encryption algorithm to generate a key for encryption and decryption, encoding the original two-dimensional code and embedding the encrypted data, compressing the encryption algorithm and the key and storing them in a configuration file respectively, and updating the key when the key expires;
[0042] Step S2, embedding an anti-counterfeiting feature in the encoded original two-dimensional code and verifying the encrypted data using a hash algorithm, optimizing the two-dimensional code graphic in combination with RIP technology to generate a two-dimensional code with an anti-counterfeiting feature;
[0043] Step S3, respectively obtaining the amount of error bytes in the encrypted data and the total amount of bytes in the encrypted data in several generation cycles;
[0044] Step S4, determining the generation stability of the QR code based on the variance of the proportion of error bytes in the encrypted data;
[0045] Step S5: if the generation stability does not meet the requirement, the ratio of expired and unrenewed keys is adjusted, or the generation quality of the QR code is determined based on the ratio of lost data in the QR code data;
[0046] Step S6: If the generation quality does not meet the requirements, the backup frequency of the configuration file is adjusted, or the compression rate of the encrypted data is adjusted based on the average delay time of generating the QR code.
[0047] Specifically, encryption algorithms include AES algorithm, DES algorithm, SHA-256 algorithm, etc.
[0048] Specifically, the QR code data includes the product serial number, product name, product production time, etc.
[0049] Specifically, the encrypted data includes the encrypted serial number of the product, the encrypted model number of the product, and the encrypted batch number of the product.
[0050] Specifically, the original QR code is a QR code that only contains basic product information or simple identification information before undergoing anti-counterfeiting encryption processing.
[0051] Specifically, the configuration file includes an encryption algorithm, an encoding mode of the QR code, and a size of the QR code.
[0052] Specifically, anti-counterfeiting features include data encryption anti-counterfeiting, digital signature anti-counterfeiting, and the addition of special graphic elements.
[0053] Specifically, the process of using the hash algorithm to verify the encrypted data is as follows: using the selected hash algorithm to calculate the collected product-related data that needs to be encrypted, converting it into a fixed-length hash value, and storing the generated hash value together with the encrypted product data in the corresponding position of the QR code. When scanning the QR code with anti-counterfeiting encryption information, first extract the encrypted data and the previously stored hash value from the QR code, and use the same hash algorithm as when generating the QR code to calculate the decrypted product data again to obtain a new hash value, and compare the recalculated hash value with the original hash value extracted from the QR code. If the two hash values are exactly the same, it can be considered that the encrypted data has not been tampered with after the QR code is generated. If the two hash values are different, it means that the data may have been tampered with.
[0054] Specifically, RIP technology interprets various graphics, images and text information in the digital pages produced in the computer into dot matrix information that can be recorded by printers, imagesetters or other output devices, making the edges of the generated two-dimensional code graphics clearer.
[0055] Specifically, the QR code generated in the present technical solution is a universal QR code, that is, the QR code can be recognized by any APP with a "scan" function, and there is no need to download a special APP for recognition.
[0056] Specifically, the ratio of expired and unupdated keys is the ratio of the number of keys that have expired but have not been updated to the total number of keys.
[0057] In implementation, the method of the present invention adjusts the proportion of expired and unrenewed keys according to the variance of the proportion of erroneous bytes in the encrypted data. Since the encrypted data may contain multiple data types, the different data types in the encrypted data are not uniformly processed and converted into data types that meet the requirements of the two-dimensional code encoding, resulting in encoding format errors, which in turn cause garbled characters in the generated two-dimensional code. By reducing the proportion of expired and unrenewed keys, it can be ensured that the format and encryption method of the encrypted data are better matched with the two-dimensional code encoding requirements, and the probability of garbled characters caused by the incompatibility of the encrypted data and the two-dimensional code encoding can be effectively reduced, thereby improving the stability and quality of the two-dimensional code generation. The backup frequency of the configuration file is adjusted according to the proportion of lost data in the two-dimensional code data. Since the software used to generate the two-dimensional code may overwrite and migrate the configuration file when it is automatically upgraded, Or format conversion and other operations, data loss occurs when overwriting the configuration file, so that the software cannot read the parameters in the configuration file normally. By increasing the backup frequency of the configuration file, the impact of data loss can be reduced, and the time when the QR code generation fails due to configuration file problems can be reduced. The compression rate of the encrypted data is adjusted according to the average delay time of generating the QR code. Since the generation of the QR code requires the storage of encrypted data, encoded intermediate data, and graphic data in the memory, too much data leads to insufficient memory. Frequent data exchange will make the QR code generation process slow, resulting in delays in graphics drawing. By increasing the compression rate of the encrypted data, the storage space of the data in the memory can be effectively reduced, the time consumption caused by data exchange can be reduced, the QR code generation speed can be accelerated, the graphics drawing delay can be reduced, and the stability of QR code generation can be improved.
[0058] Specifically, the two-dimensional code includes a QR code, a PDF417 code and a data matrix code.
[0059] Specifically, the two-dimensional code generation method based on anti-counterfeiting encryption technology can also be used to generate barcodes.
[0060] Specifically, determining the generation stability of the two-dimensional code includes:
[0061] Obtaining the amount of error bytes in the encrypted data and the total amount of bytes in the encrypted data in several generation cycles respectively, and calculating the variance of the percentage of error bytes in the encrypted data;
[0062] Comparing the variance of the proportion of the amount of error bytes in the encrypted data with a preset first variance;
[0063] If the variance of the proportion of the amount of error bytes in the encrypted data is greater than the preset first variance, it is determined that the generation stability of the QR code does not meet the requirements.
[0064] Specifically, determining the generation quality of the two-dimensional code includes:
[0065] Comparing the variance of the proportion of the amount of error bytes in the encrypted data with the preset first variance and the preset second variance respectively;
[0066] If the variance of the proportion of error bytes in the encrypted data is greater than the preset first variance and less than or equal to the preset second variance, it is preliminarily determined that the generation quality of the QR code does not meet the requirements, and whether the generation quality of the QR code meets the requirements is determined based on the proportion of lost data in the QR code data.
[0067] It can be understood that the three intervals corresponding to the preset first variance and the preset second variance correspond to three situations respectively:
[0068] The first interval is when the variance of the proportion of error bytes in the encrypted data is less than or equal to the preset first variance, corresponding to the situation where the stability of the generated QR code meets the requirements;
[0069] The second interval is when the variance of the proportion of the amount of error bytes in the encrypted data is greater than the preset first variance and less than or equal to the preset second variance. When the software used to generate the QR code is automatically upgraded, the configuration file may be overwritten, migrated, or format converted. When the configuration file is overwritten, data is lost, so that the software cannot read the parameters in the configuration file normally.
[0070] The third interval is when the variance of the proportion of erroneous bytes in the encrypted data is greater than the preset second variance. The corresponding encrypted data may contain multiple data types. The different data types in the encrypted data are not processed uniformly and converted into data types that meet the requirements of the QR code encoding, resulting in an encoding format error.
[0071] In practice, the preset first variance is generally selected in the range of [0.02, 0.04], and the preset second variance is generally selected in the range of [0.05, 0.07].
[0072] Preferably, the preferred embodiment of the preset first variance is 0.03, and the preferred embodiment of the preset second variance is 0.06.
[0073] Specifically, the variance of the proportion of error bytes in the encrypted data is the variance of the proportion of error bytes in the encrypted data within several generation cycles. The calculation method of the variance of the proportion of error bytes in the encrypted data is a conventional technical means well known to those skilled in the art, and therefore the calculation process of the variance of the proportion of error bytes in the encrypted data will not be repeated here.
[0074] Specifically, the proportion of erroneous bytes in the encrypted data is the ratio of the erroneous bytes in the encrypted data to the total bytes in the encrypted data in a number of generation cycles.
[0075] In implementation, the method of the present invention determines the generation stability of the QR code by setting a preset first variance and a preset second variance, thereby reducing the impact of the decrease in the generation accuracy of the QR code due to inaccurate determination of the generation stability of the QR code, and further improving the generation stability of the QR code.
[0076] Specifically, the proportion of keys that have expired and have not been updated is adjusted, including:
[0077] Comparing the variance of the proportion of the amount of error bytes in the encrypted data with the preset second variance;
[0078] If the variance of the proportion of the amount of error bytes in the encrypted data is greater than a preset second variance, reducing the proportion of keys that have expired and have not been updated;
[0079] The reduction range of the key expired and unupdated ratio is determined by the difference between the variance of the proportion of error bytes in the encrypted data and a preset second variance.
[0080] Specifically, when the difference between the variance of the proportion of error bytes in the encrypted data and the preset second variance is within 0.03, the proportion of expired keys that have not been updated is reduced to 0.9 times the original; when the difference between the variance of the proportion of error bytes in the encrypted data and the preset second variance exceeds 0.03, the proportion of expired keys that have not been updated is reduced by 0.03 for every 0.02 that exceeds it. For example, the difference between the variance of the proportion of error bytes in the encrypted data and the preset second variance is 0.07, the current proportion of expired keys that have not been updated is 0.2, and the reduced proportion of expired keys that have not been updated is 0.2×0.9-0.03×2=0.12.
[0081] In implementation, the method of the present invention adjusts the proportion of expired and unrenewed keys by setting a preset first variance and a preset second variance. Since the encrypted data may contain multiple data types, the different data types in the encrypted data are not uniformly processed and converted into data types that meet the requirements of the two-dimensional code encoding, resulting in encoding format errors, which in turn cause garbled codes in the generated two-dimensional code. By reducing the proportion of expired and unrenewed keys, it can be ensured that the format and encryption method of the encrypted data are better matched with the two-dimensional code encoding requirements, which can effectively reduce the probability of garbled codes caused by the incompatibility of the encrypted data and the two-dimensional code encoding, improve the stability and quality of the two-dimensional code generation, and further improve the stability of the two-dimensional code generation.
[0082] Specifically, the backup frequency of the configuration files is adjusted, including:
[0083] The amount of lost data in the QR code data and the total amount of data in the QR code data are obtained respectively, and the proportion of the amount of lost data in the QR code data is calculated;
[0084] Compare the ratio of lost data in the two-dimensional code data with the preset first ratio and the preset second ratio respectively;
[0085] If the proportion of lost data in the two-dimensional code data is greater than the preset first proportion, it is determined that the generated quality of the two-dimensional code does not meet the requirements;
[0086] If the proportion of lost data in the two-dimensional code data is greater than the preset first proportion and less than or equal to the preset second proportion, increasing the backup frequency of the configuration file;
[0087] If the proportion of lost data in the QR code data is greater than the preset second proportion, it is preliminarily determined that the generation efficiency of the QR code does not meet the requirements, and whether the generation efficiency of the QR code meets the requirements is determined based on the average delay time of generating the QR code.
[0088] It can be understood that the three intervals corresponding to the preset first proportion and the preset second proportion correspond to three situations respectively:
[0089] The first interval is when the proportion of lost data in the QR code data is less than or equal to the preset first proportion, corresponding to the situation where the quality of generated QR code meets the requirements;
[0090] The second interval is when the proportion of lost data in the QR code data is greater than the preset first proportion and less than or equal to the preset second proportion. When the software used to generate the QR code is automatically upgraded, the configuration file may be overwritten, migrated, or format converted. When the configuration file is overwritten, data is lost, so that the software cannot read the parameters in the configuration file normally.
[0091] The third interval is when the proportion of lost data in the QR code data is greater than the preset second proportion. The corresponding QR code generation needs to store encrypted data, encoded intermediate data, and graphic data in the memory. Too much data leads to insufficient memory, and frequent data exchange will slow down the QR code generation process and cause delays in graphics drawing.
[0092] In practice, the preset first ratio is generally selected in the range of [0.03, 0.05], and the preset second ratio is generally selected in the range of [0.06, 0.08].
[0093] Preferably, the preferred embodiment of the preset first ratio is 0.04, and the preferred embodiment of the preset second ratio is 0.07.
[0094] In implementation, the method of the present invention determines the generation quality of the QR code by setting a preset first ratio and a preset second ratio, thereby reducing the impact of the decreased generation stability of the QR code due to inaccurate determination of the generation quality of the QR code, and further improving the generation stability of the QR code.
[0095] Specifically, the ratio of the amount of lost data in the two-dimensional code data is the ratio of the amount of lost data in the two-dimensional code data to the total amount of data in the two-dimensional code data.
[0096] Specifically, the increase range of the backup frequency of the configuration file is determined by the difference between the ratio of the amount of lost data in the two-dimensional code data and a preset first ratio.
[0097] Specifically, when the difference between the proportion of lost data in the QR code data and the preset first proportion is within 0.02, the backup frequency of the configuration file is increased to 1.2 times the original; when the difference between the proportion of lost data in the QR code data and the preset first proportion exceeds 0.02, the backup frequency of the configuration file increases by 2 times / hour for every 0.02 exceeding it. For example, the difference between the proportion of lost data in the QR code data and the preset first proportion is 0.06, the current backup frequency of the configuration file is 5 times / hour, and the increased backup frequency of the configuration file is 5×1.2+2×2=10 times / hour.
[0098] In implementation, the method of the present invention adjusts the backup frequency of the configuration file by setting a preset first ratio and a preset second ratio. Since the software used to generate the QR code may overwrite, migrate or convert the configuration file during automatic upgrading, data loss may occur when the configuration file is overwritten, making it impossible for the software to read the parameters in the configuration file normally. By increasing the backup frequency of the configuration file, the impact of data loss can be reduced, the time of QR code generation failure due to configuration file problems can be reduced, and the stability of QR code generation can be further improved.
[0099] Specifically, the compression rate of encrypted data is adjusted, including:
[0100] Obtain the delay time of generating the QR code in several generation cycles, and calculate the average delay time of generating the QR code;
[0101] Comparing the average delay time of generating the QR code with the preset delay time;
[0102] If the average delay time for generating the two-dimensional code is greater than the preset delay time, it is determined that the generation efficiency of the two-dimensional code does not meet the requirements, and the compression rate of the encrypted data is increased.
[0103] It can be understood that the two intervals corresponding to the preset delay time correspond to two situations:
[0104] The first interval is when the average delay time for generating the QR code is less than or equal to the preset delay time, corresponding to the situation where the generation efficiency of the QR code meets the requirements;
[0105] The second interval is when the average delay time for generating a QR code is greater than the preset delay time. The corresponding QR code generation requires storing encrypted data, encoded intermediate data, and graphic data in the memory. Too much data leads to insufficient memory, and frequent data exchange slows down the QR code generation process, resulting in delays in graphics drawing.
[0106] In practice, the preset delay time is generally selected in the range of [50ms, 70ms]. Preferably, the preset delay time is 60ms.
[0107] Specifically, the average delay time for generating a two-dimensional code is the ratio of the total delay time for generating the two-dimensional code in a number of generation cycles to the number of generation cycles.
[0108] In implementation, the method of the present invention determines the generation efficiency of the QR code by setting a preset delay time, thereby reducing the impact of the decreased generation stability of the QR code due to inaccurate determination of the generation efficiency of the QR code, and further improving the generation stability of the QR code.
[0109] Specifically, the increase in the compression rate of the encrypted data is determined by the difference between the average delay time for generating the two-dimensional code and the preset delay time.
[0110] Specifically, when the difference between the average delay time for generating the QR code and the preset delay time is within 50ms, the compression rate of the encrypted data increases to 1.1 times the original; when the difference between the average delay time for generating the QR code and the preset delay time exceeds 50ms, the compression rate of the encrypted data increases by 5% for every 10ms exceeding it. For example, the difference between the average delay time for generating the QR code and the preset delay time is 70ms, the current compression rate of the encrypted data is 50%, and the compression rate of the encrypted data after the increase is 50%×1.1+5%×2=65%.
[0111] In implementation, the method of the present invention adjusts the compression rate of encrypted data by setting a preset delay time. Since the generation of a QR code requires storing encrypted data, encoded intermediate data, and graphic data in the memory, too much data leads to insufficient memory, and frequent data exchange will slow down the QR code generation process and cause delays in graphic drawing. By increasing the compression rate of encrypted data, the storage space of the data in the memory can be effectively reduced, the time consumption caused by data exchange can be reduced, the QR code generation speed can be accelerated, the graphic drawing delay can be reduced, and the generation stability of the QR code can be further improved.
[0112] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
Claims
1. A two-dimensional code generation method based on anti-counterfeiting encryption technology, characterized in that: include: Encrypt the two-dimensional code data using an encryption algorithm to output encrypted data, generate a key for encryption and decryption using the encryption algorithm, encode the original two-dimensional code and embed the encrypted data, compress the encryption algorithm and the key and store them in a configuration file respectively, and update the key when the key expires; Embed anti-counterfeiting features in the encoded original two-dimensional code and use a hash algorithm to verify the encrypted data, and optimize the two-dimensional code graphics in combination with RIP technology to generate a two-dimensional code with anti-counterfeiting features; respectively obtaining the amount of error bytes in the encrypted data and the total amount of bytes in the encrypted data in a number of generation cycles; The stability of QR code generation is determined based on the variance of the proportion of error bytes in the encrypted data, where: If the generation stability does not meet the requirements, the ratio of expired keys that have not been updated is adjusted, or the generation quality of the QR code is determined based on the ratio of lost data in the QR code data. If the generation quality does not meet the requirements, the backup frequency of the configuration file is adjusted, or the compression rate of the encrypted data is adjusted based on the average delay time of generating the QR code.
2. The two-dimensional code generation method based on anti-counterfeiting encryption technology according to claim 1 is characterized in that: The two-dimensional code includes a QR code, a PDF417 code and a data matrix code.
3. The two-dimensional code generation method based on anti-counterfeiting encryption technology according to claim 1 is characterized in that: Determining the generation stability of the two-dimensional code includes: Compare the variance of the proportion of error bytes in the encrypted data with a preset first variance; If the variance of the proportion of the amount of error bytes in the encrypted data is greater than the preset first variance, it is determined that the generation stability of the QR code does not meet the requirements.
4. The two-dimensional code generation method based on anti-counterfeiting encryption technology according to claim 3 is characterized in that: Determining the quality of the generated QR code includes: Comparing the variance of the proportion of the amount of error bytes in the encrypted data with the preset first variance and the preset second variance respectively; If the variance of the proportion of error bytes in the encrypted data is greater than the preset first variance and less than or equal to the preset second variance, it is preliminarily determined that the generation quality of the QR code does not meet the requirements, and whether the generation quality of the QR code meets the requirements is determined based on the proportion of lost data in the QR code data.
5. The two-dimensional code generation method based on anti-counterfeiting encryption technology according to claim 4 is characterized in that: Adjust the ratio of expired keys that have not been renewed, including: Comparing the variance of the proportion of the amount of error bytes in the encrypted data with the preset second variance; If the variance of the proportion of the amount of error bytes in the encrypted data is greater than a preset second variance, reducing the proportion of keys that have expired and have not been updated; The reduction range of the key expired and unupdated ratio is determined by the difference between the variance of the proportion of error bytes in the encrypted data and a preset second variance.
6. The two-dimensional code generation method based on anti-counterfeiting encryption technology according to claim 4 is characterized in that: Adjust the backup frequency of the configuration files, including: Compare the ratio of lost data in the two-dimensional code data with the preset first ratio and the preset second ratio respectively; If the proportion of lost data in the two-dimensional code data is greater than the preset first proportion, it is determined that the generated quality of the two-dimensional code does not meet the requirements; If the proportion of lost data in the two-dimensional code data is greater than the preset first proportion and less than or equal to the preset second proportion, increasing the backup frequency of the configuration file; If the proportion of lost data in the QR code data is greater than the preset second proportion, it is preliminarily determined that the generation efficiency of the QR code does not meet the requirements, and whether the generation efficiency of the QR code meets the requirements is determined based on the average delay time of generating the QR code.
7. The two-dimensional code generation method based on anti-counterfeiting encryption technology according to claim 6 is characterized in that: The ratio of the amount of lost data in the two-dimensional code data is the ratio of the amount of lost data in the two-dimensional code data to the total amount of data in the two-dimensional code data.
8. The two-dimensional code generation method based on anti-counterfeiting encryption technology according to claim 7 is characterized in that: The increase range of the backup frequency of the configuration file is determined by the difference between the ratio of the amount of lost data in the two-dimensional code data and a preset first ratio.
9. The two-dimensional code generation method based on anti-counterfeiting encryption technology according to claim 8 is characterized in that: Adjust the compression rate of encrypted data, including: Comparing the average delay time of generating the QR code with the preset delay time; If the average delay time for generating the two-dimensional code is greater than the preset delay time, it is determined that the generation efficiency of the two-dimensional code does not meet the requirements, and the compression rate of the encrypted data is increased.
10. The two-dimensional code generation method based on anti-counterfeiting encryption technology according to claim 9, characterized in that: The increase in the compression rate of the encrypted data is determined by the difference between the average delay time for generating the two-dimensional code and the preset delay time.
Citation Information
Patent Citations
Two-dimensional code anti-counterfeiting method based on near infrared spectrum analysis
CN103646265A
Certificate identification method and device based on two-dimensional code
CN110020540A
Traceability anti-counterfeiting system based on Internet information
CN116385026A
Electronic contract maintenance management method and system based on big data
CN118760853A
Generating method, verifying method for electronic bill with Anti-fake two dimension (2D) code and system for same
US20160055552A1
Cited By
Anti-counterfeiting two-dimensional code generation method based on dynamic encryption
CN119940386A
