Image encryption method, medium, equipment and terminal based on four-dimensional hyper-chaotic system
1. An image encryption method based on a four-dimensional hyper-chaotic system is characterized in that the image encryption method based on the four-dimensional hyper-chaotic system comprises the following steps:
step one, extracting the matrix size MxNx3 on the R, G and B channels in the image, combining the three-dimensional matrix into a 3 MxN two-dimensional matrix and recording the two-dimensional matrix as P1;
Step two, adding P1Converting into a row matrix and simultaneously converting the row matrix into a column matrixBinary matrix P2;
Step three, inputting an initial key ko(ii) a Solving a differential equation set by using a Runge Kutta method, and obtaining 3 MxN solutions by using different independent variable values; generating a matrix consisting of four chaotic sequences and recording the matrix as X;
step four, processing the four chaotic sequences:
step five, adding P2By shifting each element of p3(i,: clockwise by H1(i) A unit;
step six, adding P3Every two columns in (1) are exchanged and recorded as p4And p is4Conversion into a decimal matrix of one row of 3M x N columns, denoted p5;
Step seven, p is5(1:MxN),p5(MxN+1:2xMxN),p5(2xMxN + 1: 3xMxN) is subjected to exclusive OR operation with x1, y1 and z1 respectively and reduced to M x N matrix which is marked as p6,p7,p8;
Step eight, combining three two-dimensional M x N matrixes p6,p7,p8Merge into a three-dimensional matrix of MxNx3, denoted as p9。
2. The image encryption method based on the four-dimensional hyperchaotic system as claimed in claim 1, wherein in the third step, the decomposition of differential equations by the Runge Kutta method is as follows:
3. the image encryption method based on the four-dimensional hyper-chaotic system as claimed in claim 1, wherein in the fourth step, the four chaotic sequences are processed as follows:
4. the image encryption method based on the four-dimensional hyper-chaotic system as claimed in claim 1, wherein in the eighth step, the matrix p is used9And converting the picture into a unit8 format and outputting the picture into a jpg format, namely the final encrypted picture.
5. A computer device, characterized in that the computer device comprises a memory and a processor, the memory storing a computer program which, when executed by the processor, causes the processor to carry out the steps of:
step one, extracting the matrix size MxNx3 on the R, G and B channels in the image, combining the three-dimensional matrix into a 3 MxN two-dimensional matrix and recording the two-dimensional matrix as P1;
Step two, adding P1Convert to a row matrix and convert the row matrix to a binary matrix P2;
Step three, inputting an initial key ko(ii) a Solving a differential equation set by using a Runge Kutta method, and obtaining 3 MxN solutions by using different independent variable values; generating a matrix consisting of four chaotic sequences and recording the matrix as X;
step four, processing the four chaotic sequences:
step five, adding P2By shifting each element of p3(i,: clockwise by H1(i) A unit;
step six, adding P3Every two columns in (1) are exchanged and recorded as p4And p is4Conversion into a decimal matrix of one row of 3M x N columns, denoted p5;
Step seven, p is5(1:MxN),p5(MxN+1:2xMxN),p5(2xMxN + 1: 3xMxN) is subjected to exclusive OR operation with x1, y1 and z1 respectively and reduced to M x N matrix which is marked as p6,p7,p8;
Step eight, combining three two-dimensional M x N matrixes p6,p7,p8Merge into one MxNx3 three-dimensional matrix, denoted p9。
6. A computer-readable storage medium storing a computer program which, when executed by a processor, causes the processor to perform the steps of:
step one, extracting the matrix size MxNx3 on the R, G and B channels in the image, combining the three-dimensional matrix into a 3 MxN two-dimensional matrix and recording the two-dimensional matrix as P1;
Step two, adding P1Convert to a row matrix and convert the row matrix to a binary matrix P2;
Step three, inputting an initial key ko(ii) a Solving a differential equation set by using a Runge Kutta method, and obtaining 3 MxN solutions by using different independent variable values; generating a matrix consisting of four chaotic sequences and recording the matrix as X;
step four, processing the four chaotic sequences:
step five, adding P2By shifting each element of p3(i,: clockwise by H1(i) A unit;
step six, adding P3Every two columns in (1) are exchanged and recorded as p4And p is4Conversion into a decimal matrix of one row of 3M x N columns, denoted p5;
Step seven, p is5(1:MxN),p5(MxN+1:2xMxN),p5(2xMxN + 1: 3xMxN) is subjected to exclusive OR operation with x1, y1 and z1 respectively and reduced to M x N matrix which is marked as p6,p7,p8;
Step eight, combining three two-dimensional M x N matrixes p6,p7,p8Merge into a three-dimensional matrix of MxNx3, denoted as p9。
7. An information data processing terminal, characterized in that the information data processing terminal is used for realizing the image encryption method based on the four-dimensional hyper-chaotic system as claimed in any one of claims 1 to 4.
Background
At present, digital images are one of the most popular multimedia forms, and in order to realize digital image security, in actual operation, two-dimensional images are generally converted into one-dimensional data, and then encrypted by an encryption algorithm. The traditional digital image encryption algorithm is mainly divided into the following categories according to the encryption concept: pixel scrambling based on spatial domain, encryption based on transform domain, encryption based on secret sharing by secret segmentation, encryption based on neural network and cellular automata, and encryption based on blind source separation.
The traditional image encryption technology is an encryption algorithm based on pixel scrambling, and a general key and the algorithm cannot be effectively separated. The encryption technology based on the chaotic dynamics system developed in recent years is a password encryption technology and has the limitation that an image is used as a common data stream. At present, the research of the chaotic encryption technology is mostly based on one-dimensional and two-dimensional chaotic systems. In the chaos-based image encryption method, some utilize a chaos system to generate a pseudo-random sequence and encrypt in a sequence cipher form; some utilize chaotic ergodicity, process pseudo-random sequence produced, get the position after the pixel is scrambled, then scramble the position of the pixel; some of the chaotic computing expressions utilize the reversible characteristic of some chaotic computing expressions to substitute and diffuse the pixel values into the chaotic computing expressions. Chaotic systems commonly used for image encryption are: a Logistic chaotic system, a Henon chaotic system, a Lorenz chaotic system, a Chen chaotic system, a Rossler chaotic system and the like.
Through the above analysis, the problems and defects of the prior art are as follows: the traditional encryption algorithm and the digital image encryption algorithm of the low-dimensional chaotic system gradually expose the problems of small key space, low safety and the like.
The difficulty in solving the above problems and defects is: the current chaotic encryption is mainly a low-dimensional chaotic system and only has one Lee's exponent which is larger than zero, and the first difficulty is how to find a system with a simple nonlinear form under the condition that the number of system state variables is as small as possible and the positive Lee's exponent is as large as possible. The conventional algorithm, such as scrambling or substitution of pixel positions, still has certain characteristics of original pixels, which is very bad in encryption, and it is a second difficulty to find an algorithm capable of scrambling the pixels well by using the pixels for decryption. The traditional encryption algorithm has small key space, and the longer the bit number of the key is, the larger the key space is, but the bit number of the key is limited by the algorithm. The chaos encrypted key can define any real number by itself, and the real number is dense, so the theoretical size of the key space is infinite, namely the number of bits of the maximum floating point number which can be identified by the computer in reality.
The significance of solving the problems and the defects is as follows: 1. the researchers indicate that the confidentiality of the low-dimensional chaotic system is not enough, so that the research on the image encryption technology based on the high-dimensional chaotic system and even the hyperchaotic system is very meaningful. 2. If the algorithm can erase all the features of the pixel, it can be said that it is almost impossible to solve the original image. The safety is greatly improved.
Disclosure of Invention
Aiming at the problems in the prior art, the invention provides an image encryption method, a medium, equipment and a terminal based on a four-dimensional hyper-chaotic system.
The invention is realized in such a way that an image encryption method based on a four-dimensional hyper-chaotic system comprises the following steps:
step one, extracting the matrix size MxNx3 on the R, G and B channels in the image, combining the three-dimensional matrix into a 3 MxN two-dimensional matrix and recording the two-dimensional matrix as P1;
Step two, adding P1Convert to a row matrix and convert the row matrix to a binary matrix P2;
Step three, inputting an initial key ko(ii) a Solving a differential equation set by using a Runge Kutta method, and obtaining 3 MxN solutions by using different independent variable values; generating a matrix consisting of four chaotic sequences and recording the matrix as X;
step four, processing the four chaotic sequences:
step five, adding P2By shifting each element of p3(i,: clockwise by H1(i) A unit;
step six, adding P3Every two columns in (1) are exchanged and recorded as p4And p is4Is converted into oneDecimal matrix of rows 3M x N columns, denoted p5(ii) a The complexity of the algorithm is increased, and the replacement of the pixel position of the traditional encryption algorithm is merged into the algorithm.
Step seven, p is5(1:MxN),p5(MxN+1:2xMxN),p5(2xMxN + 1: 3xMxN) is subjected to exclusive OR operation with x1, y1 and z1 respectively and reduced to M x N matrix which is marked as p6,p7,p8;
Step eight, combining three two-dimensional M x N matrixes p6,p7,p8Merge into a three-dimensional matrix of MxNx3, denoted as p9。
Step one to step four are preparation work, and the original image matrix and the encryption matrix are obtained and processed into row vectors to be better operated in the next step. Step five, taking a pixel as an example, converting the pixel into a binary system, and moving the value of the original pixel clockwise to be almost unrelated to the value of the encrypted pixel, so that most decryption modes can be blocked. And step six and step seven increase the complexity of the algorithm, and the replacement of the pixel position of the traditional encryption algorithm is merged into the algorithm.
Further, in the third step, solving a differential equation set by the Runge Kutta method is as follows:
further, in the fourth step, the four chaotic sequences are processed as follows:
further, in the eighth step, the matrix p is divided into9And converting the picture into a unit8 format and outputting the picture into a jpg format, namely the final encrypted picture.
Another object of the present invention is to provide a program storage medium for receiving a user input, the stored computer program causing an electronic device to execute the image encryption method based on a four-dimensional hyper-chaotic system, comprising the steps of:
step one, extracting the matrix size MxNx3 on the R, G and B channels in the image, combining the three-dimensional matrix into a 3 MxN two-dimensional matrix and recording the two-dimensional matrix as P1;
Step two, adding P1Convert to a row matrix and convert the row matrix to a binary matrix P2;
Step three, inputting an initial key ko(ii) a Solving a differential equation set by using a Runge Kutta method, and obtaining 3 MxN solutions by using different independent variable values; generating a matrix consisting of four chaotic sequences and recording the matrix as X;
step four, processing the four chaotic sequences:
step five, adding P2By shifting each element of p3(i,: clockwise by H1(i) A unit;
step six, adding P3Every two columns in (1) are exchanged and recorded as p4And p is4Conversion into a decimal matrix of one row of 3M x N columns, denoted p5;
Step seven, p is5(1:MxN),p5(MxN+1:2xMxN),p5(2xMxN + 1: 3xMxN) is subjected to exclusive OR operation with x1, y1 and z1 respectively and reduced to M x N matrix which is marked as p6,p7,p8;
Step eight, combining three two-dimensional M x N matrixes p6,p7,p8Merge into a three-dimensional matrix of MxNx3, denoted as p9。
Another object of the present invention is to provide a computer program product stored on a computer readable medium, which includes a computer readable program for providing a user input interface to implement the four-dimensional hyper-chaotic system based image encryption method when the computer program product is executed on an electronic device.
By combining all the technical schemes, the invention has the advantages and positive effects that: in recent years, the development of modern network technology is rapid, the image encryption technology is also rapidly developed, and the digital image encryption algorithm based on the traditional encryption algorithm and the low-dimensional chaotic system gradually exposes the problems of small key space, low security and the like. Therefore, on the basis of a three-dimensional Lorenz system, the four-dimensional hyper-chaos Lorenz system is formed by adding the variable w, and the computation result of the Lyapunov index and the simulation result of the motion trajectory of the system verify the hyper-chaos of the system. For the system, an exchange based on chaotic sequences and an exclusive or algorithm are proposed to encrypt the image. The safety analysis and test results of the algorithm show that the new algorithm is very sensitive to the secret key, has good diffusivity and safety, and can resist brute force attack, known plaintext attack and selected plaintext attack.
Drawings
Fig. 1 is a flowchart of an image encryption method based on a four-dimensional hyper-chaotic system according to an embodiment of the present invention.
Fig. 2 is an x-t plan view provided by an embodiment of the present invention.
FIG. 3 is a y-t plan view provided by an embodiment of the present invention.
FIG. 4 is a z-t plan view provided by an embodiment of the present invention.
FIG. 5 is a w-t plan view provided by an embodiment of the present invention.
FIG. 6 is a three-dimensional x-y-z diagram provided by an embodiment of the present invention.
FIG. 7 is a y-z-w three-dimensional diagram provided by an embodiment of the present invention.
Fig. 8 is a three-dimensional x-y-w diagram provided by an embodiment of the present invention.
FIG. 9 is a three-dimensional x-z-w diagram provided by an embodiment of the present invention.
Fig. 10 is a flowchart of an image encryption algorithm based on a four-dimensional hyper-chaotic system according to an embodiment of the present invention.
Fig. 11 is an original image, an encrypted image, and a decrypted image provided by an embodiment of the present invention.
Fig. 12 is a statistical histogram before encryption according to an embodiment of the present invention.
Fig. 13 is an encrypted statistical histogram provided by an embodiment of the present invention.
FIGS. 14 and 15 are graphs of the initial correct key for 10 skew provided by embodiments of the present invention-14The key of (2) is used for decrypting the encrypted Lena image to obtain a result schematic diagram.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail with reference to the following embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Aiming at the problems in the prior art, the invention provides an image encryption method, a medium, equipment and a terminal based on a four-dimensional hyper-chaotic system, and the invention is described in detail with reference to the attached drawings.
A person skilled in the art can also use other steps to implement the image encryption method based on the four-dimensional hyper-chaotic system provided by the present invention, and the image encryption method based on the four-dimensional hyper-chaotic system provided by the present invention shown in fig. 1 is only a specific embodiment.
As shown in fig. 1, an image encryption method based on a four-dimensional hyper-chaotic system according to an embodiment of the present invention includes:
s101: extracting matrix size MxNx3 on R, G and B channels in the image, combining the three-dimensional matrix into a 3 MxN two-dimensional matrix, and recording the two-dimensional matrix as P1。
S102: will P1Convert to a row matrix and convert the row matrix to a binary matrix P2。
S103: input initial key ko(ii) a The differential equation set is solved by using the Runge Kutta method, and 3 MxN solutions are obtained by using different independent variable values. The matrix formed by the four chaotic sequences is recorded as X.
S104: processing the four chaotic sequences:
s105: will P2By shifting each element of p3(i,: clockwise by H1(i) And (4) units.
S106: handle P3Every two columns in (1) are exchanged and recorded as p4And p is4Conversion into a decimal matrix of one row of 3M x N columns, denoted p5。
S107: p is to be5(1:MxN),p5(MxN+1:2xMxN),p5(2xMxN + 1: 3xMxN) is subjected to exclusive OR operation with x1, y1 and z1 respectively and reduced to M x N matrix which is marked as p6,p7,p8。
S108: combining three two-dimensional M x N matrices p6,p7,p8Merge into a three-dimensional matrix of MxNx3, denoted as p9。
In S103 provided by the embodiment of the present invention, solving a differential equation set by the longgutta method is as follows:
in S104 provided by the embodiment of the present invention, the four chaotic sequences are processed as follows:
in S108 provided in the embodiment of the present invention, the matrix p is divided into9And converting the picture into a unit8 format and outputting the picture into a jpg format, namely the final encrypted picture.
The technical solution of the present invention is further described with reference to the following specific examples.
1. Four-dimensional hyperchaotic Lorenz system
On the basis of a three-dimensional Lorenz system, a differential equation is added by introducing a new variable w to form a four-dimensional differential equation set:
the four-dimensional hyperchaotic Lorenz system is constructed by the above formula, wherein nonlinear terms are used for increasing the complexity of system motion, a, b, c and d are system parameters, and the values of a, b and c are the same as those of the classical three-dimensional Lorenz system.
The invention employsA method for calculating the Lyaponov exponent of the system of differential equations, which yields the Lyaponov exponent of the formula (1) as input when a is 10, b is 8/3, c is 28, and d is 212.0438, into21.9735, into3H. 2.19184When 2 Lyapunov indexes are larger than 0, the formula (1) generates hyper-chaotic motion, which is called a new hyper-chaotic Lorenz system.
When a is 10, b is 8/3, c is 28, and d is 2, the motion trajectory of the system is as shown in fig. 3-6, and experimental results show that each sequence value of x, y, z, and w has the characteristics of randomness, ergodicity, determinacy, and extreme sensitivity to initial values.
2. Digital image encryption algorithm based on four-dimensional hyper-chaotic system
The encryption algorithm process is shown in figure 10,
the method comprises the following specific steps:
stepl: extracting matrix size MxNx3 on R, G and B channels in the image, combining the three-dimensional matrix into a 3 MxN two-dimensional matrix, and recording the two-dimensional matrix as P1。
Step 2: will P1Convert to a row matrix and convert the row matrix to a binary matrix P2。
Step 3: input initial key ko(ii) a The differential equation set (1) is solved using the Runge Kutta method, and 3 MxN solutions are obtained using different argument values. The matrix formed by the four chaotic sequences is recorded as X.
Step 4: the four chaotic sequences are processed as follows:
step 5: will P2By shifting each element of p3(i,: clockwise by H1(i) And (4) units.
Step 6: handle P3Every two columns in (1) are exchanged and recorded as p4And p is4Conversion into a decimal matrix of one row of 3M x N columns, denoted p5。
Step 7: p is to be5(1:MxN),p5(MxN+1:2xMxN),p5(2xMxN + 1: 3xMxN) is subjected to exclusive OR operation with x1, y1 and z1 respectively and reduced to M x N matrix which is marked as p6,p7,p8。
Step 8: combining three two-dimensional M xN matrices p6,p7,p8Merge into a three-dimensional matrix of MxNx3, denoted as p9。
Step 8: will matrix p9And converting the picture into a unit8 format and outputting the picture into a jpg format, namely the final encrypted picture.
The image decryption step is the reverse process of the encryption step, and the original image, the encryption image and the decryption are as shown in fig. 11.
The invention may also be applied to any binary-related encryption in addition to image encryption; such as literal encryption, converting the literal into an ASCII value and into binary for encryption.
The technical solution of the present invention is further described below with reference to simulation experiments.
Encryption algorithm security analysis and experimental simulation
In an encryption algorithm, security is a primary issue. The security of the encryption algorithm of the present invention will be verified below. The invention adopts a color image Lena of 220X 280 pixels as an encrypted image.
1. Key space analysis
The key of the invention is determined by four initial values of the system, the initial values are real numbers, and the hyperchaotic system can provide infinite key space in theory because the real numbers are dense. But in practice it is not possible to provide an infinite amount of space due to the limitations of modern computer development. If the encryption system is of a double-precision double-floating-point type, each initial value obtains a 15-bit effective number. 4 real numbers with 15 bits are used together as a key, the key space of the encryption algorithm is 1015x4=1060≈2200. In order to be able to resist brute force attacks, the key space k should be larger than 2100Much less than 2200Therefore, the encryption algorithm designed by the invention is enough to resist the current brute force attack.
2. Statistical histogram analysis
According to Shannon's theory, a cryptosystem should have good performance against statistical attacks. Fig. 8 and 9 show statistical histograms of the original image and the ciphertext image. The histogram analysis examines whether the number of each pixel value from 0 to 255 in the ciphertext image is an important index for uniform distribution or not, the distribution condition of the pixel values of the image is well reflected, the flatter the histogram is, the more uniform the pixel value distribution is, and it can be seen that the histogram distribution of the image before encryption is uneven, the main information of the image is gathered in a certain area, and the statistical histogram of the ciphertext image after encryption is uniform in distribution, has good statistical property and has good scrambling property, and can effectively resist known plaintext attack or plaintext attack selection.
3. Analysis of stationary points
The fixed point ratio refers to a percentage value of the number of pixels with unchanged pixel values in the total number of pixels after the image is encrypted, and the calculation formula is as follows:
wherein the content of the first and second substances,
theoretically, the smaller the fixed point ratio of the ciphertext image, the better the proposed encryption scheme. Stationary point ratio calculated based on the system of the present invention
A ratio of less than 1% indicates that the encryption scheme is very secure.
4. Key sensitivity testing and analysis
From a cryptographic point of view, the encryption algorithm is designed to be sufficiently sensitive to the key that it must be guaranteed that the avalanche effect will occur. The avalanche effect is that even if the key changes slightly, the correspondingThe encrypted ciphertext data may also change dramatically. Ideally, it is desirable that at least half of the ciphertext is changed. The encryption algorithm of the invention uses the secret key k0=(x0,y0,z0,w0) As an initial key, the four components are put together as a key of the algorithm.
To test the sensitivity of the algorithm to the key, the value of any one of the subkeys in the key is changed slightly (change 10)-14) And then encrypting, and comparing the number of different pixels corresponding to the two encrypted images before and after encryption.
When the initial value k1 is (0.1+ 10)-14,0.2+10-14,2+10-14,0.5+10-14) The method comprises the following steps: the pixel ratio p of the two encrypted images is 99.61%.
When the initial value k is2=(0.1+10-14,0.2+2x10-14,2+10-14,0.5+10-14) The method comprises the following steps: the pixel ratio p of the two encrypted images is 99.61%.
When the initial value k is3=(0.1+10-14,0.2+2x10-14,2+10-14,0.5+2x10-14) The method comprises the following steps: the pixel ratio p of the two encrypted images is 99.62%.
The results show that even the encryption keys differ by 10-14The resulting encrypted image differs by more than about 99.62% in pixels. FIGS. 14 and 15 show the initial correct key and phase difference of 10-14The encrypted Lena image is decrypted by the key, so that the complete correct decryption can be seen, and the original image information is not exposed. The encryption algorithm of the present invention is therefore very sensitive to keys.
The invention constructs a new hyperchaotic system based on a three-dimensional Lorenz system, then provides a digital image encryption algorithm on the basis of the new hyperchaotic system, and finally analyzes the security of the encryption algorithm of the invention from 4 aspects of image histogram, adjacent pixel correlation, key sensitivity and key space size. The result shows that the algorithm has the characteristics of good encryption effect, strong sensitivity to the key and large key space, can resist the current brute force attack, known plaintext attack and selected plaintext attack, and has higher security. The hyperchaotic system is combined with the plaintext in subsequent preparation, and a self-adaptive encryption algorithm meeting the requirements of modern cryptography is researched.
It should be noted that the embodiments of the present invention can be realized by hardware, software, or a combination of software and hardware. The hardware portion may be implemented using dedicated logic; the software portions may be stored in a memory and executed by a suitable instruction execution system, such as a microprocessor or specially designed hardware. Those skilled in the art will appreciate that the apparatus and methods described above may be implemented using computer executable instructions and/or embodied in processor control code, such code being provided on a carrier medium such as a disk, CD-or DVD-ROM, programmable memory such as read only memory (firmware), or a data carrier such as an optical or electronic signal carrier, for example. The apparatus and its modules of the present invention may be implemented by hardware circuits such as very large scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, or programmable hardware devices such as field programmable gate arrays, programmable logic devices, etc., or by software executed by various types of processors, or by a combination of hardware circuits and software, e.g., firmware.
The above description is only for the purpose of illustrating the present invention and the appended claims are not to be construed as limiting the scope of the invention, which is intended to cover all modifications, equivalents and improvements that are within the spirit and scope of the invention as defined by the appended claims.