Rapid image encryption method and device, equipment and storage medium
By introducing two-dimensional chaotic mapping and gene encoding into image encryption technology, and combining XOR operation, the problem of insufficient security in the prior art is solved, and higher security and complexity are achieved.
Patent Information
- Application Number
- CN202510204680.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-24
- Publication Date
- 2025-06-06
- Estimated Expiration
- 2045-02-24
AI Technical Summary
The prior art is difficult to effectively improve the security of image encryption, especially when considering the characteristics of image redundancy, large data volume and two-dimensional structure.
A fast image encryption method is adopted to generate a coding lookup table by performing two-dimensional chaos mapping and gene encoding based on a preset key, and encrypting the image through XOR operation.
It improves the security and complexity of image encryption, enhances the randomness and diffusion of data, and effectively resists statistical attacks and exhaustive attacks.
Smart Images

Figure CN120111151A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image encryption technology, and in particular to a method, device, equipment and storage medium for fast image encryption. Background Art
[0002] With the popularization of the Internet and smart phones, information security issues have become increasingly prominent, especially in the process of image transmission. As an important carrier of information interaction, digital images are crucial to ensure their transmission security. Therefore, image encryption technology has become the key to protecting image security.
[0003] Traditional encryption algorithms include DES (Data Encryption Standard), RSA (an encryption algorithm) and AES (Advanced Encryption Standard). Traditional encryption algorithms cannot meet the needs of image encryption because they do not consider the redundancy of images, large data volume and two-dimensional structure.
[0004] Therefore, how to improve the security of image encryption is a technical problem that needs to be solved urgently.
[0005] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0006] The main purpose of this application is to provide a method, device, equipment and storage medium for rapid image encryption, aiming to solve the technical problem of how to improve the security of image encryption.
[0007] To achieve the above purpose, the present application proposes a method for fast image encryption, the method comprising:
[0008] Performing two-dimensional chaotic mapping on the plaintext image to be encrypted based on a preset first key to obtain a scrambled image, and generating a coding lookup table based on a preset second key;
[0009] Genetically encoding the scrambled image through dynamic encoding to obtain a preliminary encoded image;
[0010] Search and replace each code in the preliminary coded image in the code lookup table to obtain a preliminary obfuscated image after replacement;
[0011] Starting from the second bit in the preliminary obfuscated image, each target element in the preliminary obfuscated image is traversed, and an XOR operation is performed on the target element and the element of the previous bit of the target element to obtain a ciphertext matrix after encrypting the plaintext image.
[0012] In one embodiment, the step of performing two-dimensional chaotic mapping on the plaintext image to be encrypted based on a preset first key to obtain a scrambled image includes:
[0013] Obtaining a current number of split rounds, and determining a target value on a target number of bits in the first key, wherein the target number of bits corresponds to the current number of split rounds;
[0014] Dividing the plaintext image into two sub-images in a diagonal direction based on the number of segmentation rounds;
[0015] For each of the sub-images, dividing the sub-image into at least one group of pixel sets, wherein the pixel set includes two columns of adjacent sub-pixel sets;
[0016] For each group of the pixel sets, determine each short pixel in the shorter sub-pixel set among the adjacent sub-pixel sets and each long pixel in the longer sub-pixel set among the adjacent sub-pixel sets, and insert each of the short pixels in sequence between each of the long pixels to obtain an intermediate image;
[0017] Connecting pixels in the intermediate image according to a preset connection rule to obtain an intermediate image;
[0018] Taking the intermediate image as a new plaintext image, returning to the step of dividing the plaintext image into two sub-images in a diagonal direction based on the target value, until the number of divisions is equal to the target value, and updating the number of division rounds;
[0019] Return to the step of obtaining the current number of segmentation rounds until the number of segmentation rounds is equal to the length of the first key, and use the current intermediate image as the scrambled image.
[0020] In one embodiment, the step of dividing the plaintext image into two sub-images in a diagonal direction based on the number of division rounds includes:
[0021] If the number of segmentation rounds is an odd number, the plaintext image is segmented into two sub-images from the upper left to the lower right along the diagonal direction;
[0022] If the number of segmentation rounds is an even number, the plaintext image is segmented into two sub-images along a diagonal direction from the upper right to the lower left.
[0023] In one embodiment, the step of generating a coding lookup table based on a preset second key includes:
[0024] Generate an initial array of a preset size, and perform a two-dimensional chaotic mapping on the initial array based on the last four bits of the second key to obtain a scrambled array;
[0025] Genetically encoding the scrambled array according to a preset encoding rule to obtain an encoding matrix;
[0026] The row and column indexes of the encoding matrix are defined according to a preset index rule to obtain an encoding lookup table.
[0027] In one embodiment, the step of genetically encoding the scrambled image by dynamic encoding to obtain a preliminary encoded image comprises:
[0028] Starting from the second bit in the scrambled image, each target pixel value in the scrambled image is traversed, and based on the pixel value of the previous bit of the target pixel value, the target pixel value is updated until the last pixel value in the scrambled image is traversed to obtain the preliminary encoded image.
[0029] In one embodiment, after the step of obtaining the ciphertext matrix after encrypting the plaintext image, the method further includes:
[0030] Decoding the first bit in the ciphertext matrix based on the second key to obtain a pixel value of the first bit after decoding;
[0031] Starting from the second bit of the ciphertext matrix, each target ciphertext in the ciphertext matrix is traversed, and the pixel value of the target ciphertext is calculated based on the pixel value of the decoded ciphertext of the previous bit of the target ciphertext to obtain the plaintext image after the ciphertext matrix is decoded.
[0032] In addition, to achieve the above-mentioned purpose, the present application also proposes a fast image encryption device, the fast image encryption device comprising:
[0033] An initialization module, used for performing two-dimensional chaotic mapping on the plaintext image to be encrypted based on a preset first key to obtain a scrambled image, and generating a coding lookup table based on a preset second key;
[0034] A preliminary encoding module, used for genetically encoding the scrambled image through dynamic encoding to obtain a preliminary encoded image;
[0035] A preliminary obfuscation module, used for searching and replacing each code in the preliminary coded image in the code lookup table to obtain a replaced preliminary obfuscated image;
[0036] The encryption module is used to traverse each target element in the preliminary obfuscated image starting from the second bit in the preliminary obfuscated image, perform an XOR operation on the target element and the element of the previous bit of the target element, and obtain a ciphertext matrix after encrypting the plaintext image.
[0037] In addition, to achieve the above-mentioned purpose, the present application also proposes an electronic device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the image fast encryption method as described above.
[0038] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the image fast encryption method described above are implemented.
[0039] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the image fast encryption method described above are implemented.
[0040] The present application provides a method for fast encryption of an image. The present application first performs a two-dimensional chaotic mapping on a plaintext image using a first key to obtain a scrambled image, generates a coding lookup table based on a second key, and then performs genetic coding on the scrambled image to obtain a preliminary coded image. Then, the new codes corresponding to the codes in the preliminary coded image are sequentially searched in the coding lookup table to replace them to obtain a replaced preliminary obfuscated image. Finally, each target element is traversed starting from the second position in the obfuscated image, the target element is XOR-ed with the element before the target element, and the target element is replaced with the budget result. After the traversal is completed, the ciphertext matrix after the plaintext image is encrypted can be obtained.
[0041] In summary, the present application integrates the two-dimensional chaotic mapping algorithm with the genetic coding algorithm. Compared with the traditional encryption algorithm, the present application increases the complexity and randomness of the data by permuting and genetically encoding the plaintext image, and, based on the XOR operation with adjacent elements, improves the diffusibility of the encryption, thereby improving the security of image encryption. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0043] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0044] Figure 1 A flowchart of the first embodiment of the image fast encryption method of the present application is provided;
[0045] Figure 2 A schematic diagram of the mapping process provided for an embodiment of the image fast encryption method of the present application;
[0046] Figure 3 A schematic diagram of the encryption and decryption effect provided by the embodiment of the image fast encryption method of the present application;
[0047] Figure 4 A histogram of a plaintext image and a ciphertext image provided in the embodiment of the image fast encryption method of the present application;
[0048] Figure 5 This is a schematic diagram of the module structure of the image fast encryption device according to an embodiment of the present application;
[0049] Figure 6 This is a schematic diagram of the device structure of the hardware operating environment involved in the image fast encryption method in the embodiment of the present application.
[0050] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0051] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0052] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0053] The main solution of the embodiment of the present application is: based on a preset first key, a two-dimensional chaotic mapping is performed on the plaintext image to be encrypted to obtain a scrambled image, and a coding lookup table is generated based on a preset second key; the scrambled image is genetically encoded by dynamic coding to obtain a preliminary encoded image; each code in the preliminary encoded image is searched and replaced in the coding lookup table to obtain a replaced preliminary obfuscated image; starting from the second position in the preliminary obfuscated image, each target element in the preliminary obfuscated image is traversed, and the target element is XORed with the previous element of the target element to obtain a ciphertext matrix after the plaintext image is encrypted.
[0054] In this embodiment, for the convenience of description, the electronic device is used as the execution subject for explanation below.
[0055] With the popularization of the Internet and smart phones, information security issues have become increasingly prominent, especially in the process of image transmission. As an important carrier of information interaction, digital images are crucial to ensure their transmission security. Therefore, image encryption technology has become the key to protecting image security.
[0056] Traditional encryption algorithms include DES (Data Encryption Standard), RSA (an encryption algorithm) and AES (Advanced Encryption Standard). Traditional encryption algorithms cannot meet the needs of image encryption because they do not consider the redundancy of images, large data volume and two-dimensional structure.
[0057] Therefore, how to improve the security of image encryption is a technical problem that needs to be solved urgently.
[0058] In response to the above problems, the present application provides a method for fast image encryption. The present application first uses a first key to perform a two-dimensional chaotic mapping on the plaintext image to obtain a scrambled image, and generates a coding lookup table based on a second key. The scrambled image is then genetically encoded to obtain a preliminary coded image. The new codes corresponding to each code in the preliminary coded image are then searched in the coding lookup table in turn, and replaced to obtain a replaced preliminary obfuscated image. Finally, each target element is traversed starting from the second bit in the obfuscated image, the target element is XORed with the previous bit of the target element, and the target element is replaced with the budget result. After the traversal is completed, the ciphertext matrix after the plaintext image encryption can be obtained.
[0059] In summary, the present application integrates two-dimensional chaotic mapping with genetic coding algorithm. Compared with traditional encryption algorithms, the present application increases the complexity and randomness of data by permuting and genetically encoding plaintext images, and based on the XOR operation with adjacent elements, improves the diffusibility of encryption, thereby improving the security of image encryption.
[0060] It should be noted that the execution subject of this embodiment may be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, etc. The following takes an electronic device as an example to illustrate this embodiment and the following embodiments.
[0061] Based on this, the present application embodiment provides a method for fast encryption of images. Figure 1 , Figure 1 This is a flowchart of the first embodiment of the image fast encryption method of the present application.
[0062] In this embodiment, the image fast encryption method includes steps S10 to S50:
[0063] Step S10, performing two-dimensional chaotic mapping on the plaintext image to be encrypted based on a preset first key to obtain a scrambled image, and generating a coding lookup table based on a preset second key;
[0064] It should be noted that, in this embodiment, both the first key and the second key can be set according to actual conditions and are not further limited in this embodiment.
[0065] In this embodiment, a two-dimensional chaotic mapping is first performed on the plaintext image to be encrypted using a preset first key. The two-dimensional chaotic mapping can generate complex, pseudo-random position changes to ensure that the distribution of the image pixel positions is more random, thereby greatly improving the security of the image. After the two-dimensional chaotic mapping, a scrambled image is obtained, and its pixel positions are already very different from the original plaintext image. At the same time, a coding lookup table is generated based on a preset second key. This lookup table is used for coding replacement in subsequent steps, which ensures the complexity and security of the encryption process.
[0066] Further, in a feasible implementation manner, the step of performing two-dimensional chaotic mapping on the plaintext image to be encrypted based on the preset first key in the above step S10 to obtain a scrambled image includes steps A10 to A70:
[0067] Step A10, obtaining the current number of split rounds, and determining a target value on a target number of bits in the first key, wherein the target number of bits corresponds to the current number of split rounds;
[0068] In this embodiment, when the plaintext image is scrambled, the current number of segmentation rounds is first obtained, which is initially 1, and then the target value on the target bit number corresponding to the number of segmentation rounds is determined in the first key. For example, in the first round of segmentation, the target value is the value of the highest bit in the first key.
[0069] It should be noted that, in this embodiment, the highest bit in the first key is taken as the first bit, and the bits in the first key are arranged in order from high to low.
[0070] Step A20, dividing the plaintext image into two sub-images along a diagonal direction based on the target value;
[0071] In this embodiment, after determining the target value from the first key, the plaintext image is divided into two sub-images in a diagonal direction based on the characteristics of the target value. This division method ensures that different parts of the image are processed in a non-standard, non-linear manner, thereby increasing the complexity of encryption and speeding up the image scrambling.
[0072] Furthermore, in a feasible implementation manner, the above step A20 may include steps A21 to A22:
[0073] Step A21, if the number of segmentation rounds is an odd number, the plaintext image is segmented into two sub-images along a diagonal direction from the upper left to the lower right;
[0074] In this embodiment, when the image is scrambled, the image may be segmented for multiple cycles. Therefore, when the image is segmented, it is necessary to first determine the current number of segmentation rounds, determine the parity of the current number of rounds, determine whether it is left mapping or right mapping, and then receive the preset first key. Then, determine the target value on the number of bits of the current number of segmentation rounds from the first key. For example, when the current number is the third round of segmentation, the number of segmentations is then the value of the third bit from high to low is determined in the first key. The parity of this bit will determine the direction of the current scrambled image segmentation, thereby introducing key-based randomness. If the number of segmentation rounds is an odd number, the plaintext image is segmented into two sub-images in the diagonal direction from the upper left to the lower right. This segmentation method ensures that different parts of the image are processed in a non-standard manner, increasing the complexity of encryption.
[0075] Step A22: if the number of segmentation rounds is an even number, the plaintext image is segmented into two sub-images along the diagonal direction from the upper right to the lower left.
[0076] In this embodiment, if the number of segmentation rounds is an even number, the device adopts a segmentation method opposite to step A21, that is, the plaintext image is segmented into two sub-images along the diagonal direction from the upper right to the lower left.
[0077] Step A30, for each of the sub-images, dividing the sub-image into at least one set of pixel sets, wherein the pixel set includes two columns of adjacent sub-pixel sets;
[0078] In this embodiment, each sub-image is further subdivided into at least one group of pixel sets, each group of pixel sets contains two adjacent columns of sub-pixel sets, and the two columns of sub-pixel sets may be different in length. Since each sub-image is a group of isosceles right triangles, there is a difference between two adjacent columns of pixels in the sub-image. Based on this difference, the pixels can be interspersed.
[0079] Step A40, for each group of the pixel sets, determining each short pixel in the shorter sub-pixel set of the adjacent sub-pixel sets and each long pixel in the longer sub-pixel set of the adjacent sub-pixel sets, and sequentially inserting each of the short pixels between each of the long pixels to obtain an intermediate image;
[0080] In this embodiment, for each group of pixels, each short pixel in the shorter sub-pixel set and each long pixel in the longer sub-pixel set of adjacent sub-pixel sets are determined, and then the short pixels are inserted into the long pixels in sequence to form a new pixel arrangement. This step further increases the complexity of the image by changing the original order and adjacent relationship of the pixels.
[0081] Step A50, connecting the pixels in the intermediate image according to a preset connection rule to obtain an intermediate image;
[0082] Step A60, taking the intermediate image as a new plaintext image, returning to execute the step of dividing the plaintext image into two sub-images in the diagonal direction based on the number of division rounds, until the number of divisions is equal to the target value, and then updating the number of division rounds.
[0083] In this embodiment, after completing the insertion operation of all pixel sets, an intermediate matrix is obtained. Then, the pixels in the intermediate matrix are connected according to a preset connection rule (the connection rule can be a predefined algorithm) to obtain a scrambled intermediate image. Then, the intermediate image is used as a new plaintext image, and steps A20-A50 are returned to execute, and the segmentation is performed again until the number of segmentations is equal to the target value of the number of bits corresponding to the current round number in the first key, and a round of segmentation is completed. When a round of segmentation is completed, the number of segmentation rounds is increased by one.
[0084] Step A70, returning to the step of obtaining the current number of segmentation rounds, until the number of segmentation rounds is equal to the length of the first key, and taking the current intermediate image as the scrambled image.
[0085] In this embodiment, after the number of segmentation rounds is updated, the process returns to execute steps A10-A60 until the number of segmentation rounds is equal to the length of the first key, and the current intermediate image is the final scrambled image.
[0086] As an example, use the key key1 to perform a two-dimensional chaotic mapping on the image:
[0087] key_str = str(key1);
[0088] Starting from the highest digit of the key key1, odd digits correspond to left mapping, even digits correspond to right mapping, and each digit value corresponds to the number of mapping iterations. The plaintext image P is iterated alternately through the left and right mapping formulas to obtain the scrambled image P1.
[0089] Specifically, assume that the size of a grayscale image is N×N, and the chaotic mapping is implemented by stretching and folding operations. The image is divided into two isosceles right triangles along the diagonal direction of the image. Using the length difference between each column and the adjacent column of the isosceles right triangle, the pixels of the shorter column are inserted between the two pixels of the adjacent longer column. Repeat this process, connect in a specific way, and then the image can be stretched into a straight line. Finally, it is folded into a scrambled image.
[0090] For example, see Figure 2 , Figure 2 This is a schematic diagram of the mapping process involved in the embodiment of the present application. The left mapping of the image array of size 4×4 is as follows: Figure 2As shown, N = 4. First, the image is divided into two isosceles right triangle images along the diagonal line from the upper left to the lower right, and the pixels of the shorter columns of the two parts are inserted between the two pixels of the longer columns: the pixel (0,0) is inserted between (0,1) and (1,1), the pixel (0,2) is inserted between (0,3) and (1,3), the pixel (1,2) is inserted between (1,3) and (2,3), and so on, and the operation is repeated for the parts. Then the image is stretched into a straight line, and finally folded and mapped into a new image.
[0091] The scrambled image obtained after mapping can be expressed by the formula. Specifically, let the grayscale image size be N×N, let C(i,j), i,j=0,1,…,N-1, be the pixel value of the i-th row and j-th column in the image array, let l(i), i=0,1,…,N 2 -1 is the stretched one-dimensional array. The mapping is divided into left mapping and right mapping, and the formula is as follows:
[0092] Left mapping algorithm:
[0093] When i>j and j is an even number, the formula is:
[0094]
[0095] When i>j and j is an odd number, the formula is:
[0096]
[0097] When j ≥ i and Nj is an odd number, the formula is:
[0098]
[0099] When j≥i and Nj is an even number, the formula is:
[0100]
[0101] Right mapping algorithm:
[0102] Mirror the original image, and set A(i,j), i,j=0,1,…,N-1. The formula is:
[0103] A(i,j)=C(i,N-1-j);
[0104] The right mapping algorithm can be obtained through the left mapping.
[0105] Further, in a feasible implementation manner, the step of generating a coding lookup table based on a preset second key in the above step S10 may include steps B10 to B30:
[0106] Step B10, generating an initial array of a preset size, and performing a two-dimensional chaotic mapping on the initial array based on the last four bits of the second key to obtain a scrambled array;
[0107] In this embodiment, an initial array of a preset size is first generated. The size of this array is usually determined according to encryption requirements and security requirements, and then the device uses the last four bits of the second key to perform a two-dimensional chaotic mapping on the initial array.
[0108] Step B20, performing genetic coding on the scrambled array according to a preset coding rule to obtain a coding matrix;
[0109] In this embodiment, after obtaining the scrambled array, the device performs genetic encoding on it according to a preset encoding rule.
[0110] Step B30, defining the row and column indexes of the encoding matrix according to a preset index rule to obtain an encoding lookup table.
[0111] In this embodiment, finally, the device defines the row and column indexes of the coding matrix according to a preset index rule, thereby generating a coding lookup table.
[0112] As an example, first generate the initial matrix array, generate the matrix array K:
[0113] K=np.arange(256).reshape(16,16);
[0114] Where: np.arrange() is a function that generates a one-dimensional array, and the value of each bit in the array is its index value; reshape() is a function that reshapes it into a two-dimensional array.
[0115] Use the last 4 bits of the key key2 to perform a two-dimensional chaotic mapping scrambling on the K array to obtain the scrambled array K1. Perform DNA encoding on the values in the K1 array according to the rule rule=mod(key2,8)+1 in Table 1 to obtain the encoding matrix K2. Use the custom row and column indexes of the encoding matrix to obtain the encoding lookup table K3:
[0116] K 3 =pd.DataFrame(K 2 ,index=indices,index=indices)
[0117] In the formula: mod() is the modulus function; pd.DataFrame() is the function of customizing the row and column indexes of the array, and indices is the row and column index values: the pairwise matching values of the four bases.
[0118] Specifically, DNA is composed of four deoxynucleotides: adenine (A), cytosine (C), guanine (G) and thymine (T). The chemical structure of the base determines the principle of base complementary pairing. If the base is represented by a 2-bit binary number, the operation and arrangement of the base can store binary information. A grayscale image pixel can be represented as an 8-bit binary value, which can be converted into four bases for calculation using the 8 encoding rules in Table 1. Table 2 is the rule for DNA XOR operation. However, the traditional DNA encoding and calculation rules are fixed, which makes the DNA encoding less resistant to exhaustive attacks and has certain security defects.
[0119]
[0120] Table 1 DNA coding rules
[0121]
[0122] Table 2 DNA XOR rules
[0123] In this embodiment, an image encryption technology based on a DNA coding lookup table is improved. A lookup table generated by a python system random number function is used, and base substitution is performed, so that the row and column indexes of the lookup table are separate DNA codes. Then the image pixel value encoding value is decomposed into row coordinates and column coordinates, and base substitution is performed after searching. Although this technology randomly replaces the DNA code to enhance the randomness of the algorithm, the range of the lookup table is small, and it is difficult to resist exhaustive attacks. When the seed setting is not random enough, the quality of the generated lookup table may be poor and the consistency problem of different platforms. Based on the problems existing in this technology, this paper designs a method for a DNA coding lookup table of size generated by a new scrambling algorithm, which effectively enhances the security of the algorithm. First, an initial array is generated, and a two-dimensional chaotic map is used for scrambling, and the array is DNA-encoded, and DNA combinations are defined as row and column indexes to form a DNA lookup table. For example, 1334 is used as the scrambling key of the two-dimensional chaotic map, and the initial array is scrambled, and the matrix converted to is shown in Table 3.
[0124] 52 123 ... 85 163 48 ... 84 ... ... ... ... 30 206 ... 49
[0125] Table 3 Random permutation matrix Use rule 5 in Table 1 to perform DNA encoding on the matrix and obtain the lookup table, as shown in Table 4.
[0126]
[0127] Table 4 Lookup table
[0128] For example, to encode the pixel value 30, first perform the DNA original encoding according to Rule 5 to obtain CATG, where CA is used as the row index and TG is used as the column index. Then, the lookup table is searched to obtain TCAT. Therefore, CATG is replaced by TCAT. Similarly, to encode the pixel value 41, GTGC is obtained. DNA XOR operation is performed on the two codes TCAT and GTGC to obtain CTGG. Decoding is performed using Rule 2 to obtain 181, completing the pixel diffusion. The lookup table can flexibly adapt to different DNA encoding rules and operation requirements, enhancing the versatility and security of the algorithm.
[0129] Step S20, genetically encoding the scrambled image through dynamic encoding to obtain a preliminary encoded image;
[0130] In this embodiment, after the scrambled image is obtained, the scrambled image is genetically encoded using a dynamic encoding method. The dynamic encoding can ensure that each pixel value is associated with the previous pixel value during the conversion process, which further increases the diffusibility of encryption.
[0131] Further, in a feasible implementation manner, the above step S20 may include step S21:
[0132] Step S21, traversing each target pixel value in the scrambled image starting from the second bit in the scrambled image, updating the target pixel value based on the previous pixel value of the target pixel value, until traversing to the last pixel value in the scrambled image, to obtain the preliminary encoded image.
[0133] In this embodiment, the second pixel value in the scrambled image is first located. This is because in some encryption strategies, the first pixel value of the image may be retained or specially processed. Starting from the second bit, traversing can ensure the continuity and consistency of the encryption process. Starting from the second bit, each target pixel value in the scrambled image is traversed in turn. For each target pixel value, the target pixel value is updated based on its previous pixel value.
[0134] As an example, the scrambled image P1 is DNA-encoded, and the encoding rule adopts a dynamic encoding method, which depends on the pixel value of the previous bit:
[0135] rule=mod(P 1 [prev_i,prev_j],8)+1,if i! =0and j! =0;
[0136] rule=mod(key2,8)+1,if i==0and j==0;
[0137] Where: P1[prev_i,prev_j] is the previous pixel value.
[0138] The preliminary encoded image P2 is obtained.
[0139] Step S30, searching and replacing each code in the preliminary coded image in the code lookup table to obtain a preliminary obfuscated image after replacement;
[0140] In this embodiment, each code in the preliminary coded image is searched and replaced in the code lookup table, and the image information is further obfuscated by replacing the code, thereby increasing the complexity of encryption.
[0141] Specifically, as an example, the codes in the P2 array are searched and replaced in the code lookup table K3, with the row index being the first two digits and the column index being the last two digits, to obtain the replaced array P3.
[0142] Step S40, traversing each target element in the preliminary obfuscated image starting from the second bit in the preliminary obfuscated image, performing an XOR operation on the target element and the element of the previous bit of the target element, and obtaining a ciphertext matrix after encrypting the plaintext image.
[0143] It should be noted that, in this embodiment, the XOR operation is an effective encryption method, which can further confuse the image information and improve the security of encryption.
[0144] In this embodiment, each target element in the image is traversed starting from the second bit of the preliminary obfuscated image. For each target element, an XOR operation is performed between it and the previous element, and the result of the XOR operation replaces the current target element. Then, the next element is traversed until all elements are traversed to obtain the final ciphertext matrix, that is, the encrypted image.
[0145] Specifically, as an example, a DNA XOR operation is performed on each base pair of P3 and the previous base in its array position, and the first base is not processed, to obtain image P4:
[0146] P 4 [i,j]=P 3 [i,j]XOR P 3 [prev_i,prev_j],if i! =0and j! =0;
[0147] P 4 [i,j]=P 3 [i,j],if i==0and j==0;
[0148] This application integrates the secondary obfuscation algorithm with the genetic coding algorithm. Compared with the traditional encryption algorithm, this application increases the complexity and randomness of the data by permuting and genetically encoding the plaintext image, and improves the diffusibility of the encryption based on the XOR operation with adjacent elements, thereby improving the security of image encryption.
[0149] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above embodiment 1 can be referred to the above introduction, and will not be repeated later. On this basis, after the above step S40, the method can also include steps S50 to S60:
[0150] Step S50, decoding the first bit in the ciphertext matrix based on the second key to obtain a pixel value after decoding the first bit;
[0151] In this embodiment, the encrypted ciphertext matrix and the second key are first received, and then the first bit in the ciphertext matrix is decoded based on the second key. This decoding process involves a specific algorithm or function, which utilizes certain characteristics of the second key or the result after specific processing to restore the original pixel value of the first bit in the ciphertext matrix, and can be set according to actual needs.
[0152] Step S60, starting from the second bit of the ciphertext matrix, traverse each target ciphertext in the ciphertext matrix, calculate the pixel value of the target ciphertext based on the pixel value of the decoded ciphertext before the target ciphertext, and obtain the plaintext image after the ciphertext matrix is decoded.
[0153] In this embodiment, after obtaining the pixel value after decoding the first bit, each target ciphertext is traversed starting from the second bit of the ciphertext matrix, and for each target ciphertext, the pixel value of the target ciphertext is calculated based on the pixel value after decoding the previous ciphertext.
[0154] Specifically, as an example, P4 is decoded by DNA to obtain the ciphertext image P5, and the decoding rule for each bit is:
[0155] rule=mod(P 5 [prev_i,prev_j],8)+1,if i! =0andj! =0;
[0156] rule=mod(key2,8)+1,if i==0and j==0;
[0157] Where: P5[prev_i,prev_j] is the decoded pixel value of the previous bit.
[0158] Furthermore, in order to verify the performance of the above algorithm, four classic images are used for analysis: Lena, Baboon, Cameraman and Peppers. The experiment uses key1=1234567890123456 and key2=123456789 as keys. The encryption and decryption effects are as follows: Figure 3 As shown, the ciphertext image has no visual features and appears as a random noise distribution. No information about the plaintext image can be obtained, which shows that the encryption algorithm has an excellent encryption effect; the decrypted image is no different from the plaintext image, indicating that the algorithm has no loss in the encryption and decryption process.
[0159] In key space analysis and key sensitivity, the key space is the set of all possible keys that can be used in an image encryption algorithm. The security of the algorithm is closely related to the key space. The premise of an excellent encryption algorithm is to have a large key space. In the image encryption algorithm, when the key space is larger than 2 100 Only when the key length is longer can it resist brute force attacks. Experiments show that the longer the key length, the larger the key space. The key space of the encryption algorithm is far more than 2 100 , indicating that the encryption algorithm has strong resistance to brute force attacks.
[0160] Key sensitivity is an important performance indicator of encryption algorithms, which is used to evaluate the impact of the key on the encryption result. For an encryption algorithm with strong key sensitivity, when the key changes slightly, the generated ciphertext should change greatly. High key sensitivity can effectively resist attacks and ensure data security.
[0161] For the Lena secret image encrypted with key key1=1234567890123456 and key2=123456789, when it is decrypted with key1=1234567890123457 and key2=123456789 and with key1=123456789012345 and key2=123456788, even if the encryption key and the decryption key differ by only one key bit, the image cannot be decrypted correctly at all, indicating that the encryption algorithm is highly sensitive to the key.
[0162] The histogram displays the statistical data of image pixels in the form of a graph, which can intuitively reflect the distribution of grayscale values in the image. The histogram of the original image usually has obvious statistical characteristics as shown in the figure below. Statistical analysis attackers may compare the encrypted image with its statistical laws to infer the conversion relationship between the original image and the encrypted image. In order to increase the difficulty of statistical attacks, the histogram of the encrypted image needs to maintain a relatively uniform distribution. Figure 4The pixel histograms of the plaintext image and its ciphertext image are displayed. The experimental results show that the pixel value distribution of the plaintext image is not uniform and has certain distribution characteristics, while the pixel values of the ciphertext image are evenly distributed and it is difficult to observe their rules and characteristics. This shows that it is difficult for attackers to obtain effective information from the encrypted image, and it can effectively resist statistical attacks.
[0163] In image encryption, information entropy can represent the distribution of pixel values. The more uniform the grayscale value distribution of the encrypted image is, the higher the randomness and security of the image is, and the closer the information entropy of the image is to the maximum information entropy value of 8.
[0164] The calculation formula of information entropy is as follows:
[0165]
[0166] Where: Y is the grayscale image, p(y i ) is the value y in image Y i The probability of n is the number of possible grayscale values.
[0167] The experiment calculated the information entropy of four images before and after encryption, and the results are shown in Table 5. The experimental results show that the information entropy of the ciphertext images is very close to the ideal value of 8. Therefore, the privacy of the ciphertext images is strong, the amount of information contained in the images is very small, and they can effectively resist statistical attacks.
[0168]
[0169] Table 5 Information entropy of plaintext image and ciphertext image
[0170] The correlation between adjacent pixels is one of the important criteria for evaluating the performance of image encryption algorithms. In the original image, the correlation between adjacent pixels is very high, which may cause the leakage of one pixel to cause the surrounding pixels to be inferred. In order to resist attacks, an excellent encryption method should destroy the correlation of pixels in the original image. The measurement of correlation usually includes the correlation coefficients in the horizontal, vertical and diagonal directions. In general, the correlation between adjacent pixels of the original image is close to 1, while the correlation between adjacent pixels of the encrypted image should be close to 0. The calculation formula is as follows:
[0171]
[0172] Where x and y are the grayscale values of two adjacent pixels; N is the number of adjacent pixels; R xy is the correlation coefficient; E(x) is the expected value; D(x) is the variance; cov(x,y) is the covariance.
[0173] Table 6 shows the correlation coefficients of the four images in the horizontal, vertical and diagonal directions. The results show that the correlation coefficients of the plaintext images in the three directions are very high, while the correlation coefficients of the ciphertext images are very low, very close to 0, which indicates that the correlation between the plaintext images and the ciphertext images has been significantly reduced, which is conducive to resisting statistical attacks and greatly improves the security of the algorithm.
[0174]
[0175] Table 6 Correlation coefficients between plaintext images and ciphertext images
[0176] In addition, in the scrambling stage, this embodiment calls a two-dimensional chaotic map to perform scrambling according to the key key1. Let L be the number of bits of key1, and the time complexity is θ(9L×N 2 The time complexity of DNA encoding operation is θ(3×N 2 ), the time complexity of DNA decoding is θ(N 2 ). The time complexity of the entire encryption algorithm is θ((9L+4)×N 2 ). Due to the high parallelism of DNA computing, the speed of encryption algorithms can be further improved.
[0177] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the image fast encryption method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0178] This application also provides a fast image encryption device, please refer to Figure 5 , the image fast encryption device comprises:
[0179] Initialization module 10, used for performing two-dimensional chaotic mapping on the plaintext image to be encrypted based on a preset first key to obtain a scrambled image, and generating a coding lookup table based on a preset second key;
[0180] A preliminary encoding module 20, used for genetically encoding the scrambled image through dynamic encoding to obtain a preliminary encoded image;
[0181] A preliminary obfuscation module 30, configured to search and replace each code in the preliminary coded image in the code lookup table to obtain a replaced preliminary obfuscated image;
[0182] The encryption module 40 is used to traverse each target element in the preliminary obfuscated image starting from the second bit in the preliminary obfuscated image, perform an XOR operation on the target element and the element of the previous bit of the target element, and obtain a ciphertext matrix after encrypting the plaintext image.
[0183] Optionally, the initialization module 10 is further used to:
[0184] Obtaining a current number of split rounds, and determining a target value on a target number of bits in the first key, wherein the target number of bits corresponds to the current number of split rounds;
[0185] Dividing the plaintext image into two sub-images along a diagonal direction based on the number of segmentation rounds;
[0186] For each of the sub-images, dividing the sub-image into at least one group of pixel sets, wherein the pixel set includes two columns of adjacent sub-pixel sets;
[0187] For each group of the pixel sets, determine each short pixel in the shorter sub-pixel set among the adjacent sub-pixel sets and each long pixel in the longer sub-pixel set among the adjacent sub-pixel sets, and insert each of the short pixels in sequence between each of the long pixels to obtain an intermediate image;
[0188] Connecting pixels in the intermediate image according to a preset connection rule to obtain an intermediate image;
[0189] Taking the intermediate image as a new plaintext image, returning to the step of dividing the plaintext image into two sub-images in a diagonal direction based on the number of division rounds, until the number of divisions is equal to the target value, and updating the number of division rounds;
[0190] Return to the step of obtaining the current number of segmentation rounds until the number of segmentation rounds is equal to the length of the first key, and use the current intermediate image as the scrambled image.
[0191] Optionally, the initialization module 10 is further used to:
[0192] If the number of segmentation rounds is an odd number, the plaintext image is segmented into two sub-images from the upper left to the lower right along the diagonal direction;
[0193] If the number of segmentation rounds is an even number, the plaintext image is segmented into two sub-images along a diagonal direction from the upper right to the lower left.
[0194] Optionally, the initialization module 10 is further used to:
[0195] Generate an initial array of a preset size, and perform a two-dimensional chaotic mapping on the initial array based on the last four bits of the second key to obtain a scrambled array;
[0196] Genetically encoding the scrambled array according to a preset encoding rule to obtain an encoding matrix;
[0197] The row and column indexes of the encoding matrix are defined according to a preset index rule to obtain an encoding lookup table.
[0198] Optionally, the preliminary encoding module 20 is further used for:
[0199] Starting from the second bit in the scrambled image, each target pixel value in the scrambled image is traversed, and based on the pixel value of the previous bit of the target pixel value, the target pixel value is updated until the last pixel value in the scrambled image is traversed to obtain the preliminary encoded image.
[0200] Optionally, the image fast encryption device is also used for:
[0201] Decoding the first bit in the ciphertext matrix based on the second key to obtain a pixel value of the first bit after decoding;
[0202] Starting from the second bit of the ciphertext matrix, each target ciphertext in the ciphertext matrix is traversed, and the pixel value of the target ciphertext is calculated based on the pixel value of the decoded ciphertext of the previous bit of the target ciphertext to obtain the plaintext image after the ciphertext matrix is decoded.
[0203] The image fast encryption device provided by the present application adopts the image fast encryption method in the above embodiment, which can solve the technical problem of how to improve the security of image encryption. Compared with the prior art, the beneficial effects of the image fast encryption device provided by the present application are the same as the beneficial effects of the image fast encryption method provided by the above embodiment, and the other technical features in the image fast encryption device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0204] The present application provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the image fast encryption method in the above-mentioned embodiment one.
[0205] like Figure 6As shown, the electronic device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the electronic device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows an electronic device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0206] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0207] The electronic device provided by the present application adopts the image fast encryption method in the above embodiment, which can solve the technical problem of how to improve the security of image encryption. Compared with the prior art, the beneficial effects of the electronic device provided by the present application are the same as the beneficial effects of the image fast encryption method provided by the above embodiment, and the other technical features in the electronic device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0208] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0209] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0210] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, wherein the computer-readable program instructions are used to execute the image fast encryption method in the above-mentioned embodiment.
[0211] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.
[0212] The computer-readable storage medium may be included in the electronic device, or may exist independently without being installed in the electronic device.
[0213] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by an electronic device, the electronic device: performs two-dimensional chaotic mapping on the plaintext image to be encrypted based on a preset first key to obtain a scrambled image, and generates a coding lookup table based on a preset second key; genetically encodes the scrambled image through dynamic coding to obtain a preliminary coded image; searches and replaces each code in the preliminary coded image in the coding lookup table to obtain a replaced preliminary obfuscated image; traverses each target element in the preliminary obfuscated image starting from the second bit in the preliminary obfuscated image, performs an XOR operation on the target element and the element before the target element, and obtains a ciphertext matrix after encrypting the plaintext image.
[0214] The computer program code for performing the operation of the present application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on the remote computer, or entirely on the remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0215] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0216] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0217] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned image fast encryption method, and can solve the technical problem of how to improve the security of image encryption. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the image fast encryption method provided by the above-mentioned embodiment, and will not be repeated here.
[0218] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned image fast encryption method when executed by a processor.
[0219] The computer program product provided by this application can solve the technical problem of how to improve the security of image encryption. Compared with the prior art, the beneficial effects of the computer program product provided by this application are the same as the beneficial effects of the image fast encryption method provided by the above embodiment, which will not be repeated here.
[0220] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A method for fast image encryption, characterized in that: The method comprises: Performing two-dimensional chaotic mapping on the plaintext image to be encrypted based on a preset first key to obtain a scrambled image, and generating a coding lookup table based on a preset second key; Genetically encoding the scrambled image through dynamic encoding to obtain a preliminary encoded image; Search and replace each code in the preliminary coded image in the code lookup table to obtain a preliminary obfuscated image after replacement; Starting from the second bit in the preliminary obfuscated image, each target element in the preliminary obfuscated image is traversed, and an XOR operation is performed on the target element and the element of the previous bit of the target element to obtain a ciphertext matrix after encrypting the plaintext image.
2. The image fast encryption method according to claim 1, characterized in that: The step of performing two-dimensional chaotic mapping on the plaintext image to be encrypted based on the preset first key to obtain a scrambled image comprises: Obtaining a current number of split rounds, and determining a target value on a target number of bits in the first key, wherein the target number of bits corresponds to the current number of split rounds; Dividing the plaintext image into two sub-images along a diagonal direction based on the number of segmentation rounds; For each of the sub-images, dividing the sub-image into at least one group of pixel sets, wherein the pixel set includes two columns of adjacent sub-pixel sets; For each group of the pixel sets, determine each short pixel in the shorter sub-pixel set among the adjacent sub-pixel sets and each long pixel in the longer sub-pixel set among the adjacent sub-pixel sets, and insert each of the short pixels in sequence between each of the long pixels to obtain an intermediate image; Connecting pixels in the intermediate image according to a preset connection rule to obtain an intermediate image; Taking the intermediate image as a new plaintext image, returning to the step of dividing the plaintext image into two sub-images in a diagonal direction based on the number of division rounds, until the number of divisions is equal to the target value, and updating the number of division rounds; Return to the step of obtaining the current number of segmentation rounds until the number of segmentation rounds is equal to the length of the first key, and use the current intermediate image as the scrambled image.
3. The image fast encryption method according to claim 2, characterized in that: The step of dividing the plaintext image into two sub-images in a diagonal direction based on the number of division rounds includes: If the number of segmentation rounds is an odd number, the plaintext image is segmented into two sub-images from the upper left to the lower right along the diagonal direction; If the number of segmentation rounds is an even number, the plaintext image is segmented into two sub-images along a diagonal direction from the upper right to the lower left.
4. The image fast encryption method according to claim 1, characterized in that: The step of generating a coding lookup table based on a preset second key comprises: Generate an initial array of a preset size, and perform a two-dimensional chaotic mapping on the initial array based on the last four bits of the second key to obtain a scrambled array; Genetically encoding the scrambled array according to a preset encoding rule to obtain an encoding matrix; The row and column indexes of the encoding matrix are defined according to a preset index rule to obtain an encoding lookup table.
5. The image fast encryption method according to claim 1, characterized in that: The step of genetically encoding the scrambled image by dynamic encoding to obtain a preliminary encoded image comprises: Starting from the second bit in the scrambled image, each target pixel value in the scrambled image is traversed, and based on the pixel value of the previous bit of the target pixel value, the target pixel value is updated until the last pixel value in the scrambled image is traversed to obtain the preliminary encoded image.
6. The image fast encryption method according to claim 1, characterized in that: After the step of obtaining the ciphertext matrix after encrypting the plaintext image, the method further includes: Decoding the first bit in the ciphertext matrix based on the second key to obtain a pixel value of the first bit after decoding; Starting from the second bit of the ciphertext matrix, each target ciphertext in the ciphertext matrix is traversed, and the pixel value of the target ciphertext is calculated based on the pixel value of the decoded ciphertext of the previous bit of the target ciphertext to obtain the plaintext image after the ciphertext matrix is decoded.
7. A fast image encryption device, characterized in that: The device comprises: An initialization module, used for performing two-dimensional chaotic mapping on the plaintext image to be encrypted based on a preset first key to obtain a scrambled image, and generating a coding lookup table based on a preset second key; A preliminary encoding module, used for genetically encoding the scrambled image through dynamic encoding to obtain a preliminary encoded image; A preliminary obfuscation module, used for searching and replacing each code in the preliminary coded image in the code lookup table to obtain a replaced preliminary obfuscated image; The encryption module is used to traverse each target element in the preliminary obfuscated image starting from the second bit in the preliminary obfuscated image, perform an XOR operation on the target element and the element of the previous bit of the target element, and obtain a ciphertext matrix after encrypting the plaintext image.
8. An electronic device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the image fast encryption method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the image fast encryption method according to any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the image fast encryption method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Image encryption method based on chaotic sequence and DNA coding
CN113225449A
Logistic-based large key space bit scrambling chaotic image encryption method
CN114418823A
Image encryption algorithm based on multi-chaotic system and cyclic DNA operation and electronic equipment
CN117440101A
Reversible DNA information hiding method based on prediction-error expansion and histrogram shifting
US20190251268A1
Image encryption communication algorithm based on two-dimensional lag-complex logistic mapping, and image decryption communication algorithm based on two-dimensional lag-complex logistic mapping
WO2022077793A1
Cited By
Blood glucose data encryption transmission method and device, equipment and storage medium
CN121750345A