A QR code encryption and decryption method and system based on chaos theory and AES algorithm
By employing a QR code encryption and decryption method based on chaos theory and the AES algorithm, and utilizing improved mapping and key sequence generation techniques, the balance between security and decoding complexity in existing QR code encryption methods is resolved, achieving a highly secure and efficient information encryption and decryption process.
Patent Information
- Application Number
- CN202411238789.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2026-01-13
- Estimated Expiration
- 2044-09-05
AI Technical Summary
Existing QR code encryption methods struggle to balance security and decoding complexity, and pose risks of information leakage or tampering, especially when standard recognition devices cannot decode encrypted QR code images.
A QR code encryption and decryption method based on chaos theory and AES algorithm is adopted. A key sequence is generated by improving Logistic mapping and Chebyshev mapping, and the plaintext information is encrypted by combining AES encryption algorithm. The ciphertext is then converted into a QR code, and the same key sequence is used for decryption.
It effectively reduces the problem of information leakage or tampering caused by QR codes, improves the security of encryption and the complexity of decoding, and ensures the integrity and confidentiality of information.
Smart Images

Figure CN119094102B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of QR code encryption and decryption, and in particular to a QR code encryption and decryption method and system based on chaos theory and AES algorithm. BACKGROUND
[0002] QR code (Quick Response Code) is a high-efficiency two-dimensional bar code system developed by Denso Wave Company of Japan in 1994. It can be quickly scanned and read, hence the name "Quick Response". The design of QR code aims to provide high-speed reading capability, large data capacity and powerful error correction function, so that it can perform outstandingly in various application scenarios.
[0003] Main components of QR code:
[0004] 1. Functional pattern. Functional pattern includes position detection pattern, separator, positioning pattern and correction pattern, etc. These elements help the decoder to identify the direction, size and version of the QR code, and correct the distortion that may occur during scanning.
[0005] 2. Encoding area. The encoding area contains format information, version information, data and error correction code; the format information defines the level of error correction and the mask mode used; the version information indicates the size and capacity of the QR code; the data and error correction code are the actual stored information and the encoding used for error recovery.
[0006] The encoding process of QR code is as follows:
[0007] (1) Data analysis and selection of encoding mode: according to the type of input data (such as numbers, alphanumeric, binary, etc.), select the appropriate encoding mode for conversion.
[0008] (2) Error correction coding: use Reed-Solomon error correction algorithm to generate error correction code, to ensure that the original data can be recovered after a certain level of physical damage.
[0009] (3) Construct the final information: arrange the data code and error correction code in the matrix, and fill as needed to ensure the integrity of the symbol.
[0010] (4) Apply mask and arrange module: apply mask to ensure uniform distribution of black and white modules in the QR code, avoiding patterns that are not friendly to scanners.
[0011] (5) Add format and version information: finally, add format information and version information to the specified position in the QR code, complete the construction of the entire symbol.
[0012] The decoding process of QR code is the reverse process of the encoding process, and the steps are as follows:
[0013] (1) Image recognition and module reading: The scanner first recognizes the image of the QR code and reads the depth module to obtain the encoded information.
[0014] (2) Extracting format and version information: Extracting format information and version information from the QR code, which is crucial for subsequent data parsing.
[0015] (3) Removing mask and error correction: Removing the mask effect and using error correction code to detect and correct possible errors.
[0016] (4) Data parsing: According to the initial encoding mode, the data code is translated back to the original data form, realizing the complete recovery of data.
[0017] QR codes are widely used in product tracking, advertising, mobile payments, and personal identity verification due to their efficiency and flexibility. With the popularity of smartphones and mobile devices, QR codes have become more widely used, providing great convenience for people's daily life and work.
[0018] There are three common QR code encryption methods:
[0019] The first method is to use encryption algorithms to encrypt the plaintext information first, and then use QR code generation software to generate QR codes from the encrypted ciphertext information. This method is easy to implement and generates a relatively standard QR code, which can encrypt the QR code information without damaging the QR code image.
[0020] The second method is to encrypt the QR image after generating the QR code image, which indirectly realizes information encryption. This method has certain limitations. If the QR code image is encrypted using image encryption algorithms, the encrypted image will be unpredictable and no longer have the symbol characteristics of QR codes, and standard QR recognition devices cannot decode the information. This method greatly reduces the value of encrypted QR codes and is only suitable for special scenarios.
[0021] The third method is to combine the encoding principles and manufacturing processes of QR codes for encryption research. The encryption position can be selected between information encoding and error correction encoding, integrated into the error correction encoding process, or after error correction encoding before generating the QR code image. Compared with the first two methods, the third method has the best encryption effect and the highest security, but it is also the most complex to implement. Although it increases the difficulty of cracking, it also increases the complexity of decoding, and the deeper the encoding, the more aspects need to be considered, and the higher the requirements for encryption algorithms.
[0022] The present application considers on the basis of the first method, combined with chaotic mapping, designs a QR code encryption and decryption method and system based on chaos theory and AES algorithm. SUMMARY
[0023] The present application aims at the needs and deficiencies of the current technology development, provides a QR code encryption and decryption method and system based on chaos theory and AES algorithm, to effectively reduce the information disclosure or information tampering problem caused by QR code through increasing encryption processing.
[0024] In the first aspect, the present application provides a QR code encryption and decryption method based on chaos theory and AES algorithm, which solves the above technical problems by adopting the following technical solutions:
[0025] A QR code encryption and decryption method based on chaos theory and AES algorithm, which includes QR code encryption process and QR code decryption process;
[0026] (1) QR code encryption process
[0027] (1.1) Obtain the plaintext information to be generated QR code, calculate the complete group number g containing 128 bits and the byte number r contained in the last incomplete group according to the total byte number of the plaintext information;
[0028] (1.2) Obtain the current system time as a random seed, and the initial parameters of the improved logistic mapping and Chebyshev mapping generated by the pseudo-random generator;
[0029] (1.3) According to the calculation result of step (1.1), the plaintext information is grouped to obtain g plaintext blocks containing 128 bits and 1 plaintext block less than 128 bits;
[0030] (1.4) Respectively iterate the improved Logistic mapping and Chebyshev mapping, remove the transient influence caused by the initial condition of chaotic system, and realize the discretization of chaotic sequence;
[0031] (1.5) Through the iteration and result binarization of the improved Logistic mapping and Chebyshev mapping, two 128-bit binary sequences are generated; through the XOR operation, a 128-bit initial key sequence for AES encryption is obtained; repeat this process g+r times, that is, g+r 128-bit initial key sequences are obtained;
[0032] (1.6) using the g+r initial 128-bit key sequences obtained in step (1.5), AES encrypts each of the g 128-bit plaintext blocks obtained in step (1.3) to obtain corresponding ciphertext blocks; for the 1 plaintext block with less than 128 bits obtained in step (1.3), 8r bits are randomly cut from the g+r initial 128-bit key sequences, and bitwise XOR operation is performed with the bytes contained in the plaintext block to obtain the remaining ciphertext; the foregoing ciphertext blocks are merged one by one, and the remaining ciphertext is connected to obtain the ciphertext encrypted by the improved AES algorithm;
[0033] (1.7) converting the ciphertext encrypted by the improved AES algorithm into Base64 code to obtain the final ciphertext information;
[0034] (1.8) saving the g+r initial 128-bit key sequences and the final ciphertext information in the database;
[0035] (1.9) converting the final ciphertext information into a QR code to complete the entire encryption and coding process;
[0036] (2) QR code decryption process
[0037] (2.1) obtaining the g+r initial 128-bit key sequences and the encrypted ciphertext information from the database;
[0038] (2.2) Base64 decoding the ciphertext information to restore it to binary data;
[0039] (2.3) using the same AES algorithm and the corresponding initial key sequence as in the encryption process to decrypt each ciphertext block to obtain the original plaintext block;
[0040] (2.4) for the last ciphertext block with less than 128 bits, 8r bits are first randomly cut from the g+r initial 128-bit key sequences, and then bitwise XOR operation is performed with the bytes contained in the ciphertext block to obtain the remaining plaintext;
[0041] (2.5) merging all the decrypted plaintext blocks to obtain the complete plaintext information.
[0042] Optionally, after obtaining the plaintext information to be generated into a QR code in step (1.1), first, the character encoding mode is selected according to the type and content of the plaintext information, then the plaintext information is converted into binary data according to the selected encoding mode, and finally the length of the converted data is counted to obtain the total number of bytes of the plaintext information.
[0043] Optionally, in step (1.2), the pseudo-random generator generates the initial parameter x0 of the improved logistic mapping and the initial parameter y0 of the Chebyshev mapping based on the current time of the system;
[0044] The improved logistic map has the form x n+1 = 1 - μ * x n 2 where n is a natural number, x n represents a chaotic variable, -1 < x n < 1, and μ represents a control parameter, 1 < μ ≤ 2; when the control parameter μ is set to 2, the improved logistic map is in a full-mapping chaotic state;
[0045] The Chebyshev map has the form y n+1 = cos(k * arccos(y n )), where n is a natural number, y n represents a chaotic variable, -1 ≤ y n ≤ 1, and k represents a control parameter; when the control parameter k takes an integer value and is not less than the value 2, the Chebyshev map enters a chaotic state, and the values of iterations thereof are uniformly mapped to the interval [-1, 1].
[0046] Optionally, step (1.4) is performed, the improved logistic map is iterated 2000 + g times, and the Chebyshev map is iterated 2000 + r times to respectively generate long chaotic sequences; then a threshold value is set, the values in the sequences are compared with the set threshold value, the values greater than the set threshold value in the sequences are converted to 1, and the values less than or equal to the set threshold value in the sequences are converted to 0, so as to obtain binary chaotic sequences and realize discretization of the chaotic sequences.
[0047] Optionally, when step (1.5) is performed, the improved logistic map and the Chebyshev map are respectively iterated 128 times, and the real-value chaotic sequences obtained by each iteration are quantized to binary sequences with 0.5 as a threshold value, so as to form two 128-bit binary sequences.
[0048] In a second aspect, the present application provides a QR code encryption and decryption system based on a chaotic theory and an AES algorithm, which solves the above technical problems by adopting the following technical solutions:
[0049] A QR code encryption and decryption system based on a chaotic theory and an AES algorithm, which comprises a QR code encryption part and a QR code decryption part.
[0050] The QR code encryption part comprises the following modules:
[0051] An acquisition and calculation module, configured to acquire plaintext information to be used to generate a QR code, and calculate a complete group number g containing 128 bits and a byte number r contained in a last incomplete group according to a total byte number of the plaintext information.
[0052] a grouping module, configured to group the plaintext information according to the calculation result of the calculation module to obtain g plaintext blocks each containing 128 bits and one plaintext block less than 128 bits;
[0053] an initialization obtaining module, configured to obtain the current time of the system as a random seed, and generate initial parameters of the improved logistic map and the Chebyshev map by using a pseudo-random generator;
[0054] an iteration module, configured to respectively iterate the improved logistic map and the Chebyshev map, remove transient effects caused by initial conditions of the chaotic system, and realize discretization of the chaotic sequence;
[0055] a key generation module, configured to first generate two binary sequences each containing 128 bits by binarizing the results of iteration of the improved logistic map and the Chebyshev map, and then obtain a 128-bit initial key sequence for AES encryption by performing an XOR operation;
[0056] a loop execution module, configured to cyclically execute the key generation module g+r times to obtain g+r 128-bit initial key sequences;
[0057] an encryption module, configured to perform AES encryption on the g plaintext blocks each containing 128 bits obtained by the grouping module by using the g+r 128-bit initial key sequences obtained by the key generation module to obtain corresponding ciphertext blocks; and configured to further perform an XOR operation between 8r bits randomly cut from the g+r 128-bit initial key sequences and bytes contained in the one plaintext block less than 128 bits to obtain remaining ciphertext for the one plaintext block less than 128 bits;
[0058] a ciphertext merging module, configured to merge the ciphertext blocks one by one and connect the remaining ciphertext to obtain ciphertext encrypted by the improved AES algorithm;
[0059] a conversion and encoding module, configured to convert the ciphertext encrypted by the improved AES algorithm into Base64 encoding to obtain final ciphertext information;
[0060] a saving module, configured to save the g+r 128-bit initial key sequences and the final ciphertext information in the database correspondingly;
[0061] a ciphertext conversion module, configured to convert the final ciphertext information into a QR code to complete the entire encryption and encoding process;
[0062] The QR code decryption part includes the following modules:
[0063] an information obtaining module, configured to obtain the g+r 128-bit initial key sequences and the encrypted ciphertext information from the database;
[0064] The decoding module is configured to decode the ciphertext information in Base64 to restore binary data;
[0065] The decryption module is configured to decrypt each ciphertext block using the same AES algorithm and corresponding initial key sequence as the encryption part of the QR code to obtain the original plaintext block; for the last ciphertext block with less than 128 bits, the decryption module is further configured to randomly intercept 8r bits from the g+r initial key sequences of 128 bits, and perform bitwise XOR operation with the bytes contained in the ciphertext block to obtain the remaining plaintext.
[0066] The merging decryption module is configured to merge all the decrypted plaintext blocks to obtain the complete plaintext information.
[0067] Optionally, after the acquisition calculation module acquires the plaintext information to be generated into the QR code, the acquisition calculation module is configured to select a character encoding mode according to the type and content of the plaintext information, then convert the plaintext information into binary data according to the selected encoding mode, and then calculate the total number of bytes of the plaintext information by counting the length of the converted data, and finally calculate the complete group number g containing 128 bits and the number r of bytes contained in the last incomplete group according to the total number of bytes of the plaintext information.
[0068] Optionally, the acquisition initialization module acquires the current time of the system as a random seed, and generates the initial parameters x0 and y0 of the improved logistic mapping and the initial parameters y0 of the Chebyshev mapping by using a pseudo-random generator.
[0069] The improved logistic mapping has the form x n+1 = 1-μ*x n 2 where n is a natural number, x n represents a chaotic variable, -1 < x n <1, and μ represents a control parameter, 1 < μ ≤ 2; the control parameter μ is set to 2, i.e., the improved logistic mapping is in a full-mapping chaotic state.
[0070] The Chebyshev mapping has the form y n+1 = cos(k*arccos(y n )), where n is a natural number, y n represents a chaotic variable, -1 ≤ y n ≤ 1, and k represents a control parameter; when the control parameter k takes an integer value and is not less than the value 2, the Chebyshev mapping enters a chaotic state, and the values of its iterations are uniformly mapped to the interval [-1, 1].
[0071] Optionally, the iteration module of the encryption part of the QR code iterates the improved Logistic mapping 2000+g times and the Chebyshev mapping 2000+r times to generate long chaotic sequences, and then sets a threshold, compares the values in the sequences with the set threshold, converts the values greater than the set threshold in the sequences to 1 and the values less than or equal to the set threshold in the sequences to 0, so as to obtain binary chaotic sequences and realize the discretization of the chaotic sequences.
[0072] Optionally, the key generation module of the encryption part of the QR code first iterates the improved Logistic mapping and the Chebyshev mapping 128 times respectively, quantizes the real chaotic sequences obtained in each iteration to binary sequences with 0.5 as the threshold, so as to form two 128-bit binary sequences, and then obtains a 128-bit initial key sequence for AES encryption through the XOR operation.
[0073] The QR code encryption and decryption method and system based on the chaos theory and the AES algorithm of the present application have the following beneficial effects compared with the prior art:
[0074] The improved Logistic mapping, the Chebyshev mapping and the improved AES algorithm are used to encrypt and decrypt the QR code, so that the information leakage or information tampering problem caused by the QR code can be effectively reduced. BRIEF DESCRIPTION OF DRAWINGS
[0075] Figure 1 is a flow chart of the encryption method of the first embodiment of the present application; Figure 1 Figure 2 is a flow chart of the decryption method of the first embodiment of the present application;
[0076] Figure 3 is a module connection block diagram of the second embodiment of the present application; Figure 2 Figure 4 is a flow chart of the encryption method of the second embodiment of the present application. DETAILED DESCRIPTION
[0077] In order to make the technical solutions, the technical problems solved and the technical effects of the present application clearer, the technical solutions of the present application are described in detail below in combination with specific embodiments.
[0078] Embodiment 1
[0079] The present embodiment proposes a QR code encryption and decryption method based on the chaos theory and the AES algorithm, which includes a QR code encryption process and a QR code decryption process.
[0080] (1) Combined with Figure 1, the QR code encryption process Figure 1
[0081] (1.1) Obtain the plaintext information to be generated into a QR code, select a character encoding mode according to the type and content of the plaintext information, then convert the plaintext information into binary data according to the selected encoding mode, and finally count the length of the converted data, that is, the total number of bytes of the plaintext information;
[0082] According to the total number of bytes of the plaintext information, the number of complete groups g containing 128 bits and the number of bytes r contained in the last incomplete group are calculated.
[0083] (1.2) Obtain the current time of the system as a random seed, and use a pseudo-random generator to generate the initial parameter x0 of the improved logistic mapping and the initial parameter g0 of the Chebyshev mapping. Wherein:
[0084] The improved logistic mapping has the form x n+1 = 1 - μ * x n 2 , where n is a natural number, x n represents a chaotic variable, -1 < x n < 1, and μ represents a control parameter, 1 < μ ≤ 2; the control parameter μ is set to 2, that is, the improved logistic mapping is in a full mapping chaotic state;
[0085] The Chebyshev mapping has the form y n+1 = cos(k * arccos(y n )), where n is a natural number, y n represents a chaotic variable, -1 ≤ y n ≤ 1, and k represents a control parameter. When the control parameter k takes an integer value and is not less than the value 2, the Chebyshev mapping enters a chaotic state, and the values of its iterations are uniformly mapped to the interval [-1, 1].
[0086] (1.3) According to the calculation result of step (1.1), the plaintext information is grouped to obtain g plaintext blocks containing 128 bits and 1 plaintext block containing less than 128 bits.
[0087] (1.4) The improved logistic mapping is iterated 2000+g times, and the Chebyshev mapping is iterated 2000+r times to generate long chaotic sequences, respectively. Then set a threshold, compare the values in the sequence with the set threshold, convert the values greater than the set threshold in the sequence to 1, and convert the values less than or equal to the set threshold in the sequence to 0, thereby obtaining a binary chaotic sequence and realizing the discretization of the chaotic sequence.
[0088] (1.5) Improved Logistic mapping and Chebyshev mapping are iterated 128 times respectively, and the real number chaotic sequence obtained in each iteration is quantized to a binary sequence with 0.5 as the threshold, thereby forming two 128-bit binary sequences. An initial key sequence of 128 bits for AES encryption is obtained by XOR operation; repeat this process g+r times, that is, g+r initial key sequences of 128 bits are obtained.
[0089] (1.6) The g+r initial key sequences of 128 bits obtained in step (1.5) are used to AES encrypt the g plaintext blocks containing 128 bits obtained in step (1.3) one by one to obtain the corresponding ciphertext blocks; for the 1 plaintext block less than 128 bits obtained in step (1.3), 8r bits are randomly truncated from the g+r initial key sequences of 128 bits, and bitwise XOR operation is performed with the bytes contained in the plaintext block to obtain the remaining ciphertext; the aforementioned ciphertext blocks are merged one by one, and the remaining ciphertext is connected to obtain the ciphertext encrypted by the improved AES algorithm;
[0090] (1.7) The ciphertext encrypted by the improved AES algorithm is converted into Base64 encoding to obtain the final ciphertext information;
[0091] (1.8) The g+r initial key sequences of 128 bits and the final ciphertext information are saved in the database;
[0092] (1.9) The final ciphertext information is converted into a QR code, and the entire encryption and encoding process is completed.
[0093] (2) QR code decryption process
[0094] (2.1) Obtain the g+r initial key sequences of 128 bits and the encrypted ciphertext information from the database;
[0095] (2.2) Base64 decode the ciphertext information to restore it to binary data;
[0096] (2.3) Use the same AES algorithm and corresponding initial key sequence as the encryption process to decrypt each ciphertext block to obtain the original plaintext block;
[0097] (2.4) For the last ciphertext block less than 128 bits, 8r bits are randomly truncated from the g+r initial key sequences of 128 bits, and then bitwise XOR operation is performed with the bytes contained in the ciphertext block to obtain the remaining plaintext;
[0098] (2.5) Merge all the decrypted plaintext blocks to obtain the complete plaintext information.
[0099] Example Two:
[0100] Combine the attached Figure 2The embodiment provides a QR code encryption and decryption system based on chaos theory and an AES algorithm, which comprises a QR code encryption part and a QR code decryption part.
[0101] The QR code encryption part comprises the following modules.
[0102] An acquisition calculation module is configured to acquire plaintext information to be generated into a QR code, select a character encoding mode according to the type and content of the plaintext information, convert the plaintext information into binary data according to the selected encoding mode, count the length of the converted data, obtain the total byte number of the plaintext information, and further calculate a complete group number g containing 128 bits and a byte number r contained in a last incomplete group.
[0103] A grouping module is configured to group the plaintext information according to the calculation result of the acquisition calculation module to obtain g plaintext blocks containing 128 bits and one plaintext block with less than 128 bits.
[0104] An acquisition initialization module is configured to acquire the current time of the system as a random seed, and generate initial parameters x0 of an improved logistic mapping and initial parameters y0 of a Chebyshev mapping by using a pseudo-random generator. n+1 =1-μ*x n 2 n is a natural number, x n represents a chaotic variable, -1 < x n < 1, and μ represents a control parameter, 1 < μ ≤ 2; the control parameter μ is set to 2, that is, the improved logistic mapping is in a full-mapping chaotic state; the Chebyshev mapping has the form y n+1 =cos(k*arccos(y n )), n is a natural number, y n represents a chaotic variable, -1 ≤ y n ≤ 1, k represents a control parameter, the control parameter k takes an integer value and is not less than the value 2, the Chebyshev mapping enters a chaotic state, and the values of iterations of the Chebyshev mapping are uniformly mapped to the interval [-1, 1].
[0105] An iteration module is configured to iterate the improved logistic mapping 2000 + g times and iterate the Chebyshev mapping 2000 + r times to generate long chaotic sequences, then set a threshold, compare the values in the sequences with the set threshold, convert the values greater than the set threshold in the sequences into 1 and convert the values less than or equal to the set threshold in the sequences into 0, so as to obtain binary chaotic sequences and realize the discretization of the chaotic sequences.
[0106] The key generation module is configured to firstly iterate the improved Logistic mapping and the Chebyshev mapping for 128 times respectively, quantize the real chaotic sequence obtained in each iteration into a binary sequence by taking 0 as a threshold, thereby forming two 128-bit binary sequences, and then obtain a 128-bit initial key sequence for AES encryption through an XOR operation;
[0107] The loop execution module is configured to cyclically execute the key generation module for g+r times to obtain g+r initial 128-bit key sequences.
[0108] The encryption module is configured to use the g+r initial 128-bit key sequences obtained by the key generation module to perform AES encryption on the g plaintext blocks containing 128 bits obtained by the grouping module one by one to obtain corresponding ciphertext blocks; and for the 1 plaintext block containing less than 128 bits obtained by the grouping module, the encryption module is further configured to randomly intercept 8r bits from the g+r initial 128-bit key sequences, and perform an XOR operation on the bytes contained in the plaintext block bit by bit to obtain remaining ciphertext.
[0109] The ciphertext merging module is configured to merge the aforementioned ciphertext blocks one by one and connect the remaining ciphertext to obtain the ciphertext encrypted by the improved AES algorithm.
[0110] The conversion and encoding module is configured to convert the ciphertext encrypted by the improved AES algorithm into Base64 encoding to obtain the final ciphertext information.
[0111] The storage module is configured to store the g+r initial 128-bit key sequences and the final ciphertext information in the database correspondingly.
[0112] The ciphertext conversion module is configured to convert the final ciphertext information into a QR code to complete the entire encryption and encoding process.
[0113] The QR code decryption part includes the following modules:
[0114] The information acquisition module is configured to acquire the g+r initial 128-bit key sequences and the encrypted ciphertext information from the database.
[0115] The decoding module is configured to decode the ciphertext information into binary data.
[0116] The decryption module is configured to use the same AES algorithm and the corresponding initial key sequence as the QR code encryption part to decrypt each ciphertext block to obtain the original plaintext block; and for the last ciphertext block containing less than 128 bits, the decryption module is further configured to randomly intercept 8r bits from the g+r initial 128-bit key sequences, and perform an XOR operation on the bytes contained in the ciphertext block bit by bit to obtain the remaining plaintext.
[0117] The merged decryption module is configured to merge all the decrypted plaintext blocks to obtain complete plaintext information.
[0118] Based on the method described in Embodiment 1 and the system described in Embodiment 2, the following should be added:
[0119] The AES (Advanced Encryption Standard) algorithm is an iterative block cipher system in which plaintext data is divided into groups of 16 bytes (128 bits) and mapped into a 4×4 matrix called the state matrix.
[0120] The AES encryption process is determined by the round transformation function, which includes four modules: byte substitution, row shifting, column obfuscation, and round key addition. The four modules of the round transformation function are described in detail below:
[0121] 1. Byte Substitution (SubBytes)
[0122] Byte substitution is the first step in the AES encryption process. It primarily involves non-linearly replacing each byte in the state matrix using a lookup table called the S-box. Specifically, the bytes are represented in binary format (8 bits per byte); the high 4 bits of the byte are used as the row value (0-15), and the low 4 bits as the column value (0-15); this row and column value is used to find the corresponding element in the S-box, and the original byte is replaced with that element's value. The purpose of this step is to increase the non-linearity of the encryption, making the encryption process more difficult to crack.
[0123] 2. Row shifting (ShiftRows)
[0124] The row shift operation performs a circular left shift on each row of the state matrix, with the number of bits shifted varying depending on the row:
[0125] The first row remains unchanged.
[0126] The second row is shifted to the left by 1 byte (8 bits).
[0127] The third row is shifted 2 bytes (16 bits) to the left.
[0128] The fourth row is shifted 3 bytes (24 bits) to the left.
[0129] This row shifting operation increases the diffusion of data, causing data to mix between rows and increasing the complexity of encryption.
[0130] 3. MixColumns
[0131] The column obfuscation operation is performed independently on each column of the state matrix, utilizing the multiplication property over the finite field GF(2^8) to replace each byte in each column with a linear combination of multiple bytes. This step enhances the correlation between data within a column, further improving the security of the encryption.
[0132] 4. AddRoundKey
[0133] AddRoundKey is the bitwise XOR operation of the state matrix with the round key, which is derived from the initial key. This step ensures that even with the same plaintext block input, the ciphertext block output will be different due to the change in the round key.
[0134] Encryption and decryption process of AES algorithm:
[0135] The AES encryption process includes initial key expansion and subsequent multiple rounds of transformation, each round including the four steps mentioned above, but omitting the column mixing step in the last round. The decryption process is the reverse of these operations, with steps including inverse byte substitution, inverse row shift, inverse column mixing, and AddRoundKey, but with the order of round key usage reversed.
[0136] The main differences between the improved AES algorithm and the AES algorithm lie in encryption speed, storage space occupation, and key generation method. These improvements aim to improve the efficiency and security of the algorithm, making it more suitable for specific application scenarios. The following will describe the differences between the improved AES algorithm and the AES algorithm in detail:
[0137] Encryption speed: Although the AES algorithm is already very efficient, its performance can still be improved in resource-constrained environments such as embedded systems or Internet of Things devices. The improved AES algorithm optimizes the structure of the encryption and decryption round function, reducing the computational complexity and thus improving the encryption and decryption speed. The improved AES algorithm also uses lookup tables (LUT) to replace complex multiplication operations, which not only speeds up the encryption and decryption process but also helps to achieve higher throughput in hardware implementation.
[0138] Storage space occupation: In the standard AES implementation, S-boxes and other data structures occupy a certain amount of storage space. The improved AES algorithm reduces the storage space occupation by 40% by redesigning these data structures. This is particularly important for devices with limited storage resources; the improved algorithm also defines new tables to simplify multiple operations, further reducing the demand for storage space.
[0139] Key generation method: The improved AES algorithm uses a composite chaotic sequence to generate the initial key sequence, which increases the randomness and complexity of the key, thereby improving the security of the algorithm. This method uses the sensitive characteristics of chaos theory to the initial conditions to ensure that each encryption uses a difficult-to-predict key sequence.
[0140] Encryption mode: The improved AES algorithm can adopt different working modes such as CBC, CFB, OFB, CTR, etc. to adapt to different application scenarios and security requirements. These working modes have their own advantages and disadvantages, for example, CBC mode provides diffusion, while CTR mode supports parallel processing. The improved AES algorithm can select the appropriate working mode according to the needs.
[0141] Flexibility and adaptability: The improved AES algorithm is designed to consider various application scenarios and can be flexibly adapted to different hardware and software environments. It can efficiently run on resource-constrained devices while maintaining high security, meeting modern encryption needs.
[0142] In summary, through the improvement of the AES algorithm, significant improvements can be achieved in encryption speed, storage space occupation, key generation, working mode selection, etc. These improvements make the improved AES algorithm perform better in specific application scenarios, especially in situations that require high efficiency and high security. The emergence of the improved AES algorithm not only improves the confidentiality and integrity of data, but also promotes the development and application of cryptography.
[0143] In summary, the QR code encryption and decryption method and system based on chaos theory and AES algorithm can effectively reduce the problem of information leakage or information tampering caused by QR code.
[0144] The above application specific examples have described the principles and implementation modes of the present application in detail. These examples are only used to help understand the core technical content of the present application. Based on the above specific embodiments of the present application, any improvement and modification of the present application made by those skilled in the art without departing from the principles of the present application shall fall within the scope of the patent protection of the present application.
Claims
1. A QR code encryption and decryption method based on chaos theory and AES algorithm, characterized in that, It includes a QR code encryption process and a QR code decryption process; (1) QR code encryption process (1.1) Obtain the plaintext information to be generated into a QR code, calculate the total number of bytes of the plaintext information, and obtain the complete packet number g containing 128 bits and the number r of bytes contained in the last incomplete packet; (1.2) Obtain the current system time as a random seed, and generate the initial parameters of the improved logistic mapping and Chebyshev mapping of the pseudo-random generator; (1.3) According to the calculation result of step (1.1), group the plaintext information to obtain g plaintext blocks containing 128 bits and 1 plaintext block less than 128 bits; (1.4) Iteratively process the improved Logistic mapping and Chebyshev mapping respectively, remove the transient effect caused by the initial conditions of the chaotic system, and realize the discretization of the chaotic sequence; (1.5) Through the iteration and binaryzation of the improved Logistic mapping and Chebyshev mapping, two 128-bit binary sequences are generated; through the XOR operation, a 128-bit initial key sequence for AES encryption is obtained; repeat this process g+r times, that is, g+r 128-bit initial key sequences are obtained; (1.6) Use the g+r 128-bit initial key sequences obtained in step (1.5) to AES-encrypt the g plaintext blocks containing 128 bits obtained in step (1.3) one by one to obtain the corresponding ciphertext blocks; for the 1 plaintext block less than 128 bits obtained in step (1.3), randomly cut 8r bits from the g+r 128-bit initial key sequences, and perform bitwise XOR operation with the bytes contained in the plaintext block to obtain the remaining ciphertext; merge the aforementioned ciphertext blocks one by one, and connect the remaining ciphertext to obtain the ciphertext encrypted by the improved AES algorithm; (1.7) Convert the ciphertext encrypted by the improved AES algorithm into Base64 encoding to obtain the final ciphertext information; (1.8) Save the g+r 128-bit initial key sequences and the final ciphertext information in the database; (1.9) Convert the final ciphertext information into a QR code to complete the entire encryption and encoding process; (2) QR code decryption process (2.1) Obtain the g+r 128-bit initial key sequences and the encrypted ciphertext information from the database; (2.2) Base64-decode the ciphertext information to restore it to binary data; (2.3) Use the same AES algorithm and corresponding initial key sequence as the encryption process to decrypt each ciphertext block to obtain the original plaintext block; (2.4) For the last ciphertext block less than 128 bits, 8r bits are randomly cut from the g+r 128-bit initial key sequences, and then bitwise XOR operation is performed with the bytes contained in the ciphertext block to obtain the remaining plaintext; (2.5) Merge all the decrypted plaintext blocks to obtain the complete plaintext information.
2. The QR code encryption and decryption method based on chaos theory and AES algorithm according to claim 1, characterized in that, After the step (1.1) is performed, the plaintext information to be generated into a QR code is obtained, and then the character coding mode is selected according to the type and content of the plaintext information, the plaintext information is converted into binary data according to the selected coding mode, and finally the length of the converted data is counted, that is, the total number of bytes of the plaintext information is obtained.
3. The QR code encryption and decryption method based on chaos theory and AES algorithm according to claim 1, characterized in that, Perform step (1.2), the pseudo-random generator generates initial parameters of the modified logistic map based on the current time of the system with the initial parameters of the Chebyshev map The improved logistic map has the form wherein, is a natural number, represents a chaotic variable, represents a control parameter, 1 < μ ≤ 2; setting the control parameter μ to 2, the improved logistic map is in a full-mapping chaotic state; Chebyshev mapping has the form wherein, is a natural number, denotes a chaotic variable, k denotes a control parameter, the control parameter k takes integer values and is not less than the value 2, the Chebyshev mapping enters a chaotic state and the values of its iterations are uniformly mapped to the interval [-1, 1].
4. The QR code encryption and decryption method based on chaos theory and AES algorithm according to claim 1, characterized in that, In the step (1.4), the improved Logistic mapping is iterated 2000+g times, and the Chebyshev mapping is iterated 2000+r times to generate long chaotic sequences, respectively, and then a threshold is set, the values in the sequences are compared with the set threshold, the values greater than the set threshold in the sequences are converted into 1, and the values less than or equal to the set threshold in the sequences are converted into 0, so that the binary chaotic sequences are obtained, and the chaotic sequences are discretized.
5. The QR code encryption and decryption method based on chaos theory and AES algorithm according to claim 1, characterized in that, In the step (1.5), the improved Logistic mapping and the Chebyshev mapping are iterated 128 times, respectively, and the real chaotic sequences obtained by each iteration are quantized into binary sequences with 0.5 as the threshold, so that two 128-bit binary sequences are formed.
6. A QR code encryption and decryption system based on chaos theory and AES algorithm, characterized in that, The system comprises a QR code encryption part and a QR code decryption part. The QR code encryption part comprises the following modules. An acquisition and calculation module is configured to acquire plaintext information to be generated into a QR code, and calculate a complete group number g containing 128 bits and a byte number r contained in a last incomplete group according to the total byte number of the plaintext information. A grouping module is configured to group the plaintext information according to the calculation result of the acquisition and calculation module to obtain g plaintext blocks containing 128 bits and one plaintext block containing less than 128 bits. An acquisition initialization module is configured to acquire the current time of the system as a random seed, and generate initial parameters of the improved logistic mapping and the Chebyshev mapping by using a pseudo-random generator. An iteration module is configured to iteratively perform the improved Logistic mapping and the Chebyshev mapping, respectively, to remove the transient effect caused by the initial condition of the chaotic system, and to discretize the chaotic sequences. A key generation module is configured to first generate two 128-bit binary sequences by iteratively performing the improved Logistic mapping and the Chebyshev mapping and binarizing the results, and then obtain a 128-bit initial key sequence for AES encryption by performing an exclusive OR operation. A loop execution module is configured to loop the key generation module g+r times to obtain g+r 128-bit initial key sequences. An encryption module is configured to use the g+r 128-bit initial key sequences obtained by the key generation module to perform AES encryption on the g plaintext blocks containing 128 bits obtained by the grouping module one by one to obtain corresponding ciphertext blocks, and to perform an exclusive OR operation on 8r bits randomly cut from the g+r 128-bit initial key sequences and the bytes contained in the one plaintext block containing less than 128 bits obtained by the grouping module one by one to obtain the remaining ciphertext. A ciphertext merging module is configured to merge the aforementioned ciphertext blocks one by one and connect the remaining ciphertext to obtain the ciphertext encrypted by the improved AES algorithm. The conversion coding module is used for converting the ciphertext encrypted by the improved AES algorithm into Base64 coding to obtain final ciphertext information. The saving module is used for saving the g+r 128-bit initial key sequences and the final ciphertext information into a database. The ciphertext conversion module is used for converting the final ciphertext information into a QR code to complete the whole encryption and coding process. The QR code decryption part comprises the following modules: The information acquisition module is used for acquiring the g+r 128-bit initial key sequences and the encrypted ciphertext information from the database. The decoding module is used for Base64 decoding the ciphertext information to restore it into binary data. The decryption module is used for decrypting each ciphertext block by using the same AES algorithm and the corresponding initial key sequence as the QR code encryption part to obtain the original plaintext block; for the last ciphertext block with less than 128 bits, the decryption module is also used for randomly intercepting 8r bits from the g+r 128-bit initial key sequences and performing bitwise XOR operation with the bytes contained in the ciphertext block to obtain the remaining plaintext. The combined decryption module is used for combining all the decrypted plaintext blocks to obtain complete plaintext information.
7. The QR code encryption and decryption system based on chaos theory and AES algorithm according to claim 6, characterized in that, The acquisition and calculation module of the QR code encryption part acquires the plaintext information to be generated into a QR code, first selects a character coding mode according to the type and content of the plaintext information, then converts the plaintext information into binary data according to the selected coding mode, subsequently calculates the total byte number of the plaintext information by counting the length of the converted data, and finally calculates the complete group number g containing 128 bits and the byte number r contained in the last incomplete group according to the total byte number of the plaintext information.
8. The QR code encryption and decryption system based on chaos theory and AES algorithm according to claim 6, characterized in that, The QR code encryption part acquisition initialization module acquires the current time of the system as a random seed, and generates initial parameters of an improved logistic mapping using a pseudo-random generator and initial parameters of the Chebyshev mapping An improved logistic map has the form wherein, is a natural number, represents a chaotic variable, μ represents a control parameter, 1 < μ ≤ 2; setting the control parameter μ to 2, the improved logistic map is in a full-mapping chaotic state; Chebyshev mapping has the form wherein, is a natural number, denotes a chaotic variable, k denotes a control parameter, the control parameter k takes integer values and is not less than the value 2, the Chebyshev mapping enters a chaotic state and the values of its iterations are uniformly mapped to the interval [-1, 1].
9. The QR code encryption and decryption system based on chaos theory and AES algorithm according to claim 6, characterized in that, The iteration module of the QR code encryption part iterates the improved Logistic mapping 2000+g times and iterates the Chebyshev mapping 2000+r times to respectively generate long chaotic sequences, then sets a threshold value, compares the values in the sequences with the set threshold value, converts the values greater than the set threshold value in the sequences into 1 and converts the values less than or equal to the set threshold value in the sequences into 0, so as to obtain binary chaotic sequences and realize the discretization of the chaotic sequences.
10. The QR code encryption and decryption system based on chaos theory and AES algorithm according to claim 6, characterized in that, The key generation module of the QR code encryption part first iterates the improved Logistic mapping and the Chebyshev mapping for 128 times respectively, quantizes the real chaotic sequences obtained by each iteration into binary sequences with 0.5 as the threshold value, so as to form two 128-bit binary sequences, and then obtains the 128-bit initial key sequence for AES encryption by performing XOR operation.
Citation Information
Patent Citations
Information encryption method based on ghost imaging calculation and data container customization
CN110351451A
Power battery traceability management code encryption method based on improved AES algorithm
CN111262684A