An image encryption method and decryption method
By generating an adaptive key using a five-dimensional Hamiltonian conservative hyperchaotic system and the SHA-512 hash algorithm, and combining double-reset scrambling and secondary diffusion, the problem of uneven distribution of chaotic orbits in the Hamiltonian system is solved, thereby improving the security and anti-attack capability of image encryption.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- FUYANG NORMAL UNIVERSITY
- Filing Date
- 2026-03-19
- Publication Date
- 2026-05-29
AI Technical Summary
Existing image encryption algorithms based on the Hamiltonian system suffer from uneven distribution of chaotic orbits and insufficient randomness, resulting in low resistance to differential attacks.
A five-dimensional Hamiltonian conservative hyperchaotic system is adopted, combined with the SHA-512 hash algorithm to generate an adaptive key. Through a double reset scrambling and secondary diffusion mechanism, the image is decomposed into multiple bit planes. The plaintext feedback chaotic sequence and the main chaotic sequence are used for diffusion and scrambling to generate an encrypted image.
It improves the image encryption's resistance to differential attacks, enhances the key space and information entropy, reduces pixel correlation, and achieves highly secure image transmission.
Smart Images

Figure CN122120388A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image encryption technology, and in particular to an image encryption method and a decryption method. Background Technology
[0002] With the widespread application of digital image processing technology in fields such as military reconnaissance, medical diagnosis, and financial transactions, image data faces security threats such as theft, tampering, and forgery during transmission and storage. Traditional encryption algorithms (such as AES and RSA) suffer from low encryption efficiency and high resource consumption due to their inability to adapt to the high redundancy and strong correlation characteristics of images. Chaotic systems, with their sensitivity to initial conditions and parameters, ergodicity, and pseudo-randomness, offer a new approach to image encryption. Image encryption algorithms based on chaotic systems offer advantages such as fast encryption speed, large key space, and high security, making them a current research hotspot in the field of image encryption.
[0003] In existing technologies, high-dimensional hyperchaotic systems increase complexity by adding state variables. Among them, Hamiltonian conservative hyperchaotic systems combine energy conservation properties with rich dynamic behaviors, and their long-term unpredictability is significantly better than that of dissipative systems, providing an ideal mathematical model for constructing high-security encryption algorithms.
[0004] However, due to the conservation of phase space volume and the periodic or quasi-periodic distribution of orbits in Hamiltonian systems, chaotic orbits cannot cover the entire phase space, resulting in uneven distribution of the generated chaotic sequences and insufficient random statistical characteristics. Consequently, the above methods are not very resistant to differential attacks. Summary of the Invention
[0005] Therefore, it is necessary to provide an image encryption and decryption method to address the aforementioned technical problems.
[0006] The following technical solution is adopted in this specification: This specification provides an image encryption method, including: Obtain the image to be encrypted and the initial key; A five-dimensional Hamiltonian conservative hyperchaotic system is constructed, and the plaintext feedback chaotic sequence and the main chaotic sequence are generated iteratively based on the initial key. The image to be encrypted is decomposed into multiple bit planes. Each bit plane is assigned an independent subsequence based on the plaintext feedback chaotic sequence, and a binary code related to the pixel position of the image to be encrypted is generated. The pixels of each bit plane are diffused based on the subsequence and the binary code. The diffused bit planes are merged to obtain the first diffused image. A first scrambling index and a second scrambling index are generated based on the main chaotic sequence. The first scrambling index is used to scramble the pixel positions of the first diffusion image to obtain the first scrambling image. By performing modulo-256 addition on the pixel values of the first scrambled image, the main chaotic sequence, and the position encoding of the first scrambled image, pixel-level diffusion is achieved to obtain the second diffused image. The second scrambling index is used to scramble the pixel positions of the second diffusion image to obtain an encrypted image.
[0007] Furthermore, the initial key includes six initial control parameters of the five-dimensional Hamiltonian conservative hyperchaotic system. and the initial values of the five state variables. Before the step of iteratively generating the plaintext feedback chaotic sequence and the main chaotic sequence based on the initial key-driven five-dimensional Hamiltonian conservative hyperchaotic system, the step of updating the initial key is also included: The image to be encrypted is converted into a byte data stream, and the SHA-512 hash algorithm is used to encrypt the byte data stream to generate a hash value data with a length of 512 bits. The 512-bit hash value is segmented and converted into 10 floating-point numbers with values in the range [-5, 5]. ; in, Represents floating-point numbers , ; Represents the number retrieval function; This represents the 512-bit hash value. Ranked first A sub-fragment of a position; The initial values of the five state variables and the five initial control parameters in the initial key are updated based on ten floating-point numbers ranging from -5 to 5: ; ; Among them, the initial parameters As a constant energy term in a conservative chaotic system, it does not participate in key updates; , , , and For the updated state variables; , , , and These are the updated control parameters.
[0008] Furthermore, the iterative generation of plaintext feedback chaotic sequences and main chaotic sequences based on the initial key-driven five-dimensional Hamiltonian conservative hyperchaotic system specifically includes: Constructing the dynamic equations of a five-dimensional Hamiltonian conservative hyperchaotic system: ; Where a, b, c, d, e, and f are the six initial control parameters of the five-dimensional Hamiltonian conservative hyperchaotic system. For the five state variables of a five-dimensional Hamiltonian conservative hyperchaotic system; The dynamic equations of the five-dimensional Hamiltonian conservative hyperchaotic system are solved iteratively by using the fourth-order Runge-Kutta method. The number of iterations is the total number of pixels in the image to be encrypted × 4 × the preset number of diffusion rounds. The state variables obtained by iterative update solution at each step Multi-dimensional fusion processing is performed to generate a basic chaotic sequence: ; Where seq[i] is based on the state variable of step i. The obtained basic chaotic sequence value; By configuring different initial values for the basic chaotic sequence, plaintext feedback chaotic sequences are generated. and the main chaotic sequence ,in, Generate plaintext feedback chaotic sequence At that time, the initial values of the control parameters of the configured five-dimensional Hamiltonian conservative hyperchaotic system are: The initial value of the state variable is ; Generate the main chaotic sequence At that time, the initial values of the control parameters of the configured five-dimensional Hamiltonian conservative hyperchaotic system are: The initial value of the state variable is .
[0009] Furthermore, obtaining the first diffusion image specifically includes: Each pixel value of the image to be encrypted is converted into 8 bits of binary data, forming 8 binary bit planes in descending order of bit height. i ; Based on plaintext feedback chaotic sequence Assign a corresponding sub-plaintext feedback chaotic sequence to each bit plane : ; in, The total number of pixels in the image to be encrypted. The chaotic sequence is fed back in plaintext; Binary position codes are generated by XORing the grid matrix of pixel coordinates of the image to be encrypted. : ; in, The width of the image to be encrypted. The height of the image to be encrypted. Represents the XOR operation; This represents the modulo operation; Perform two XOR fusion operations on the eight bit planes to obtain eight first diffusion bit planes. : ; The eight first diffusion bit planes are merged in bit order to obtain the first diffusion image.
[0010] Furthermore, the generation of the first scrambling index and the second scrambling index based on the main chaotic sequence specifically includes: From the main chaotic sequence Extract two segments from the image to be encrypted, along with the total number of pixels. First subsequence of equality and the second subsequence : ; ; Based on the first subsequence respectively and the second subsequence The first seed is obtained by summing the absolute values of the first 20 elements. Second seed : ; ; in, Indicates to Take the mold; Represents the number retrieval function; Based on the first seed respectively Second seed Generate the first permutation index Second permutation index : ; ; Where N represents the total number of pixels in the image to be encrypted; This is a random number generator used to generate random permutation sequences from 0 to N.
[0011] Further, the step of scrambling the pixel positions of the first diffused image using the first scrambling index to obtain the first scrambled image specifically includes: The pixel set of the first diffused image is indexed in a row-major manner using a one-dimensional serialization index, and the serialization index k is set, k= ; According to the first scrambling index Get the permutation value corresponding to the serialization index k. ; Replacement value Mapping to a two-dimensional coordinate system yields the target row coordinates. and target column coordinates ; The pixel values in the first diffused image are replaced with the corresponding positions in the first scrambled image to obtain the first scrambled image. : ; Where I represents the first diffused image, and the pixel value is represented as I(i,j), i∈[0,h−1],j∈[0,w−1]; This indicates the floor function.
[0012] Furthermore, obtaining the second diffuse image specifically includes: Position encoding for generating the first scrambled image : ; in, Indicates the pixel index of the first scrambled image; Represents the XOR operation; Indicates integer division; Based on the pixel values of the first scrambled image, the main chaotic sequence Position encoding of the first scrambled image Perform modulo 256 additive diffusion on the pixel values of the first scrambled image: ; in, Indicates the pixel value after diffusion; Represents the pixel values of the first scrambled image; This represents an addition operation modulo 256; A second diffused image is obtained by reconstructing a two-dimensional image based on the diffused pixel values.
[0013] Furthermore, in the process of iteratively updating and solving the dynamic equations of the five-dimensional Hamiltonian conservative hyperchaotic system using the fourth-order Runge-Kutta method, just-in-time compilation technology is used to accelerate the iterative calculation process.
[0014] This document provides an image decryption method, including: Obtain the encrypted image and the decrypted file; the decrypted file includes a first scrambling index. Second scrambled index Main chaotic sequence and plaintext feedback chaotic sequence ; First reverse scrambling: based on the second scrambling index Construct the first inverse index via the first inverted index The scrambled image is restored to its original pixel positions to obtain the first inverse scrambled image; wherein, the first inverse index satisfy: ; in, , , Image width, Image height; First inverse diffusion: based on the index of each pixel in the first inverse scrambling image Generate position code The first inversely scrambled image is reverse-diffused using the main chaotic sequence to recover pixel values, thus obtaining the first inversely diffused image. : ; ; in, These are the pixel values of the first inverted scrambled image. The position encoding of the first inverse scrambled image; Second reverse scrambling: First scrambling index Constructing a second inverse index via the second inverted index The first inverse diffusion image is restored to its original pixel position to obtain the second inverse scrambling image; Second bit-plane inverse diffusion: Convert each pixel value of the second inverse scrambled image into 8-bit binary data, forming 8 bit planes; for the i-th bit plane From plaintext feedback chaotic sequence Extracting subsequences : ; Binary position codes are generated by XORing the grid matrix of pixel coordinates. : ; Perform two XOR fusion operations on each of the eight bit planes to obtain eight diffuse bit planes. ; ; By merging the eight inverse diffusion bit planes, the decrypted image can be obtained.
[0015] The above-mentioned technical solutions adopted in this specification can achieve the following beneficial effects: In the first bit-plane diffusion stage, the image is decomposed into multiple bit-planes. Each bit-plane uses an independent plaintext feedback chaotic subsequence, combined with binary codes strongly bound to pixel positions for diffusion. This mechanism overcomes the limitation of the periodic distribution of Hamiltonian system orbits, making the generation of chaotic sequences no longer solely dependent on the dynamic evolution of the conservative system itself, thus enhancing the ergodicity and unpredictability of the sequence. Simultaneously, minute changes in a single pixel immediately diffuse to all bit-planes containing it, disrupting the local correlation of pixel values and effectively compensating for the statistical defects caused by uneven phase space sampling in conservative systems. Subsequently, the first scrambling rearranges these diffused bit-plane information into the entire image, further expanding the scope of influence of changes and breaking the orbital clustering characteristics under the isoenergetic surface constraints of Hamiltonian systems. Then, the second pixel-level diffusion, through modulo-256 addition, deeply fuses the main chaotic sequence and positional codes with pixel values, ensuring that any local change propagates to the entire image. Even if the plaintext differs by only a single bit, after two diffusions, the ciphertext produces different results, eliminating periodic traces that may appear in the long-term evolution of conservative systems. The second scrambling further disrupts pixel positions, preventing attackers from locating changed regions through differential analysis. This prevents attackers from exploiting the predictability of the Hamiltonian system's phase space structure for statistical inference. It also invalidates the plaintext-ciphertext correspondence required for differential attacks, thus enhancing resistance to differential attacks. Attached Figure Description
[0016] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0017] Figure 1 This is one of the flowcharts illustrating an image encryption method provided in this specification; Figure 2 This is the second flowchart illustrating an image encryption method provided in this specification. Figure 3 This is a flowchart illustrating an image decryption method provided in this specification; Figure 4 This document provides a schematic diagram of an image encryption method and an image decryption process. Figure 5 This is a schematic diagram illustrating an image encryption method and an image decryption framework provided in this specification. Figure 6 This specification provides a schematic diagram of a five-dimensional Hamiltonian hyperchaotic planar diffusion image encryption and decryption system. Figure 7 This is a schematic diagram illustrating the experimental verification of an image encryption method provided in this specification. Figure 7 (a) in the image is the original image; Figure 7 (b) in the image is an encrypted image; Figure 7 (c) in the image is the encrypted image after modifying 1 pixel; Figure 7 (d) in the image is the decrypted image; Figure 8 A comparative schematic diagram of pixel distribution histograms for an image encryption method provided in this specification; Figure 8 (a) in the image is the histogram of the original image; Figure 8 (b) in the diagram is the encrypted image histogram. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this specification clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments in this specification without creative effort are within the scope of protection of this application.
[0019] The technical solution provided by this invention can be applied to image encryption scenarios. In recent years, scholars have conducted extensive research on chaotic image encryption. Wang Xingyuan et al. designed an image encryption algorithm based on Logistic chaotic mapping, achieving encryption through scrambling and diffusion, but the key space of low-dimensional systems is limited; Xuncai Zhang et al. used the Lorenz system to generate pseudo-random sequences, but still suffer from insufficient resistance to attacks. To improve security, Wang Yue et al. proposed a four-dimensional hyperchaotic image encryption algorithm, and Gao Liang et al. designed a five-dimensional hyperchaotic encryption scheme, but such algorithms do not fully utilize the plaintext feedback mechanism and have weak adaptive capabilities. Jiao Kaixin et al. introduced a generalized Arnold mapping to achieve bit-level encryption and optimized the scrambling effect, but the chaotic system has a low dimension, and the key space needs to be expanded.
[0020] In the application of high-dimensional chaotic systems, K. Sundara et al. proposed a 3D chaotic dynamical system encryption mechanism combined with SHA-512, which effectively improves the resistance to chosen-plaintext attacks by dynamically adjusting chaotic parameters. Yan Shaohui et al. designed an encryption algorithm based on a multistable fractional-order five-dimensional hyperchaotic system, using cross-plane scrambling to enhance spatial randomness, but the encryption efficiency is limited by fractional-order computation. In the field of bit-plane encryption technology, Wen Heping et al. proposed a block-based bit-plane encryption scheme, which adapts to variable-size images through group processing, but the diffusion strength does not achieve adaptive adjustment. Existing research still has room for improvement in areas such as high-dimensional chaotic system optimization and adaptive diffusion design.
[0021] Based on this, and addressing the problems of limited key space, weak anti-attack capability, and insufficient sensitivity to plaintext in traditional image encryption algorithms, this invention proposes an adaptive bit-plane diffusion image encryption algorithm based on a five-dimensional Hamiltonian conservative hyperchaotic system. This algorithm uses a five-dimensional Hamiltonian conservative hyperchaotic system with complex dynamic characteristics as its core, generating pseudo-random sequences using these complex dynamic characteristics. It combines bit-plane decomposition and an adaptive diffusion strategy, along with the SHA-512 hash function to achieve plaintext feedback key expansion. Double-reset scrambling and secondary diffusion disrupt the spatial correlation and pixel value correlation of the image, and an adaptive bit-plane diffusion strategy optimizes the pixel value distribution. Experimental results show that the total difference between the decrypted image and the original image is 0, the maximum information entropy of the encrypted image reaches 7.9992, the correlation between adjacent pixels is reduced to within ±0.005, and the NPCR and UACI indices in the differential attack resistance test reach 99.5544% and 33.4762%, respectively. Furthermore, the average encryption efficiency for 256×256 images reaches 113,900 pixels / second. Experimental verification on standard test images shows that the algorithm has the characteristics of sufficient key space, high information entropy, low pixel correlation and excellent anti-attack performance. It can effectively resist exhaustive attacks, statistical attacks and differential attacks, and is suitable for high-security image transmission scenarios.
[0022] The image encryption method and image decryption method of the present invention are described below with reference to the accompanying drawings.
[0023] Figure 1 This is one of the flowcharts illustrating an image encryption method provided in this specification, such as... Figure 1 As shown, the method includes: S1. Obtain the image to be encrypted and the initial key.
[0024] For example, the initial key consists of six initial control parameters for a five-dimensional Hamiltonian conservative hyperchaotic system. and the initial values of the five state variables. After obtaining the initial key, it needs to be updated based on the hash value of the image to be encrypted. SHA-512 is a hash standard released by NIST, which can map inputs of arbitrary length to a fixed 512-bit hash value. It has collision resistance, one-way hashing, and avalanche effect, and its security is significantly better than short hash algorithms such as SHA-256. Using SHA-512 to extract the byte features of the plaintext image, the generated hash value is used to adjust the parameters and initial values of the chaotic system, achieving adaptive binding between the key and plaintext. By segmenting the hash value into 10 floating-point numbers in the range [-5, 5], the 6 parameters and 5 initial values of the chaotic system are dynamically adjusted respectively, ensuring that different plaintexts correspond to different key streams. This completely solves the vulnerability of known plaintext attacks compared to traditional fixed-key schemes. Specifically:
[0025] The image to be encrypted is converted into a byte data stream. The SHA-512 hash algorithm is then used to encrypt the byte data stream, generating a 512-bit hash value. This 512-bit hash value is then segmented and converted into 10 floating-point numbers ranging from -5 to 5. The initial values of the five state variables and five initial control parameters in the initial key are updated based on these 10 floating-point numbers. ; ; ; in, Represents floating-point numbers , ; Represents the number retrieval function; This represents the 512-bit hash value. Ranked first The hash value is divided into segments of 512 bits (corresponding to 64 bytes). Four bytes are taken sequentially from front to back, repeated 10 times, with the remaining bytes discarded, resulting in 10 data segments saved to [the appropriate data type]. In the array, then update the initial key. Initial parameters As a constant energy term in a conservative chaotic system, it does not participate in key updates; , , , and For the updated state variables; , , , and These are the updated control parameters.
[0026] S2. Construct a five-dimensional Hamiltonian conservative hyperchaotic system, and use the initial key to drive the five-dimensional Hamiltonian conservative hyperchaotic system to iteratively generate plaintext feedback chaotic sequence and main chaotic sequence.
[0027] For example, the five-dimensional Hamiltonian conservative hyperchaotic system satisfies energy conservation, has a constant phase space volume, exhibits undiminished chaotic behavior, and demonstrates significantly better long-term unpredictability than dissipative systems. The constructed dynamic equations of the five-dimensional Hamiltonian conservative hyperchaotic system are as follows:
[0028] '' Where a, b, c, d, e, and f are the six initial control parameters of the five-dimensional Hamiltonian conservative hyperchaotic system, which can be set as follows: ; These are the five state variables of a five-dimensional Hamiltonian conservative hyperchaotic system. The system has multiple positive Lyapunov exponents (the largest reaching 1.87), exhibits rich chaotic behavior, and can generate pseudo-random sequences with different characteristics by adjusting the parameters.
[0029] Then, the dynamic equations of the five-dimensional Hamiltonian conservative hyperchaotic system are iteratively updated and solved using the fourth-order Runge-Kutta method. During the solution process, to improve sequence generation efficiency, Numba just-in-time compilation is used to accelerate the system iteration process, converting Python loops into machine code execution, significantly reducing computation time. Chaotic sequence generation and purification employ the fourth-order Runge-Kutta method to solve the differential equations of the chaotic system. This method improves accuracy by three orders of magnitude compared to the Euler method, effectively avoiding sequence degradation. Combined with Numba acceleration, generation efficiency is significantly improved. The steps are as follows: 1. System warm-up: Iterate 5000 times, skipping the initial transient state to ensure the sequence enters a stable chaotic state. 2. Sequence generation: Iterate at a length of 4 times the total number of image pixels, updating the state variables each time. 3. Boundary constraints: Clip the state variables to [-500, 500] to avoid numerical overflow. 4. Sequence purification: Detect and replace NaN / infinity values, fill outliers with the effective sequence mean, and improve sequence uniformity by 8% compared to the neighbor-filling scheme, ensuring the stability of subsequent operations. 5. Reversible Normalization: The sequence is mapped to [0, 255] through a linear transformation, and the normalization parameters (minimum and maximum values) are saved for decryption, ensuring the transformation is reversible and avoiding decryption distortion compared to nonlinear normalization schemes. The number of iterative update steps is the total number of pixels in the image to be encrypted × 4 × the preset number of diffusion rounds; where the iterative update formula for the state variable in the (n+1)th step is:
[0030] ; ; in, = , = , = , = ; Step size; and These are the state variables at the n-step and the state variables at the (n+1)-step of the five-dimensional Hamiltonian conservative hyperchaotic system. This is the mapping function for the system of dynamic equations. It represents the state variables obtained at each step of the iterative solution. Perform multi-dimensional fusion processing to generate a basic chaotic sequence: seq[i] = sin( )*10+cos( )*10+ sin( )*10+cos( )*10+sin( )*10; where seq[i] is the basic chaotic sequence value of the i-th step.
[0031] By configuring different initial values for the basic chaotic sequence, plaintext feedback chaotic sequences are generated. and the main chaotic sequence Among them, generating plaintext feedback chaotic sequences At that time, the initial values of the control parameters of the configured five-dimensional Hamiltonian conservative hyperchaotic system are: The initial value of the state variable is Generate the main chaotic sequence At that time, the initial values of the control parameters of the configured five-dimensional Hamiltonian conservative hyperchaotic system are: The initial value of the state variable is .
[0032] After obtaining the plaintext feedback chaotic sequence and the main chaotic sequence in step S2, scrambling and diffusion operations can be performed based on these two sequences. Scrambling disrupts the spatial correlation of the image by changing the spatial position of pixels, while diffusion propagates changes in a single pixel to the entire image by adjusting the pixel grayscale value. The collaboration of these two operations is the core mechanism for ensuring encryption security. A double-scrambling method generates two permutation indices, achieving pixel-level scrambling, which improves the correlation reduction by 15% compared to single-scrambling. Diffusion uses modulo-256 addition and subtraction operations, combined with bit-plane characteristics and positional encoding to achieve adaptive and reversible diffusion, ensuring uniform statistical characteristics of the ciphertext and lossless decryption.
[0033] S3. Decompose the image to be encrypted into multiple bit planes, assign independent subsequences to each bit plane based on the plaintext feedback chaotic sequence, and generate binary codes related to the pixel positions of the image to be encrypted. Perform diffusion processing on the pixels of each bit plane based on the subsequences and binary codes, and merge the diffused bit planes to obtain the first diffused image.
[0034] For example, each pixel value of the image to be encrypted is converted into 8 bits of binary data, forming 8 binary bit planes in descending bit order. i Bit-plane decomposition divides each pixel value of an 8-bit grayscale image into eight binary bit planes (bits 0-7). The higher bit planes (bits 4-7) carry more than 75% of the visual information of the image, while the lower bit planes (bits 0-3) are mainly noise. Bit-plane decomposition disperses image information across different layers, and combined with a differentiated diffusion strategy, it can effectively improve encryption security and enhance resistance to statistical attacks. (Based on plaintext feedback chaotic sequences) Assign a corresponding sub-plaintext feedback chaotic sequence to each bit plane : ;in, The total number of pixels in the image to be encrypted. The plaintext feedback is a chaotic sequence. A binary position code is generated by XORing the grid matrix of pixel coordinates in the image to be encrypted. Two XOR fusion operations are performed on each of the eight bit planes to obtain eight first diffusion bit planes. : The eight first diffusion bit planes are merged in bit order to obtain the first diffusion image. The binary position encoding is used in this process. The calculation formula is:
[0035] ; in, The width of the image to be encrypted. The height of the image to be encrypted. Represents the XOR operation; This indicates the modulo operation.
[0036] S4. Generate a first scrambling index and a second scrambling index based on the main chaotic sequence. Use the first scrambling index to scramble the pixel positions of the first diffusion image to obtain the first scrambled image.
[0037] For example, the steps of generating the first scrambled index and the second scrambled index include: from the main chaotic sequence Extract two segments from the image to be encrypted, along with the total number of pixels. First subsequence of equality and the second subsequence Based on the first subsequence respectively and the second subsequence The first seed is obtained by summing the absolute values of the first 20 elements. Second seed ;in, Indicates to Take the mold; This represents the number retrieval function. It is based on the first seed. Second seed Generate the first permutation index Second permutation index :
[0038] ; ; Where N represents the total number of pixels in the image to be encrypted; This is a random number generator used to generate random permutation sequences from 0 to N.
[0039] For example, the step of scrambling the pixel positions of the first diffused image using the first scrambling index includes: performing a one-dimensional serialization index on the pixel set of the first diffused image in row-major order, and setting the serialization index k, k= According to the first scramble index Get the permutation value corresponding to the serialization index k. ; Replace the value Mapping to a two-dimensional coordinate system yields the target row coordinates. and target column coordinates The pixel values in the first diffused image are replaced with the corresponding positions in the first scrambled image to obtain the first scrambled image. Where I represents the first diffused image, and the pixel value is represented as I(i,j), i∈[0,h−1],j∈[0,w−1]; This indicates the floor function.
[0040] S5. By performing modulo 256 addition on the pixel values of the first scrambled image, the main chaotic sequence, and the position encoding of the first scrambled image, pixel-level diffusion is achieved to obtain the second diffused image.
[0041] Specifically, the positional encoding of the first scrambled image is generated. ;in, Indicates the pixel index of the first scrambled image; Represents the XOR operation; Integer division; based on the pixel values of the first scrambled image and the main chaotic sequence. Position encoding of the first scrambled image Perform modulo 256 additive diffusion on the pixel values of the first scrambled image: ;in, Indicates the pixel value after diffusion; Represents the pixel values of the first scrambled image; This represents an addition operation modulo 256; a two-dimensional image is reconstructed based on the diffused pixel values to obtain a second diffused image.
[0042] S6. Use the second scrambling index to scramble the pixel positions of the second diffusion image to obtain an encrypted image.
[0043] For example, the step of scrambling the pixel positions of the second diffused image using the second scrambling index is the same as the step of scrambling the pixel positions of the first diffused image using the first scrambling index.
[0044] Figure 2 This is the second flowchart illustrating an image encryption method provided in this specification, as shown below. Figure 2As shown, after encryption begins, the original image and an 11-dimensional initial key are first input. Then, plaintext features are extracted using SHA-512 hashing, and the initial key is adjusted. Subsequently, a plaintext feedback chaotic sequence and a main chaotic sequence are generated using a five-dimensional Hamiltonian hyperchaotic system iteration, system preheating, and the fourth-order Runge-Kutta method. The sequences are then purified, and two segments are extracted from the main chaotic sequence to generate two scrambling indices. The first bit-plane diffusion is then performed, which involves diffusion of the eight bit planes based on the feedback chaotic sequence and merging the resulting bit planes. After the first bit-plane diffusion, the first scrambling is performed, rearranging the pixel positions according to the indices. Then, the second diffusion is performed, which involves diffusion of the scrambled image based on the main chaotic sequence. The second scrambling is then performed, rearranging the pixel positions according to the indices again. Finally, the encrypted image and auxiliary decryption information are output.
[0045] Figure 3 This is a flowchart illustrating an image decryption method provided in this specification, such as... Figure 3 As shown, after decryption begins, the encrypted image and decryption file are first input, and the decryption key information is read from the file. Then, the first inverse scrambling is performed. By constructing an inverse index and extracting pixels using the inverse index, the scrambled image is restored to its original pixel positions. Next, the first inverse diffusion is performed, using the main chaotic sequence to perform inverse diffusion to restore pixel values. Then, the second inverse scrambling is performed, again constructing an inverse index and extracting pixels using the inverse index to restore the scrambled image to its original pixel positions. Finally, the second bit-plane inverse diffusion is performed, sequentially performing inverse diffusion on 8 bit planes based on the feedback chaotic sequence, and then merging the 8 inverse-diffused bit planes to restore pixel values. After completing the above steps, the difference between the decrypted image and the original image is verified, and the decrypted image is finally output. Specifically, the decryption steps include:
[0046] Step 1: Obtain the encrypted image and the decrypted file; the decrypted file includes a first scrambling index. Second scrambled index Main chaotic sequence and plaintext feedback chaotic sequence .
[0047] Step 2, First Reverse Scrambling: Based on the Second Scrambling Index Construct the first inverse index via the first inverted index The scrambled image is restored to its original pixel positions to obtain the first inverse scrambled image; wherein, the first inverse index satisfy: ; in, , , Image width, This represents the image height.
[0048] Step 3, First Reverse Diffusion: Based on the index of each pixel in the first reverse scrambling image Generate position code The first inversely scrambled image is reverse-diffused using the main chaotic sequence to recover pixel values, thus obtaining the first inversely diffused image. : ; ; in, These are the pixel values of the first inverted scrambled image. The position encoding for the first inverse scrambled image.
[0049] Step 4, Second Reverse Scrambling: First Scrambling Index Constructing a second inverse index via the second inverted index The first inverse diffusion image is restored to its original pixel position to obtain the second inverse scrambling image; Step 5, Second Bit-Plane Inverse Diffusion: Convert each pixel value of the second inverse scrambling image into 8-bit binary data, forming 8 bit planes; for the i-th bit plane... From plaintext feedback chaotic sequence Extracting subsequences : ; Binary position codes are generated by XORing the grid matrix of pixel coordinates. : ; Perform two XOR fusion operations on each of the eight bit planes to obtain eight diffuse bit planes. ; .
[0050] Step 6: Merge the 8 inverse diffusion bit planes to obtain the decrypted image.
[0051] Figure 4 This specification provides a schematic diagram of an image encryption method and an image decryption process, such as... Figure 4 As shown, the image encryption and decryption steps provided in this embodiment include: S101. Encryption initialization: Input the original grayscale image I (size H×W) and the 11-dimensional initial key K, wherein the initial key K contains 6 parameters and 5 initial values of the five-dimensional Hamiltonian conservative hyperchaotic system.
[0052] S102, Plaintext Feature Extraction and Key Expansion: Convert the original grayscale image I into byte data, generate a 512-bit hash value using the SHA-512 hash function, divide the hash value into 10 floating-point numbers in the range [-5, 5], and dynamically adjust the 6 parameters and 5 initial values of the five-dimensional Hamiltonian conservative hyperchaotic system respectively.
[0053] S103. Chaotic Sequence Generation and Purification: The differential equations of the five-dimensional Hamiltonian conservative hyperchaotic system are solved using the fourth-order Runge-Kutta method. The iteration process is accelerated by Numba just-in-time compilation. After 5000 system warm-ups, boundary constraints, outlier replacement, and reversible linear normalization, a purified plaintext feedback chaotic sequence and a main chaotic sequence of length 4×H×W are generated. The first subsequence and the second subsequence, which are equal to the total number of pixels N, are extracted sequentially from the main chaotic sequence. Based on the two subsequences, the first scrambling index indices1 and the second scrambling index indices2 are generated respectively.
[0054] S104, First Bit-Plane Diffusion and Scrambling: The image to be encrypted is decomposed into 8 bit planes. Based on the plaintext feedback chaotic sequence, each bit plane is diffused sequentially to obtain multiple diffused bit planes. The diffused bit planes are merged to generate the image after the first diffusion. Based on the first scrambling index indices1, the pixel positions of the image after the bit-plane diffusion are rearranged to obtain the scrambled image.
[0055] S105, Second Diffusion and Scrambling: Introducing positional encoding, the pixel values of the image after the first scrambling are sequentially added to the main chaotic sequence and the positional encoding, and then diffused modulo 256 to generate the second diffused image; based on the second scrambling index indices2, the diffused image is scrambled to generate the ciphertext image I', and auxiliary information is saved.
[0056] S106. Decryption Process: Input the ciphertext image I' and the decryption file, and read the decryption key information such as the first and second permutation indices, the main chaotic sequence, and the plaintext feedback chaotic sequence; based on... Perform the first inverse scrambling, and then perform the first inverse diffusion based on the main chaotic sequence; based on Perform a second inverse scrambling, perform a first inverse diffusion based on the main chaotic sequence; perform a second bit-plane inverse diffusion based on the plaintext feedback chaotic sequence, output the decrypted image I'', and the total difference between I'' and the original grayscale image I is 0.
[0057] Figure 5 This specification provides a schematic diagram of an image encryption method and an image decryption framework, as shown below. Figure 5As shown, the overall algorithm framework follows the core process of key expansion-double-scrambling-secondary diffusion, and is divided into two main processes: encryption and decryption, based on input-processing-output logic. It comprises eight core levels, each with clearly defined functional boundaries, reflecting the core design logic of key expansion-double-scrambling-secondary diffusion. In the encryption stage: An initial key and a plaintext image are input. The plaintext features are extracted using SHA-512 to expand the key, driving a five-dimensional Hamiltonian conservative hyperchaotic system to generate a chaotic sequence. After sequence purification, a double-scrambling index and a secondary diffusion sequence are generated. The ciphertext image is then generated through double-scrambling and secondary reversible diffusion. The decryption stage is the reverse operation, recovering the original image through inverse diffusion and inverse scrambling. Compared to the traditional one-time scrambling-one-time diffusion architecture, this framework improves resistance to differential attacks by 25%.
[0058] After the encryption process begins, the original image and key are input. Plaintext features are then extracted and the initial key is adjusted. Next, a feedback chaotic sequence, a main chaotic sequence, and a scrambling index are generated. The first bit-plane diffusion is then performed, followed by the first scrambling. A second positional coding diffusion is then performed, followed by a second scrambling. Finally, the encrypted image and auxiliary decryption information are output. Specifically, the process includes the following steps:
[0059] 1. Input the original grayscale image I (size H×W) and the 11-dimensional initial key K (containing 6 system parameters + 5 adjustment coefficients).
[0060] 2. Perform SHA-512 hash on I to generate plaintext signature.
[0061] 3. Expanding the key: Adjusting the parameters and initial values of the chaotic system using plaintext features to generate an adaptive key stream.
[0062] 4. Generate chaotic sequences: Iterate through a five-dimensional Hamiltonian system accelerated by Numba to generate sequences of length 4×H×W, which are then purified for later use.
[0063] 5. Secondary reversible diffusion: Perform bit-plane diffusion and position-encoded diffusion on the first scrambled image, adjust pixel grayscale values, and save normalization parameters.
[0064] 6. Double Reset Scrambling: Generate indices1 and indices2, and rearrange the pixel positions of the first and second diffusion images in sequence.
[0065] 7. Output the encrypted image I' and save the auxiliary information (indices1, indices2, chaotic sequence, normalization parameters).
[0066] After the decryption process begins, the encrypted image and the decryption file are input first. Then, the first inverse scrambling is performed, followed by the first positional encoding inverse diffusion, then the second inverse scrambling, and finally the second bit-plane inverse diffusion. After completing these steps, the differences between the decrypted image and the original image are verified, and the decrypted image is finally output. Specifically, the process includes the following steps:
[0067] 1. Input encrypted image .
[0068] 2. Load the decryption file and read the decryption key information, including the first and second permutation indices, the main chaotic sequence, and the plaintext feedback chaotic sequence.
[0069] 3. First reverse scrambling: via based on Construct its inverted index The scrambled image is restored to its original pixel position by extracting pixels through inverse indexing.
[0070] 4. First reverse diffusion: based on the index of each pixel in the descrambled image. Generate position code The pixel values are recovered by inverse diffusion of the image obtained from the first inverse scrambling using the main chaotic sequence: .
[0071] 5. Second reverse scrambling: via based on Construct its inverted index The image after the first reverse diffusion is restored to its original pixel position by extracting pixels through inverse indexing.
[0072] 6. Second Bit-Plane Inverse Diffusion: The image after the second inverse scrambling is decomposed into 8 bit planes. Based on plaintext feedback chaotic sequence. Inverse diffusion is performed sequentially on each plane of the image after the second inverse scrambling to restore the pixel values: By merging the eight inverse diffusion bit planes, the decrypted image can be obtained.
[0073] 7. Output the decrypted image ,verify Difference from I (ideal value is 0).
[0074] The research content of this invention includes: 1. Analyzing the dynamic characteristics of a five-dimensional Hamiltonian conservative hyperchaotic system, optimizing the solution process of the fourth-order Runge-Kutta method, and verifying its chaotic behavior and pseudo-random characteristics; 2. Designing an adaptive key expansion mechanism driven by SHA-512 hash to achieve deep binding between the key and the plaintext image, thus preventing chosen-plaintext attacks; 3. Proposing a double-reset scrambling + secondary reversible diffusion encryption architecture, combining bit-plane characteristics and positional encoding to optimize the encryption process and ensure that the algorithm is completely reversible; 4. Comprehensively verifying the effectiveness of the algorithm from the dimensions of key space, information entropy, correlation, anti-attack performance, and encryption efficiency.
[0075] The innovations of this invention include: 1. Optimizing the implementation of a five-dimensional Hamiltonian conservative hyperchaotic system, using Numba just-in-time compilation to accelerate chaotic sequence generation, achieving a speed improvement of 2 times compared to traditional implementations, and expanding the key space to 10. ¹65 The algorithm achieves the following improvements: 1. It improves upon traditional five-dimensional FHCCS algorithms by three orders of magnitude; 2. It introduces SHA-512 hashing to extract plaintext features, dynamically adjusts chaotic system parameters and initial values, and achieves more refined key feedback control than the SHA-256 scheme. It also generates a dedicated key stream by combining image hash values, eliminating the risk of chosen-plaintext attacks; 3. It designs a dual-reset scrambling and adaptive bit-plane reversible diffusion collaborative mechanism, using linear normalization + positional encoding to ensure diffusion reversibility. It configures diffusion strength differently for high and low bit planes, further reducing pixel correlation compared to a fixed diffusion strategy; 4. Experiments verify the algorithm's superiority in decryption correctness, security, and efficiency. Encryption of 256×256 images takes as little as 1.15 seconds, meeting real-time encryption requirements.
[0076] The encryption and decryption processes described above are inverse processes of each other. The encryption process transforms the original image into a highly secure encrypted image by combining plaintext features to drive chaotic sequence generation, bit plane diffusion, and pixel scrambling operations, and generates auxiliary decryption information to provide complete input for the decryption process. The decryption process, on the other hand, relies on the key and auxiliary decryption information generated in the encryption process to gradually restore the pixel positions and pixel values by constructing an inverse scrambling index and performing inverse diffusion operations, ultimately achieving reliable recovery of the encrypted image. The two processes are strictly corresponding in terms of chaotic sequence dependence and the order of diffusion and scrambling operations, together forming a complete closed-loop system for image encryption and decryption. Figure 6 This specification provides a schematic diagram of an encryption and decryption system based on a five-dimensional Hamiltonian hyperchaotic planar diffusion image, as shown below. Figure 6 As shown, the system functions include:
[0077] Visual interface: The left-hand parameter setting panel allows adjustment of all algorithm parameters; the right-hand image display area simultaneously shows the original, encrypted, and decrypted images; the bottom performance evaluation results display area... Parameter configuration: Supports adjusting chaotic system parameters (CLIP_MIN / MAX, DT, preheating steps, etc.); supports custom keys (11-bit parameters); supports adjusting encryption parameters such as the number of diffusion rounds. Core features: Image loading (supports PNG / JPG / BMP formats); asynchronous encryption / decryption (avoids interface lag); automatic performance evaluation (entropy, correlation, PSNR, NPCR / UACI, etc.) Usage flow: Click "Load Image" to select an image file; adjust parameters (optional); click "Encrypt Image" to generate the encrypted result; click "Decrypt Image" to restore the image; click "Performance Evaluation" to view algorithm metrics.
[0078] Based on such Figure 6 The encryption and decryption system shown in the invention also provides experimental verification of the above-mentioned image encryption and decryption methods. For example, the experimental environment and parameter settings include:
[0079] 1. Hardware environment: Intel Core i7-8700K CPU @ 3.70GHz, 16GB RAM.
[0080] 2. Software environment: Windows 10, Python 3.9, OpenCV 4.5.4, NumPy 1.21.5.
[0081] 3. Test images: Lena, Barbara, Cameraman, Pepper (all are 256×256 PNG grayscale images).
[0082] 4. Algorithm parameters: Chaotic system parameters initial value Longo-Kuta stride .
[0083] Basic performance testing includes decryption correctness: Figure 7 This is a schematic diagram illustrating the experimental verification of an image encryption method provided in this specification, such as... Figure 7 As shown in the figure, the experiment showed that the total difference between the decrypted Lena image and the original image was 0, and the PSNR reached 100.00dB, indicating that the algorithm has perfect reversibility, accurate inverse diffusion and inverse scrambling operations, and no pixel loss. The decryption error of each channel of the color image was 0, verifying the algorithm's adaptability to multi-channel images. Figure 8As shown in Figure 8, the pixel distribution histogram of the image encryption method provided in this specification is a comparative diagram. The original image histogram has obvious peaks in multiple pixel value ranges, and the pixel distribution shows significant clustering. In contrast, the encrypted image histogram is evenly distributed across the entire pixel value range of 0 to 255, with no obvious peaks. The pixel frequency fluctuations in each channel are minimal and tend to be consistent. This intuitively demonstrates that the encryption algorithm of this invention can effectively break the pixel distribution pattern of the original image, making the pixel values of the encrypted image present a near-random uniform distribution, which can significantly improve the algorithm's ability to resist statistical analysis attacks.
[0084] Basic performance testing included information entropy analysis: information entropy measures the randomness of pixel value distribution, with a theoretical maximum of 8.0 for 8-bit images. Table 1 shows that the entropy value of the encrypted images is significantly improved. The entropy value of the Lena image after encryption reaches 7.9973, while the entropy values of the Barbara, Cameraman, and Pepper images are all close to 8.0. Overall, this verifies the effectiveness of the diffusion operation, and the entropy performance is superior to the five-dimensional FHCCS algorithm.
[0085] Table 1 Comparison of image information entropy before and after encryption. Basic performance testing includes pixel correlation analysis: the correlation between adjacent pixels reflects spatial redundancy; the lower the correlation, the stronger the resistance to statistical attacks. Table 2 shows that after encryption, the horizontal / vertical / diagonal correlation of all images decreased to within ±0.005. The Lena image's horizontal correlation was only 0.0007, and its vertical correlation was -0.0043, representing a correlation reduction of over 99%. This indicates that the double-scrambling effectively disrupts spatial correlation, achieving a 12% improvement in correlation reduction compared to the single-scrambling scheme.
[0086] Table 2 Comparison of correlation between adjacent pixels in images before and after encryption. The anti-attack performance test includes resistance to differential attacks: differential attacks assess the sensitivity of ciphertext through small changes in plaintext, with the metrics being NPCR (pixel rate of change) and UACI (average intensity of change), and target values of 99.6% and 33.5%, respectively. As shown in Table 3, the algorithm's NPCR exceeds 99.5%, and its UACI is close to 33.5%. For the Lena image, the NPCR reaches 99.5544%, and the UACI reaches 33.4762%. Due to the diffusion intensity adapting to the bit-plane features, the algorithm exhibits excellent resistance to differential attacks, with the NPCR metric being 0.12% higher than the variable-parameter hyperchaotic algorithm.
[0087] Table 3. Algorithm resistance to differential attacks (NPCR & UACI) The anti-attack performance test includes a key sensitivity test: 10-10 perturbations are added to any parameter in the initial key to generate 11 sets of perturbation keys. Experiments show that the pixel difference rate between the encrypted images of all perturbation keys and the encrypted images of the base key exceeds 99.7%, indicating that the algorithm is extremely sensitive to the key, has no weak key links, and has strong resistance to key guessing attacks. Its sensitivity is 35% higher than that of the algorithm based on the Lorenz system.
[0088] The anti-attack performance test includes key space analysis: the algorithm key contains 6 system parameters and 5 initial values, the quantization precision is 10−15, and the key space is 10165, which far exceeds the security threshold of 2128. It can resist brute-force attacks and effectively resist exhaustive attacks.
[0089] Encryption efficiency analysis: As shown in Table 4, the algorithm has an average encryption time of 1.15 seconds and a decryption time of 0.06 seconds for a 256×256 image, with a total time of 1.21 seconds. On average, it encrypts 113,900 pixels per second, which meets the requirements of real-time scenarios (such as video frame encryption and real-time communication).
[0090] Table 4 Comparison of Algorithm Encryption Efficiency (256×256×3 Grayscale Image) Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0091] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
Claims
1. An image encryption method, characterized in that, include: Obtain the image to be encrypted and the initial key; A five-dimensional Hamiltonian conservative hyperchaotic system is constructed, and the plaintext feedback chaotic sequence and the main chaotic sequence are generated iteratively based on the initial key. The image to be encrypted is decomposed into multiple bit planes. Each bit plane is assigned an independent subsequence based on the plaintext feedback chaotic sequence, and a binary code related to the pixel position of the image to be encrypted is generated. The pixels of each bit plane are diffused based on the subsequence and the binary code. The diffused bit planes are merged to obtain the first diffused image. A first scrambling index and a second scrambling index are generated based on the main chaotic sequence. The first scrambling index is used to scramble the pixel positions of the first diffusion image to obtain the first scrambling image. By performing modulo-256 addition on the pixel values of the first scrambled image, the main chaotic sequence, and the position encoding of the first scrambled image, pixel-level diffusion is achieved to obtain the second diffused image. The second scrambling index is used to scramble the pixel positions of the second diffusion image to obtain an encrypted image.
2. The image encryption method according to claim 1, characterized in that, The initial key includes six initial control parameters of the five-dimensional Hamiltonian conservative hyperchaotic system. and the initial values of the five state variables. Before the step of iteratively generating the plaintext feedback chaotic sequence and the main chaotic sequence based on the initial key-driven five-dimensional Hamiltonian conservative hyperchaotic system, the step of updating the initial key is also included: The image to be encrypted is converted into a byte data stream, and the SHA-512 hash algorithm is used to encrypt the byte data stream to generate a hash value data with a length of 512 bits. The 512-bit hash value is segmented and converted into 10 floating-point numbers with values in the range [-5, 5]. ; in, Represents floating-point numbers , ; Represents the number retrieval function; This represents the 512-bit hash value. Ranked first A sub-fragment of a position; The initial values of the five state variables and the five initial control parameters in the initial key are updated based on ten floating-point numbers ranging from -5 to 5: ; ; Among them, the initial parameters As a constant energy term in a conservative chaotic system, it does not participate in key updates; , , , and For the updated state variables; , , , and These are the updated control parameters.
3. The image encryption method according to claim 2, characterized in that, The method for iteratively generating plaintext feedback chaotic sequences and main chaotic sequences based on an initial key-driven five-dimensional Hamiltonian conservative hyperchaotic system specifically includes: Constructing the dynamic equations of a five-dimensional Hamiltonian conservative hyperchaotic system: ; Where a, b, c, d, e, and f are the six initial control parameters of the five-dimensional Hamiltonian conservative hyperchaotic system. For the five state variables of a five-dimensional Hamiltonian conservative hyperchaotic system; The dynamic equations of the five-dimensional Hamiltonian conservative hyperchaotic system are solved iteratively by using the fourth-order Runge-Kutta method. The number of iterations is the total number of pixels in the image to be encrypted × 4 × the preset number of diffusion rounds. The state variables obtained by iterative update solution at each step Multi-dimensional fusion processing is performed to generate a basic chaotic sequence: ; Where seq[i] is based on the state variable of step i. The obtained basic chaotic sequence value; By configuring different initial values for the basic chaotic sequence, plaintext feedback chaotic sequences are generated. and the main chaotic sequence ,in, Generate plaintext feedback chaotic sequence At that time, the initial values of the control parameters of the configured five-dimensional Hamiltonian conservative hyperchaotic system are: The initial value of the state variable is ; Generate the main chaotic sequence At that time, the initial values of the control parameters of the configured five-dimensional Hamiltonian conservative hyperchaotic system are: The initial value of the state variable is .
4. The image encryption method according to claim 3, characterized in that, Obtaining the first diffusion image specifically includes: Each pixel value of the image to be encrypted is converted into 8 bits of binary data, forming 8 binary bit planes in descending order of bit height. i ; Based on plaintext feedback chaotic sequence Assign a corresponding sub-plaintext feedback chaotic sequence to each bit plane : ; in, The total number of pixels in the image to be encrypted. The chaotic sequence is fed back in plaintext; Binary position codes are generated by XORing the grid matrix of pixel coordinates of the image to be encrypted. : ; in, The width of the image to be encrypted. The height of the image to be encrypted. Represents the XOR operation; This represents the modulo operation; Perform two XOR fusion operations on the eight bit planes to obtain eight first diffusion bit planes. : ; The eight first diffusion bit planes are merged in bit order to obtain the first diffusion image.
5. The image encryption method according to claim 4, characterized in that, The generation of the first and second scrambling indices based on the main chaotic sequence specifically includes: From the main chaotic sequence Extract two segments from the image to be encrypted, along with the total number of pixels. First subsequence of equality and the second subsequence : ; ; Based on the first subsequence respectively and the second subsequence The first seed is obtained by summing the absolute values of the first 20 elements. Second seed : ; ; in, Indicates to Take the mold; Represents the number retrieval function; Based on the first seed respectively Second seed Generate the first permutation index Second permutation index : ; ; Where N represents the total number of pixels in the image to be encrypted; This is a random number generator used to generate random permutation sequences from 0 to N.
6. The image encryption method according to claim 5, characterized in that, The step of scrambling the pixel positions of the first diffused image using the first scrambling index to obtain the first scrambled image specifically includes: The pixel set of the first diffused image is indexed in a row-major manner using a one-dimensional serialization index, and the serialization index k is set, k= ; According to the first scrambling index Get the permutation value corresponding to the serialization index k. ; Replacement value Mapping to a two-dimensional coordinate system yields the target row coordinates. and target column coordinates ; The pixel values in the first diffused image are replaced with the corresponding positions in the first scrambled image to obtain the first scrambled image. : ; Where I represents the first diffused image, and the pixel value is represented as I(i,j), i∈[0,h−1],j∈[0,w−1]; This indicates the floor function.
7. The image encryption method according to claim 6, characterized in that, Obtaining the second diffusion image specifically includes: Position encoding for generating the first scrambled image : ; in, Indicates the pixel index of the first scrambled image; Represents the XOR operation; Indicates integer division; Based on the pixel values of the first scrambled image, the main chaotic sequence Position encoding of the first scrambled image Perform modulo 256 additive diffusion on the pixel values of the first scrambled image: ; in, Indicates the pixel value after diffusion; Represents the pixel values of the first scrambled image; This represents an addition operation modulo 256; A second diffused image is obtained by reconstructing a two-dimensional image based on the diffused pixel values.
8. The image encryption method according to claim 3, characterized in that, In the process of iteratively updating and solving the dynamic equations of the five-dimensional Hamiltonian conservative hyperchaotic system using the fourth-order Runge-Kutta method, just-in-time compilation technology is used to accelerate the iterative calculation process.
9. An image decryption method based on the image encryption method of any of the preceding claims, characterized in that, include: Obtain the encrypted image and the decrypted file; the decrypted file includes a first scrambling index. Second scrambled index Main chaotic sequence and plaintext feedback chaotic sequence ; First reverse scrambling: based on the second scrambling index Construct the first inverse index via the first inverted index The scrambled image is restored to its original pixel positions to obtain the first inverse scrambled image; wherein, the first inverse index satisfy: ; in, , , Image width, Image height; First inverse diffusion: based on the index of each pixel in the first inverse scrambling image Generate position code The first inversely scrambled image is reverse-diffused using the main chaotic sequence to recover pixel values, thus obtaining the first inversely diffused image. : ; ; in, These are the pixel values of the first inverted scrambled image. The position encoding of the first inverse scrambled image; Second reverse scrambling: First scrambling index Constructing a second inverse index via the second inverted index The first inverse diffusion image is restored to its original pixel position to obtain the second inverse scrambling image; Second bit-plane inverse diffusion: Convert each pixel value of the second inverse scrambled image into 8-bit binary data, forming 8 bit planes; for the i-th bit plane From plaintext feedback chaotic sequence Extracting subsequences : ; Binary position codes are generated by XORing the grid matrix of pixel coordinates. : ; Perform two XOR fusion operations on each of the eight bit planes to obtain eight diffuse bit planes. ; ; By merging the eight inverse diffusion bit planes, the decrypted image can be obtained.