An image encryption method and apparatus
By calculating the chaotic sequence and performing chaotic and diffusion processing, the problem of insufficient randomness and security of image encryption methods in the prior art is solved, efficient image encryption is achieved, and the protection ability of image information is enhanced.
Patent Information
- Application Number
- CN202410809254.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-06-21
AI Technical Summary
The existing image encryption methods have low randomness, security and confusion between adjacent pixels, making it difficult to effectively resist the threat of image information theft in network transmission.
By acquiring grayscale images, multiple chaotic sequences are calculated and glyph chaotic, bit-level chaotic, encoding and diffusion processing is performed. Combined with ciphertext feedback and decoding, image encryption is finally realized, improving the randomness and security of the image.
It significantly improves the randomness, security and confusion of adjacent pixels of image encryption, enhances the ability to protect image information, and can effectively resist differential attacks and noise attacks.
Smart Images

Figure CN118631417B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image encryption technology, and in particular to an image encryption method and device. Background Art
[0002] With the rapid development of Internet technology, people are transmitting more information through the Internet. This information mainly includes text, images, videos and other contents. Among them, images can intuitively convey the information to be expressed, becoming one of the important ways of multimedia information transmission. However, due to the potential security risks of the Internet, attackers will exploit loopholes to steal important image information. Traditional image encryption methods use simple pixel value transformation technology, which has low randomness, low complexity and low security. At the same time, in the traditional scrambling method, the confusion degree of adjacent pixels is low.
[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention
[0004] The embodiments of the present invention provide an image encryption method and device, which effectively improve the randomness, security and adjacent pixel confusion.
[0005] In one aspect, an embodiment of the present invention provides an image encryption method, comprising the following steps:
[0006] Get grayscale image;
[0007] Convert the grayscale image according to the image height and the image width to obtain a first image matrix;
[0008] According to the first image matrix, a first chaotic sequence, a second chaotic sequence, a third chaotic sequence, a fourth chaotic sequence, a fifth chaotic sequence, a sixth chaotic sequence, a seventh chaotic sequence, an eighth chaotic sequence and a ninth chaotic sequence are calculated, wherein the length of the first chaotic sequence, the length of the second chaotic sequence, the length of the third chaotic sequence, the length of the fourth chaotic sequence, the length of the fifth chaotic sequence, the length of the sixth chaotic sequence and the length of the eighth chaotic sequence are all equal, the length of the seventh chaotic sequence is equal to the length of the ninth chaotic sequence, and the length of the first chaotic sequence is less than the length of the seventh chaotic sequence;
[0009] According to the first chaotic sequence, the first image matrix is subjected to a glyph scrambling process to obtain a second image matrix;
[0010] According to the second chaotic sequence and the third chaotic sequence, performing bit-level scrambling processing on the second image matrix to obtain a third image matrix;
[0011] According to the fourth chaotic sequence, performing a first encoding process on the third image matrix to obtain a first image sequence;
[0012] According to the fourth chaotic sequence, performing a second coding process on the fifth chaotic sequence to obtain a first coding sequence;
[0013] performing diffusion processing on the first image sequence and the first coding sequence according to the seventh chaotic sequence and the ninth chaotic sequence to obtain a second image sequence;
[0014] According to the sixth chaotic sequence, performing ciphertext feedback processing on the second image sequence to obtain a third image sequence;
[0015] According to the eighth chaotic sequence, the third image sequence is decoded to obtain an encrypted image.
[0016] In some embodiments, the step of calculating, according to the first image matrix, a first chaotic sequence, a second chaotic sequence, a third chaotic sequence, a fourth chaotic sequence, a fifth chaotic sequence, a sixth chaotic sequence, a seventh chaotic sequence, an eighth chaotic sequence, and a ninth chaotic sequence comprises:
[0017] Using a preset hash algorithm to perform a hash operation on the first image matrix to obtain an external key;
[0018] Dividing the external key according to a preset number of groups to obtain a plurality of subkeys;
[0019] Calculating a chaotic parameter set according to the plurality of sub-keys;
[0020] Calculating the initial value set of the chaotic system according to the chaotic parameter set;
[0021] Substituting the initial value set of the chaotic system into the three-dimensional chaotic system according to a preset number of iterations to calculate the chaotic sequence set;
[0022] According to the chaotic sequence set, a first chaotic sequence to be intercepted, a second chaotic sequence to be intercepted and a third chaotic sequence to be intercepted are calculated;
[0023] Performing a first interception process on the first chaotic sequence to be intercepted to obtain the first chaotic sequence, the second chaotic sequence, the third chaotic sequence, the fourth chaotic sequence and the fifth chaotic sequence;
[0024] Performing a second interception process on the second chaotic sequence to be intercepted to obtain the sixth chaotic sequence and the seventh chaotic sequence;
[0025] A third interception process is performed on the third chaotic sequence to be intercepted to obtain the eighth chaotic sequence and the ninth chaotic sequence.
[0026] In some embodiments, performing glyph scrambling processing on the first image matrix according to the first chaotic sequence to obtain a second image matrix includes:
[0027] Calculating a scanning start position value according to the first chaotic sequence;
[0028] Performing a V-shaped scan on the first image matrix according to the scan start position value, the image height, and the image width to obtain a plurality of scan values;
[0029] The plurality of scan values are exchanged with the plurality of maximum row pixel values that have not been exchanged in the first image matrix until each row is exchanged, thereby obtaining the second image matrix, wherein the number of the scan values is equal to the number of the maximum row pixel values, and the exchange process is used to exchange the scan values and the maximum row pixel values that are located in the same column.
[0030] In some embodiments, performing bit-level scrambling processing on the second image matrix according to the second chaotic sequence and the third chaotic sequence to obtain a third image matrix includes:
[0031] Calculating a bit conversion mode value according to the second chaotic sequence;
[0032] Performing quaternary conversion processing on the third chaotic sequence and the second image matrix;
[0033] According to the quaternary number scrambling rule and the bit conversion mode value, the third chaotic sequence after the quaternary conversion process is subjected to a first bit conversion to obtain a quaternary chaotic sequence;
[0034] According to the quaternary number scrambling rule and the bit conversion mode value, performing a second bit conversion on the second image matrix after the quaternary conversion processing to obtain a quaternary image matrix;
[0035] Performing decimal conversion processing on the quaternary chaotic sequence and the quaternary image matrix;
[0036] Calculating the pixel arrangement order according to the quaternary chaotic sequence after decimal conversion;
[0037] According to the pixel arrangement order, the quaternary image matrix after the decimal conversion is sorted to obtain the third image matrix.
[0038] In some embodiments, performing a first encoding process on the third image matrix according to the fourth chaotic sequence to obtain a first image sequence includes:
[0039] Calculating a coding mode value according to the fourth chaotic sequence;
[0040] Performing binary conversion processing on the third image matrix;
[0041] According to the encoding rule and the encoding mode value, the third image matrix after the binary conversion process is encoded to obtain the first image sequence.
[0042] In some embodiments, the step of performing diffusion processing on the first image sequence and the first coding sequence according to the seventh chaotic sequence and the ninth chaotic sequence to obtain a second image sequence includes:
[0043] Calculating a sequence change judgment value according to the seventh chaotic sequence;
[0044] Calculating a diffusion mode value according to the ninth chaotic sequence;
[0045] The first image sequence and the first coding sequence are diffused according to a diffusion rule, the sequence change judgment value and the diffusion mode value to obtain the second image sequence.
[0046] In some embodiments, performing ciphertext feedback processing on the second image sequence according to the sixth chaotic sequence to obtain a third image sequence includes:
[0047] Performing a first division on the sixth chaotic sequence to obtain a plurality of chaotic sequence blocks;
[0048] Performing a second division on the second image sequence to obtain a plurality of image sequence blocks;
[0049] If the sequence number of the image sequence block is 1, the image sequence block and the chaotic sequence block are subjected to a first XOR process to calculate a first encryption block, and the sequence number of the image sequence block is equal to the sequence number of the chaotic sequence block;
[0050] If the sequence number of the image sequence block is greater than 1, the sum of the image sequence block and the previous encryption block is calculated, and a second XOR process is performed with the chaotic sequence block to calculate the corresponding second encryption block;
[0051] The first encryption block and a plurality of the second encryption blocks are connected to obtain the third image sequence.
[0052] In some embodiments, the decoding process of the third image sequence according to the eighth chaotic sequence to obtain an encrypted image includes:
[0053] Calculating a decoding mode value according to the eighth chaotic sequence;
[0054] The third image sequence is decoded according to the encoding rule and the decoding mode value to obtain the encrypted image.
[0055] In some embodiments, the method further comprises the following steps:
[0056] Performing a security experimental analysis on the encrypted image;
[0057] The safety experimental analysis includes:
[0058] Conduct key security analysis;
[0059] Alternatively, perform key sensitivity analysis;
[0060] Alternatively, statistical analysis of pixel values may be performed;
[0061] Alternatively, adjacent pixel correlation analysis may be performed;
[0062] Alternatively, conduct differential attack resistance analysis;
[0063] Alternatively, perform noise attack resistance analysis.
[0064] On the other hand, an embodiment of the present invention provides an image encryption device, comprising:
[0065] The first module is used to obtain a grayscale image;
[0066] The second module is used to convert the grayscale image according to the image height and the image width to obtain a first image matrix;
[0067] a third module, for calculating a first chaotic sequence, a second chaotic sequence, a third chaotic sequence, a fourth chaotic sequence, a fifth chaotic sequence, a sixth chaotic sequence, a seventh chaotic sequence, an eighth chaotic sequence and a ninth chaotic sequence according to the first image matrix, wherein the length of the first chaotic sequence, the length of the second chaotic sequence, the length of the third chaotic sequence, the length of the fourth chaotic sequence, the length of the fifth chaotic sequence, the length of the sixth chaotic sequence and the length of the eighth chaotic sequence are all equal, the length of the seventh chaotic sequence is equal to the length of the ninth chaotic sequence, and the length of the first chaotic sequence is less than the length of the seventh chaotic sequence;
[0068] A fourth module is used to perform a glyph scrambling process on the first image matrix according to the first chaotic sequence to obtain a second image matrix;
[0069] A fifth module is used to perform bit-level scrambling processing on the second image matrix according to the second chaotic sequence and the third chaotic sequence to obtain a third image matrix;
[0070] A sixth module is used to perform a first encoding process on the third image matrix according to the fourth chaotic sequence to obtain a first image sequence;
[0071] A seventh module is used to perform a second coding process on the fifth chaotic sequence according to the fourth chaotic sequence to obtain a first coding sequence;
[0072] an eighth module, configured to perform diffusion processing on the first image sequence and the first coding sequence according to the seventh chaotic sequence and the ninth chaotic sequence to obtain a second image sequence;
[0073] A ninth module, configured to perform ciphertext feedback processing on the second image sequence according to the sixth chaotic sequence to obtain a third image sequence;
[0074] The tenth module is used to decode the third image sequence according to the eighth chaotic sequence to obtain an encrypted image.
[0075] The beneficial effects of the present invention are as follows:
[0076] The present invention first obtains a grayscale image and converts it to obtain a first image matrix, then calculates multiple chaotic sequences, performs glyph scrambling processing on the first image matrix to obtain a second image matrix, performs bit-level scrambling processing on the second image matrix to obtain a third image matrix, performs first coding processing on the third image matrix to obtain a first image sequence, performs second coding processing on the fifth chaotic sequence to obtain a first coding sequence, then performs diffusion processing on the first image sequence and the first coding sequence to obtain a second image sequence, performs ciphertext feedback processing on the second image sequence to obtain a third image sequence, and finally performs decoding processing on the third image sequence to obtain an encrypted image, thereby realizing image encryption, and improving the randomness, security and adjacent pixel confusion of image encryption by scrambling and diffusion.
[0077] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0079] Figure 1A flowchart of an image encryption method according to an embodiment of the present invention;
[0080] Figure 2 A schematic diagram of a chaotic state in an xy plane according to an embodiment of the present invention;
[0081] Figure 3 A schematic diagram of a chaotic state in an xz plane according to an embodiment of the present invention;
[0082] Figure 4 A schematic diagram of a chaotic state in the yz plane according to an embodiment of the present invention;
[0083] Figure 5 A schematic diagram of a chaotic state in an xyz plane according to an embodiment of the present invention;
[0084] Figure 6 A schematic diagram of a V-shaped scrambling according to an embodiment of the present invention;
[0085] Figure 7 A schematic diagram of a first conversion method in quaternary number scrambling according to an embodiment of the present invention;
[0086] Figure 8 A schematic diagram of a second conversion method in quaternary number scrambling according to an embodiment of the present invention;
[0087] Fig. 9 A schematic diagram of a third conversion method in quaternary number scrambling according to an embodiment of the present invention;
[0088] Fig.10 A schematic diagram of a fourth conversion method in quaternary number scrambling according to an embodiment of the present invention;
[0089] Fig.11 A schematic diagram of a bit-level scrambling according to an embodiment of the present invention;
[0090] Fig.12 A schematic diagram of a DNA encoding rule according to an embodiment of the present invention;
[0091] Fig.13 A schematic diagram of an addition operation in encoding according to an embodiment of the present invention;
[0092] Fig.14 A schematic diagram of a subtraction operation in encoding according to an embodiment of the present invention;
[0093] Fig.15 A schematic diagram of an XOR operation in encoding according to an embodiment of the present invention;
[0094] Fig.16 A schematic diagram of an identical or identical operation in a coding according to an embodiment of the present invention;
[0095] Fig.17A schematic diagram of a multiplication operation in encoding according to an embodiment of the present invention;
[0096] Fig.18 A schematic diagram of a diffusion process according to an embodiment of the present invention;
[0097] Fig.19 A schematic diagram of an overall image encryption process according to an embodiment of the present invention;
[0098] Fig. 20 A schematic diagram of an image encryption and decryption result according to an embodiment of the present invention;
[0099] Fig.21 A schematic diagram of a key change according to an embodiment of the present invention;
[0100] Fig. 22 A schematic diagram of a histogram of an original image according to an embodiment of the present invention;
[0101] Fig.23 A schematic diagram of a histogram of an encrypted image according to an embodiment of the present invention;
[0102] Fig.24 A schematic diagram of the correlation of adjacent pixels of a grayscale image according to an embodiment of the present invention;
[0103] Fig.25 A schematic diagram of the NPCR value and UACI value results of a differential attack according to an embodiment of the present invention;
[0104] Fig.26 A schematic diagram of a peak signal-to-noise ratio result of a decrypted image according to an embodiment of the present invention;
[0105] Fig. 27 The figure is a schematic diagram of the structure of an image encryption device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0106] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0107] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".
[0108] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0109] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0110] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.
[0111] Chaotic system: refers to a deterministic system with seemingly random irregular motion, whose behavior is uncertain, unrepeatable and unpredictable. This is the chaotic phenomenon. Chaos is an inherent characteristic of nonlinear dynamic systems and a common phenomenon in nonlinear systems. According to the properties of the dynamic system, chaos can be divided into four types: time chaos, space chaos, space-time chaos, and functional chaos.
[0112] In related technologies, with the rapid development of Internet technology, the way of information exchange and information storage in people's daily life has changed significantly. People transmit information more through the network to achieve information interconnection and resource sharing. This information mainly includes text, images, videos and other contents. Among them, images have the characteristics of being more vivid, more vivid and more intuitive, and have become one of the important ways of multimedia information transmission. Images can intuitively convey the information to be expressed and play an important role in politics, economy, military and other fields. However, due to certain security risks on the Internet, some attackers will exploit loopholes to steal important information. Therefore, it is particularly important to study image information security. Image encryption algorithms confuse image pixels, making regular pixels completely disordered. The encrypted image presents noise map characteristics and is difficult to crack. Early image encryption algorithms used simple pixel value transformation techniques, such as Fourier transform, wavelet transform and Arnold transform. After years of research, chaotic systems were introduced into image encryption algorithms. Scientists have constructed a set of nonlinear equations to describe atmospheric changes, namely the Lorenz system, which has the characteristics of chaotic unpredictability and initial value sensitivity. Scholars have applied chaotic systems to image encryption, greatly increasing the image encryption key space and enhancing the security of the algorithm. Most of the current image encryption algorithms are based on chaotic systems and use a "scrambling + diffusion" obfuscation structure to achieve encryption. Chaos has the characteristics of randomness, ergodicity, initial value sensitivity and topological transfer, and is widely used in the field of image encryption. Researchers continue to propose or improve chaotic mapping. Current research focuses more on multi-chaotic systems with more complex dynamic behaviors, larger chaotic ranges and more control parameters, which have higher complexity and security. In addition, the scrambling methods of image encryption algorithms mainly include pixel position transformation and pixel value replacement methods. Pixel position transformation mainly includes path scanning, space filling curves, block scrambling, and type scrambling. More importantly, the purpose of the diffusion link of the image encryption algorithm is to diffuse the tiny differences in the image to the entire image. The diffusion method based on algebraic operations is relatively simple and can be easily cracked by attackers. The most commonly used diffusion methods are DNA coding and convolution operations. Since DNA coding has the characteristics of fast computing speed and good encryption effect, calculations based on DNA coding have become a hot topic in image encryption algorithm research. Currently, most researchers directly diffuse the DNA sequence after encoding the sequence into a DNA sequence. To a certain extent, adjacent bits are not scrambled, and the randomness, complexity, security, and confusion of adjacent pixels are low.
[0113] In order to solve the above problems, the present invention first processes the image through the SHA-256 algorithm to obtain a hash value with a length of 256 bits, and obtains the initial value of the chaotic system after processing to generate a chaotic sequence. Secondly, the image is scrambled by randomly selecting a V-shaped scrambling starting point through the chaotic sequence, and the image is bit-level scrambled according to the proposed quaternary form bit-level scrambling method. Then, after encoding the image and the chaotic sequence DNA, the crossover and DNA operation mode of the DNA sequence and the DNA chaotic sequence are controlled by the chaotic sequence to further improve the randomness of the DNA sequence. Finally, the change is spread to the entire image through ciphertext feedback, and encryption is completed after the DNA is decrypted and reshaped into an image to achieve image encryption, thereby improving randomness, security and adjacent pixel confusion.
[0114] An image encryption method provided in an embodiment of the present application relates to the field of image encryption technology. An image encryption method provided in an embodiment of the present application can be applied to a terminal, can be applied to a server, or can be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or can be configured as a server cluster or distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server can also be a node server in a blockchain network; the software can be an application that implements an image encryption method, etc., but is not limited to the above forms.
[0115] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0116] The following is a detailed explanation of the embodiments of the present application in conjunction with the accompanying drawings:
[0117] Figure 1 is an optional flowchart of an image encryption method provided in an embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S110.
[0118] Step S101, obtaining a grayscale image;
[0119] Step S102: converting the grayscale image according to the image height and the image width to obtain a first image matrix;
[0120] Step S103, according to the first image matrix, calculating a first chaotic sequence, a second chaotic sequence, a third chaotic sequence, a fourth chaotic sequence, a fifth chaotic sequence, a sixth chaotic sequence, a seventh chaotic sequence, an eighth chaotic sequence and a ninth chaotic sequence, wherein the length of the first chaotic sequence, the length of the second chaotic sequence, the length of the third chaotic sequence, the length of the fourth chaotic sequence, the length of the fifth chaotic sequence, the length of the sixth chaotic sequence and the length of the eighth chaotic sequence are all equal, the length of the seventh chaotic sequence is equal to the length of the ninth chaotic sequence, and the length of the first chaotic sequence is less than the length of the seventh chaotic sequence;
[0121] Step S104, performing glyph scrambling processing on the first image matrix according to the first chaotic sequence to obtain a second image matrix;
[0122] Step S105: performing bit-level scrambling processing on the second image matrix according to the second chaotic sequence and the third chaotic sequence to obtain a third image matrix;
[0123] Step S106: performing a first encoding process on the third image matrix according to the fourth chaotic sequence to obtain a first image sequence;
[0124] Step S107: performing a second coding process on the fifth chaotic sequence according to the fourth chaotic sequence to obtain a first coding sequence;
[0125] Step S108, performing diffusion processing on the first image sequence and the first coding sequence according to the seventh chaotic sequence and the ninth chaotic sequence to obtain a second image sequence;
[0126] Step S109: performing ciphertext feedback processing on the second image sequence according to the sixth chaotic sequence to obtain a third image sequence;
[0127] Step S110: Decode the third image sequence according to the eighth chaotic sequence to obtain an encrypted image.
[0128] Steps S101 to S110 shown in the embodiment of the present application implement image encryption, thereby improving randomness, security, and adjacent pixel confusion.
[0129] In step S101 of some embodiments, the grayscale image may be obtained through an image database or other methods, not limited thereto.
[0130] In some embodiments, in step S102, the grayscale image may be converted according to the image height and the image width to obtain a first image matrix. Exemplarily, the image height may be set to M, the image width may be set to N, and the grayscale image P0 may be converted to a first image matrix P1 of size M*N according to the image height M and the image width N, wherein the first image matrix is a two-dimensional matrix.
[0131] In some embodiments, in step S103, according to the first image matrix, calculating the first chaotic sequence, the second chaotic sequence, the third chaotic sequence, the fourth chaotic sequence, the fifth chaotic sequence, the sixth chaotic sequence, the seventh chaotic sequence, the eighth chaotic sequence and the ninth chaotic sequence may include but are not limited to the following steps:
[0132] Performing a hash operation on the first image matrix using a preset hash algorithm to obtain an external key;
[0133] Divide the external key according to the preset number of groups to obtain several sub-keys;
[0134] According to several sub-keys, a chaotic parameter set is calculated;
[0135] According to the chaotic parameter set, the initial value set of the chaotic system is calculated;
[0136] According to the preset number of iterations, the initial value set of the chaotic system is substituted into the three-dimensional chaotic system to calculate the chaotic sequence set;
[0137] According to the chaotic sequence set, a first chaotic sequence to be intercepted, a second chaotic sequence to be intercepted and a third chaotic sequence to be intercepted are calculated;
[0138] Performing a first interception process on the first chaotic sequence to be intercepted to obtain a first chaotic sequence, a second chaotic sequence, a third chaotic sequence, a fourth chaotic sequence and a fifth chaotic sequence;
[0139] Performing a second interception process on the second chaotic sequence to be intercepted to obtain a sixth chaotic sequence and a seventh chaotic sequence;
[0140] The third chaotic sequence to be intercepted is subjected to a third interception process to obtain an eighth chaotic sequence and a ninth chaotic sequence.
[0141] In some embodiments, a preset hash algorithm may be used to perform a hash operation on the first image matrix P1 to obtain an external key K. The preset hash algorithm may include a SHA-256 algorithm. Exemplarily, the SHA-256 algorithm may be used to process the input first image matrix to obtain a 256-bit binary hash value K as the external key. Then, according to the preset number of groups, the external key is divided to obtain a number of subkeys. Exemplarily, the preset number of groups may be set to 32 groups, each group being an 8-bit binary number, and the external key K is divided to obtain a number of subkeys K={K1, K2, ...K 32 Then, according to several sub-keys, the chaotic parameter set is calculated, where the calculation formula of the chaotic parameter set is: In the formula, {a, β, γ} is the chaotic parameter set, K1 is the first subkey, Represents XOR calculation. Then, according to the chaotic parameter set, the initial value set of the chaotic system is calculated, where the calculation formula of the initial value set of the chaotic system is: In the formula, {x0, y0, z0} is the initial value set of the chaotic system, and x′0, y′0, and z′0 are all constants. Then, according to the preset number of iterations, the initial value set of the chaotic system is substituted into the three-dimensional chaotic system to calculate the chaotic sequence set. Exemplarily, the initial value set of the chaotic system {x0, y0, z0} can be substituted into the three-dimensional chaotic system, iterated 5*M*N+T0 times, and the first T0 times are discarded to remove the transient effects in the chaotic sequence, and the chaotic sequences x1, y1, and z1 with a length of 5*M*N are obtained, and combined into a chaotic sequence set {x1, y1, z1}. Then, according to the chaotic sequence set, the first chaotic sequence to be intercepted SeqX, the second chaotic sequence to be intercepted SeqY, and the third chaotic sequence to be intercepted SeqZ are calculated, where the calculation formula of the chaotic sequence to be intercepted is: Wherein, SeqX is the first chaotic sequence to be intercepted, SeqY is the second chaotic sequence to be intercepted, SeqZ is the third chaotic sequence to be intercepted, and {x1, y1, z1} is a chaotic sequence set. Finally, the first chaotic sequence to be intercepted SeqX is subjected to the first interception process to obtain the first chaotic sequence A, the second chaotic sequence B, the third chaotic sequence C, the fourth chaotic sequence D and the fifth chaotic sequence E, all of which are of length M*N. The second chaotic sequence SeqY is subjected to the second interception process to obtain the sixth chaotic sequence F of length M*N and the seventh chaotic sequence H of length 4*M*N. The third chaotic sequence SeqZ is subjected to the third interception process to obtain the eighth chaotic sequence G of length M*N and the ninth chaotic sequence I of length 4*M*N. It can be understood that the multi-vortex chaotic system (EMSCS) is a type of chaotic system that is solved using a simple polynomial function. EMSCS has rich dynamic behaviors, such as nested multi-vortex attractors and multiple signal control characteristics acting on the entire multi-vortex attractor. The expression of EMSCS is: Among them, x, y, z are input values, is the output value, a=0.8, β=0.5, γ=2. This embodiment is improved on this basis to obtain an improved 3D hyperchaotic system. EMSCS is a special basic system for constructing a special multi-vortex chaotic system. It only contains one nonlinear term, one constant term and four linear terms. In order to increase its complexity and disorder, a new 3D chaotic system is constructed by coupling the nonlinear term xy to the first and third terms of the equation, and its expression is: Among them, x, y, z are the state variables of the chaotic system, and a, b, c, d, e, and f are the parameters of the chaotic system, which can control the chaotic behavior of the chaotic system. When the system parameters a = 0.8, b = 0.6, c = 0.8, d = 2, e = 0.5, f = 15, and the initial values x0 = 0.1, y0 = 0.1, and z0 = 0.1, the system is in a chaotic state and has good chaotic behavior. Among them, the chaotic state of the xy plane of the 3D chaotic system is as follows Figure 2 As shown, the chaotic state in the xz plane is Figure 3 As shown, the chaotic state in the yz plane is Figure 4 As shown, the chaotic state in the xyz plane is Figure 5 shown.
[0142] In some embodiments, in step S104, the first image matrix is subjected to a glyph scrambling process according to the first chaotic sequence to obtain a second image matrix, which may include but is not limited to the following steps:
[0143] Calculate the scanning starting position value according to the first chaotic sequence;
[0144] Performing a V-shaped scan on the first image matrix according to the scan start position value, the image height and the image width to obtain a plurality of scan values;
[0145] A plurality of scan values are exchanged with a plurality of maximum row pixel values that have not been exchanged in the first image matrix until each row is exchanged, thereby obtaining a second image matrix in which the number of scan values is equal to the number of maximum row pixel values. The exchange process is used to exchange the scan values and the maximum row pixel values that are located in the same column.
[0146] In some embodiments, image scrambling is mainly to arrange the pixels in the image according to a certain rule, or to transform the pixels of the image, so as to effectively scramble the regular and visible information in the image into random and directly observable image information, so as to enhance the security and confidentiality of the image, so that unauthorized users cannot easily obtain or tamper with the image content. The scrambled image can be quickly obtained from the original image through the decryption algorithm, which can ensure the feasibility of the image encryption algorithm. In some embodiments, the scanning starting position value can be calculated according to the first chaotic sequence A, where the calculation formula of the scanning starting position value is: i =mod(A,Mi)+1,i=1,2,...,M-2, where a i is the scan starting position value, M is the image height, and A is the first chaotic sequence. Then according to the scan starting position value a i , image height M and image width N, perform a V-shaped scan on the first image matrix P1 to obtain a number of scan values, and finally exchange the several scan values with the several maximum row pixel values that have not been exchanged in the first image matrix until each row has been exchanged to obtain the second image matrix P2. Among them, the number of scan values is equal to the number of maximum row pixel values, and the exchange process is used to exchange the scan values and the maximum row pixel values in the same column. Exemplarily, the first column of V-shaped pixel scrambling starting position can be selected in M rows according to the scan starting position value, and then the pixel value is scanned according to the V-shaped route to obtain the scan value, which is exchanged with the maximum row pixel value of the current column, and then a second round of scrambling is performed. At this time, the height of the image becomes (M-1), and the V-shaped scrambling starting position is selected from (M-1), and the scrambling process is terminated after all rows are scrambled. The scrambling process is as follows: Figure 6 As shown, in this example, the image width and image height are 6*6, and the starting point of the first column of pixels selected in sequence is (5, 2, 3, 2, 1), and then pixels are selected in sequence according to the V-shaped curve and exchanged with the current last row (row 6). The last row after the first round of exchange remains unchanged, and the last row of the next round is row 5. After selecting pixels in sequence and exchanging them with the last row, the scrambling is completed to obtain the second image matrix P2.
[0147] In some embodiments, in step S105, the second image matrix is subjected to bit-level scrambling processing according to the second chaotic sequence and the third chaotic sequence to obtain a third image matrix, which may include but is not limited to the following steps:
[0148] Calculating a bit conversion mode value according to the second chaotic sequence;
[0149] Performing quaternary conversion processing on the third chaotic sequence and the second image matrix;
[0150] According to the quaternary number scrambling rule and the bit conversion mode value, the third chaotic sequence after the quaternary conversion is subjected to the first bit conversion to obtain a quaternary chaotic sequence;
[0151] According to the quaternary number scrambling rule and the bit conversion mode value, a second bit conversion is performed on the second image matrix after the quaternary conversion process to obtain a quaternary image matrix;
[0152] Perform decimal conversion on quaternary chaotic sequence and quaternary image matrix;
[0153] Calculate the pixel arrangement order according to the quaternary chaotic sequence after decimal conversion;
[0154] According to the pixel arrangement order, the quaternary image matrix after the decimal conversion is sorted to obtain a third image matrix.
[0155] In some embodiments, after the pixel-level scrambling of the image, the image data has not changed, and the attacker can easily crack the ciphertext image through a brute force attack. Bit-level scrambling can improve the security of the encryption result by scrambling the pixel bits, and can fully scramble the bit distribution of the pixel itself through a bit-level scrambling method based on quaternary numbers. In some embodiments, the bit conversion mode value can be calculated according to the second chaotic sequence B, wherein the calculation formula of the bit conversion mode value is: Trans(i) = mod(B(i), 4) + 1, i = 1, 2..., M*N, wherein Trans(i) is the bit conversion mode value, B is the second chaotic sequence, M is the image height, and N is the image width. Then, the third chaotic sequence C and the second image matrix P2 are subjected to quaternary conversion processing. According to the quaternary number scrambling rule and the bit conversion mode value, the third chaotic sequence C after the quaternary conversion processing is subjected to the first bit conversion to obtain a quaternary chaotic sequence. According to the quaternary number scrambling rule and the bit conversion mode value, the second image matrix P2 after the quaternary conversion processing is subjected to the second bit conversion to obtain a quaternary image matrix. Among them, in the quaternary number scrambling rule, a pixel is converted into a quaternary number with four bits, and there are four conversion modes. The first conversion mode is as follows: Figure 7 As shown, the second conversion method is as follows Figure 8 As shown, the third conversion method is as follows Fig. 9 As shown, the fourth conversion method is as follows Fig.10As shown, the first line is 4 bits before conversion, the second line is 4 bits after conversion, and the arrows represent bit position swaps. Then, the quaternary chaotic sequence and the quaternary image matrix are converted into decimals, and the pixel arrangement order is calculated according to the quaternary chaotic sequence after the decimal conversion. Finally, the quaternary image matrix after the decimal conversion is sorted according to the pixel arrangement order to obtain a third image matrix P3. Exemplarily, the scrambling process of bit-level scrambling is as follows: Fig.11 As shown in the figure, matrix B (i.e., the second chaotic sequence B) is used to select the conversion mode, matrix P is the plaintext image (i.e., the second image matrix P2), and matrix C is the matrix of the chaotic sequence reorganization (i.e., the third chaotic sequence C). Matrices P and C are converted into quaternary form, and after matrix B is processed, it is used to select the conversion mode of the corresponding positions of the two quaternary matrices. For example, the quaternary numbers of the corresponding positions of the upper left corners of matrices P and C are "0112" and "0133" respectively. At this time, the number of the upper left corner position of matrix B is 2, corresponding to the second conversion mode. According to the second conversion mode, the conversion is performed, and "0112" is converted to "1201", and "0133" is converted to "3301". The pixels of the scrambled matrix C are scanned row by row to be (241, 80, 200, 54), and the pixel arrangement order is (1, 3, 2, 4) according to the pixel value size. The pixels (97, 29, 1, 168) are scanned row by row in the matrix P. The scrambled matrix P is indexed and sorted by position using the pixel arrangement order to obtain the sorted sequence (97, 1, 29, 168), which is reshaped into the matrix Q (i.e., the third image matrix P3).
[0156] In some embodiments, in step S106, performing a first encoding process on the third image matrix according to the fourth chaotic sequence to obtain a first image sequence may include but is not limited to the following steps:
[0157] Calculate the encoding mode value according to the fourth chaotic sequence;
[0158] performing binary conversion processing on the third image matrix;
[0159] According to the coding rule and the coding mode value, the third image matrix after the binary conversion process is encoded to obtain the first image sequence.
[0160] In some embodiments, the encoding mode value may be calculated according to the fourth chaotic sequence D, wherein the encoding mode value calculation formula is: i =mod(D(i),8)+1,i=1,2,...,M*N, where, r iis the encoding mode value, D is the fourth chaotic sequence, M is the image height, and N is the image width. Then the third image matrix P3 is binary converted, and the third image matrix P3 after binary conversion is encoded according to the encoding rule and the encoding mode value to obtain the first image sequence DNAImg. Among them, the DNA encoding rule is as follows Fig.12 As shown in the figure, there are 8 encoding methods that can convert pixel values into binary form. The binary '00', '01', '10', '11' corresponds to the 4 bases of DNA coding, and the binary sequence is converted into a DNA coding sequence. The key is then used to select the scrambling, replacement or confusion operation of the DNA sequence to increase the security of encryption. It can be understood that DNA coding technology is a biologically inspired image encryption method. DNA coding technology has the characteristics of high information density, strong parallelism, and strong anti-attack. Using the characteristics of DNA sequences for image encryption can effectively improve encryption efficiency. Usually, the image is converted into a DNA sequence and encrypted using the pairing rules between the base pairs of the DNA sequence.
[0161] In some embodiments, in step S107, the fifth chaotic sequence E may be subjected to a second encoding process according to the fourth chaotic sequence D to obtain a first encoding sequence DNASeq. The second encoding process is similar to the first encoding process, and a similar encoding method may be used to encode the fifth chaotic sequence E to obtain the first encoding sequence DNASeq.
[0162] In some embodiments, in step S108, the first image sequence and the first coding sequence are diffused according to the seventh chaotic sequence and the ninth chaotic sequence to obtain the second image sequence, which may include but is not limited to the following steps:
[0163] According to the seventh chaotic sequence, the sequence change judgment value is calculated;
[0164] According to the ninth chaotic sequence, the diffusion mode value is calculated;
[0165] The first image sequence and the first coding sequence are diffused according to the diffusion rule, the sequence change judgment value and the diffusion mode value to obtain the second image sequence.
[0166] In some embodiments, diffusion refers to the change of a single plaintext pixel or key, which affects each pixel value of the entire image through certain rules, so as to effectively improve the key sensitivity of the encryption algorithm and the ability to resist differential attacks. After the image is scrambled at the pixel level, it only hides the visual information of the image, and cannot change the unique statistical characteristics of the image, resulting in the system security not being guaranteed. Therefore, the diffusion operation is performed after the scrambling link is completed, so that the ciphertext image can better hide the image information. In some embodiments, the sequence change judgment value can be calculated according to the seventh chaotic sequence, wherein the calculation formula of the sequence change judgment value is: CoSeq (i) = mod (H, 2), i = 1, 2, ..., 4 * M * N, wherein CoSeq (i) is the sequence change judgment value, H is the seventh chaotic sequence, M is the image height, and N is the image width. Then, according to the ninth chaotic sequence, the diffusion mode value is calculated, wherein the calculation formula of the diffusion mode value is: OpSeq(i)=mod(I,5)+1, i=1,2,...,4*M*N, wherein OpSeq(i) is the diffusion mode value, I is the ninth chaotic sequence, M is the image height, and N is the image width. Finally, according to the diffusion rule, the sequence change judgment value and the diffusion mode value, the first image sequence DNAImg and the first coding sequence DNASeq are diffused to obtain the second image sequence P4. Among them, the diffusion rules include addition operation, subtraction operation, XOR operation, XNOR operation, and multiplication operation. The addition operation is as follows: Fig.13 As shown, the subtraction operation is Fig.14 As shown, the XOR operation is Fig.15 As shown, the same or operation is as Fig.16 As shown, the multiplication operation is Fig.17 As shown. For example, the diffusion process is as follows Fig.18 As shown, the first image sequence DNAImg and the first coding sequence DNASeq are diffused by two chaotic sequences (i.e., the sequence change judgment value CoSeq and the diffusion mode value OpSeq) to obtain the second image sequence P4. Among them, the value of CoSeq is 0 or 1, 0 represents that the image DNA sequence value does not change, and 1 represents that the DNA operation is performed between the first image sequence DNAImg and the first coding sequence DNASeq. The DNA operation mode is selected by the diffusion mode value OpSeq, and the values of OpSeq are 1, 2, 3, 4, and 5, which respectively represent the addition operation, subtraction operation, XOR operation, XNOR operation, and multiplication operation in the diffusion rule.
[0167] In some embodiments, in step S109, according to the sixth chaotic sequence, the second image sequence is subjected to ciphertext feedback processing to obtain a third image sequence, which may include but is not limited to the following steps:
[0168] Performing a first division on the sixth chaotic sequence to obtain a plurality of chaotic sequence blocks;
[0169] Performing a second division on the second image sequence to obtain a plurality of image sequence blocks;
[0170] If the sequence number of the image sequence block is 1, the image sequence block and the chaotic sequence block are subjected to a first XOR process to calculate a first encryption block, and the sequence number of the image sequence block is equal to the sequence number of the chaotic sequence block;
[0171] If the sequence number of the image sequence block is greater than 1, the sum of the image sequence block and the previous encryption block is calculated, and a second XOR process is performed with the chaotic sequence block to calculate the corresponding second encryption block;
[0172] The first encrypted block and the plurality of second encrypted blocks are connected to obtain a third image sequence.
[0173] In some embodiments, the ciphertext feedback mode uses the encryption result of the previous ciphertext block as the encryption input of the next plaintext block, thereby forming a stream encryption mode. This stream encryption mode is suitable for situations where data streams need to be encrypted byte by byte or bit by bit, such as real-time communication or network transmission. The ciphertext feedback mode introduces a feedback mechanism so that the same plaintext can obtain different ciphertext outputs in different encryption rounds. This randomness increases the security of the cryptographic system and prevents common attacks on symmetric encryption algorithms. In some embodiments, the sixth chaotic sequence F can be first divided into a first number of chaotic sequence blocks, and the second image sequence can be divided into a second number of image sequence blocks. If the sequence number of the image sequence block is 1, the image sequence block p i With the chaotic sequence block F i Perform the first XOR process to calculate the first encrypted block; if the sequence number of the image sequence block is greater than 1, calculate the image sequence block p i With the previous encrypted block q i-1 and the chaotic sequence block F i Perform a second XOR process, calculate the corresponding second encrypted block, and then connect the first encrypted block and multiple second encrypted blocks to obtain the third image sequence P5. The sequence number of the image sequence block is equal to the sequence number of the chaotic sequence block. The calculation formula of the encrypted block is: In the formula, q i is the ith encrypted block, p i is the image sequence block, F i is a chaotic sequence block, q i-1 is the i-1th encrypted block, Represents XOR calculation, i=1, 2, ..., 4*M*N.
[0174] In some embodiments, in step S110, decoding the third image sequence according to the eighth chaotic sequence to obtain an encrypted image may include but is not limited to the following steps:
[0175] According to the eighth chaotic sequence, a decoding mode value is calculated;
[0176] The third image sequence is decoded according to the encoding rule and the decoding mode value to obtain an encrypted image.
[0177] In some embodiments, the decoding mode value may be calculated according to the eighth chaotic sequence G, wherein the decoding mode value calculation formula is: i =mod(G(i),8)+1,i=1,2,...,M*N, where w i is the decoding mode value, G is the eighth chaotic sequence, M is the image height, and N is the image width. Then, according to the encoding rule and the decoding mode value, the third image sequence P5 is decoded to obtain the encrypted image P6. Moreover, the decryption process is opposite to the encryption process, and the encrypted image can be decrypted to the original image by performing the inverse operation of the encryption step.
[0178] In some embodiments, the overall process of image encryption is as follows: Fig.19 As shown, the SHA-256 algorithm can be used to perform a hash operation on the first image matrix P1, calculate the chaotic parameters, and substitute them into the 3D chaotic system to obtain the first chaotic sequence to be intercepted SeqX, the second chaotic sequence to be intercepted SeqY and the third chaotic sequence to be intercepted SeqZ, and then intercept them respectively to obtain the first chaotic sequence A, the second chaotic sequence B, the third chaotic sequence C, the fourth chaotic sequence D, the fifth chaotic sequence E, the sixth chaotic sequence F, the seventh chaotic sequence H, the eighth chaotic sequence G and the ninth chaotic sequence I, and then perform V-shaped scrambling according to the first chaotic sequence A to obtain the second image matrix P2, perform bit-level scrambling according to the second chaotic sequence B and the third chaotic sequence C to obtain the third image matrix P3, perform DNA diffusion according to the fourth chaotic sequence D, the fifth chaotic sequence E, the seventh chaotic sequence H and the ninth chaotic sequence to obtain the second image sequence P4, perform ciphertext feedback according to the sixth chaotic sequence F to obtain the third image sequence P5, and perform DNA decoding according to the eighth chaotic sequence G to obtain the encrypted image P6.
[0179] In some embodiments, an image encryption method provided by this embodiment further includes the following steps:
[0180] Conduct security experimental analysis on encrypted images;
[0181] Safety experimental analysis includes:
[0182] Conduct key security analysis;
[0183] Alternatively, perform key sensitivity analysis;
[0184] Alternatively, statistical analysis of pixel values may be performed;
[0185] Alternatively, adjacent pixel correlation analysis may be performed;
[0186] Alternatively, conduct differential attack resistance analysis;
[0187] Alternatively, perform noise attack resistance analysis.
[0188] In some embodiments, in order to verify the security and reliability of the image encryption method of this embodiment, some simulation experiments are conducted on images selected from the USC-SIPI image database and commonly used standard test images based on the MATLAB R2018a platform under Microsoft Windows 10. Fig. 20 As shown, the selected image size is 256×256. The results show that the encrypted image is similar to the noise image, and the decrypted image is completely consistent with the original image. The image encryption method of this embodiment can effectively encrypt the image.
[0189] In some embodiments, key security analysis can be performed. The key space is the set of all keys that can be generated in the image encryption algorithm. The key space of the image encryption algorithm must be as large as possible. The larger the key space, the more robust the image encryption algorithm. When the key space is large enough, it can effectively resist exhaustive attacks. Exhaustive attacks are machines that traverse all possible keys to try out the correct key for the encryption system. When the key space is large enough, brute force attacks exceed their timeliness, so that the encryption system can remain relatively secure. The current limit of brute force attacks is 2 100 In this embodiment, there are 6 control parameters and 3 initial values, and the calculation accuracy is 10 -10 , so the key space of this algorithm is 10 10×9 =10 90 ≈2 999 , which is much longer than the effective time of brute force attack, so the algorithm is sufficient to resist brute force attack.
[0190] In some embodiments, key sensitivity analysis can be performed. Key sensitivity analysis is used to evaluate the differences between the initial values of the system generated by the encryption system under the action of different keys. The key of the image encryption algorithm needs to have a high sensitivity. When the key changes slightly, the initial value of the encryption algorithm will be greatly different from the correct key, the encryption result will be very different, and the decrypted image will be completely different from the original image. Key sensitivity can be used to analyze the security of the encryption algorithm. In the key sensitivity analysis, only one key value is changed at a time, and the other keys remain unchanged. There are 3 sets of data for the changed keys, such as Fig.21 As shown. During the encryption process, according to Fig.21The Boat image is encrypted with the key in . From the encryption result, it can be seen that it is difficult to see the difference between the encrypted images. The number of pixels change rate (NPCR) can compare the values of the pixels at the corresponding positions of the two images and record the proportion of the number of different pixels to all the pixels. If the values of all the pixels at the corresponding positions of the two images are different, but if the values of the pixels at their corresponding positions are very different, it means that the difference between the two images is still very small. The number of pixels change rate (NPCR) is one-sided as a measure of the difference between the two images. The unified average changing intensity (UACI) can compare the values of the pixels at the corresponding positions of the two images, record their differences, and calculate the average value of the ratio of the difference of all the pixels at the corresponding positions to the maximum difference. The number of pixels change rate (NPCR) and the unified average changing intensity (UACI) are used to measure the number of changed pixels and the average changing intensity of pixels between the two ciphertext images. The difference between the two encrypted images can be intuitively obtained through the data. This embodiment uses the pixel number change rate (NPCR) and the unified average change intensity (UACI) to quantitatively analyze the ciphertext images encrypted with different keys and the ciphertext images encrypted with the correct key. Under ideal conditions, the value of the pixel number change rate (NPCR) should be 99.6094%, and the value of the unified average change intensity (UACI) should be 33.4635%. In the data results obtained in this embodiment, the NPCR value of Key1 is 99.6240, and the UACI value is 33.4121, the NPCR value of Key2 is 99.5021, and the UACI value is 33.4803, and the NPCR value of Key3 is 99.5853, and the UACI value is 33.4216. It can be seen from the data that both the NPCR and UACI values are close to the ideal values, indicating that the encryption algorithm has a high sensitivity to the encryption key, and even if the encryption key changes slightly, the encryption result can have a high security.
[0191] In some embodiments, pixel value statistical analysis can be performed. The histogram can show the distribution of pixel values of an image, which is used to determine the ability of the encryption algorithm to resist statistical attacks. Since the plaintext image has certain statistical laws, attackers may use known information to restore the original image and achieve the purpose of cracking the encryption system. Therefore, the ciphertext image should hide statistical information as much as possible so that attackers cannot obtain valid information from the ciphertext image. A more secure encryption algorithm is one that can generate an encrypted image with a uniformly distributed histogram feature. The histogram of the original image is as follows: Fig. 22 As shown, the histogram of the encrypted image is Fig.23As shown, it can be seen that the histogram of the ciphertext image is almost evenly distributed, while the histogram distribution of the original image is uneven. From the evenly distributed histogram, it can be seen that the encryption effect of the encryption algorithm is relatively good, and the security of the encrypted image is also relatively high.
[0192] In some embodiments, adjacent pixel correlation analysis can be performed. A secure image encryption algorithm must have the ability to reduce the correlation between adjacent pixels. If there is still a high correlation between adjacent pixels in the ciphertext image, the attacker can use the relationship between pixels to crack the encryption system. The size of the correlation coefficient can be used to measure the quality of the encrypted image. The closer the value is to 1, the higher the image correlation is. The closer to 0, the worse the encrypted image quality is, which means that the security of the encryption algorithm is not high and the ability to resist attacks is weak. In the correlation analysis, the correlation coefficient values of adjacent pixels in the original image and the ciphertext image in the horizontal, vertical and diagonal directions are calculated, and the values are observed to determine whether the correlation between pixels in the ciphertext image is effectively reduced. The correlation coefficient value calculation result is shown as follows. Fig.24 As shown, Baboon represents a baboon image, Boat represents a boat image, Cameraman represents a photographer image, House represents a house image, and Pepper represents a bell pepper image. It can be obtained that the correlation of the ciphertext image is close to 0. Combining the two sets of data, it can be seen that the encryption algorithm of this embodiment can effectively reduce the high correlation between adjacent pixels of the image and obtain an encryption result with higher security.
[0193] In some embodiments, differential attack resistance analysis can be performed. When attacking an image encryption system, the attacker can make slight changes to the pixels of the original image, encrypt the two images before and after the changes respectively, and then analyze the relationship between them by comparing the two encrypted images. The ciphertext image can be cracked by finding the pattern of changes before and after. This type of attack is called a differential attack. If an encryption algorithm wants to have a strong ability to resist differential attacks, there must be a huge difference between its encrypted image and the original encrypted image when there is a slight change in the image pixels. The analysis of the encryption algorithm's ability to resist differential attacks measures the difference between the two encrypted images by calculating their NPCR and UACI values. The difference between the two encrypted images is only one pixel value. The NPCR value and UACI value between the encryption results are as follows. Fig.25 As shown, the results show that the encryption algorithm is highly sensitive to slight changes in the plaintext image, and it can be seen that the encryption algorithm can resist differential attacks well.
[0194] In some embodiments, noise attack resistance analysis is performed. Noise attack is when image information is interfered with by noise during transmission. The encrypted image may be disturbed and some information may be disordered, making it difficult to decrypt the original image during decryption. The anti-noise attack capability of the encryption system has a great influence on the robustness of the encryption system. When analyzing the anti-noise attack capability of the encryption algorithm, by adding noise of different intensities to the encrypted image, such as salt and pepper noise and Gaussian noise, and then decrypting the processed ciphertext, the decrypted image is visually compared with the original image to analyze the ability of the decryption algorithm to restore the original image. When analyzing the anti-noise interference capability of the encryption algorithm, salt and pepper noise of different intensities can be added to the encrypted image, and then it can be decrypted to obtain the decrypted image. It can be seen from the experimental results that after the ciphertext image has been subjected to a noise attack, it can be decrypted by the algorithm into the original image, and the content of the image can still be clearly seen. Next, the impact of noise attacks is analyzed through quantitative analysis. The peak signal-to-noise ratio (PSNR) is an important indicator used to analyze the similarity between the original image and the decrypted image. The mean square error (MSE) is the cumulative square error between the original image and the encrypted image. The difference between the two images is measured by calculating the mean square error (MSE) for each pixel at each position of the two images. The larger the PSNR value, the greater the robustness of the encryption algorithm. This embodiment analyzes the robustness of the encryption algorithm through the peak signal-to-noise ratio (PSNR). The PSNR value is calculated between the decrypted image and the original image of the ciphertext image after the attack with salt and pepper noise density of 0.01, 0.05 and 0.1. The calculation results are as follows: Fig.26 As shown in the figure, through comparative analysis, it can be seen that the encryption algorithm has good resistance to salt and pepper noise attacks and has high algorithm security. In addition to the above experimental analysis, it is also possible to perform pruning attack resistance analysis, chi-square test, information entropy analysis, plaintext attack analysis, and comparative analysis of multiple encryption algorithms.
[0195] The beneficial effects of implementing the embodiments of the present invention include: the embodiments of the present invention first obtain a grayscale image and convert it to obtain a first image matrix, then calculate multiple chaotic sequences, perform glyph scrambling processing on the first image matrix to obtain a second image matrix, perform bit-level scrambling processing on the second image matrix to obtain a third image matrix, perform first coding processing on the third image matrix to obtain a first image sequence, perform second coding processing on the fifth chaotic sequence to obtain a first coding sequence, then perform diffusion processing on the first image sequence and the first coding sequence to obtain a second image sequence, perform ciphertext feedback processing on the second image sequence to obtain a third image sequence, and finally perform decoding processing on the third image sequence to obtain an encrypted image, thereby realizing image encryption, and improving the randomness, security and adjacent pixel confusion of image encryption by scrambling and diffusion. At the same time, the encrypted image obtained after encryption in this embodiment has a histogram with an average distribution, the correlation of the encrypted image is close to 0, has a sufficiently large key space to resist exhaustive attacks, and can effectively resist statistical attacks, differential attacks, noise attacks, cropping attacks, etc., has high security, and can be widely used in image communication transmission.
[0196] like Fig. 27 As shown, an embodiment of the present invention further provides an image encryption device, comprising:
[0197] The first module 801 is used to obtain a grayscale image;
[0198] The second module 802 is used to convert the grayscale image according to the image height and the image width to obtain a first image matrix;
[0199] The third module 803 is used to calculate a first chaotic sequence, a second chaotic sequence, a third chaotic sequence, a fourth chaotic sequence, a fifth chaotic sequence, a sixth chaotic sequence, a seventh chaotic sequence, an eighth chaotic sequence and a ninth chaotic sequence according to the first image matrix, wherein the length of the first chaotic sequence, the length of the second chaotic sequence, the length of the third chaotic sequence, the length of the fourth chaotic sequence, the length of the fifth chaotic sequence, the length of the sixth chaotic sequence and the length of the eighth chaotic sequence are all equal, the length of the seventh chaotic sequence is equal to the length of the ninth chaotic sequence, and the length of the first chaotic sequence is less than the length of the seventh chaotic sequence;
[0200] The fourth module 804 is used to perform glyph scrambling processing on the first image matrix according to the first chaotic sequence to obtain a second image matrix;
[0201] The fifth module 805 is used to perform bit-level scrambling processing on the second image matrix according to the second chaotic sequence and the third chaotic sequence to obtain a third image matrix;
[0202] The sixth module 806 is used to perform a first encoding process on the third image matrix according to the fourth chaotic sequence to obtain a first image sequence;
[0203] The seventh module 807 is used to perform a second coding process on the fifth chaotic sequence according to the fourth chaotic sequence to obtain a first coding sequence;
[0204] An eighth module 808 is used to perform diffusion processing on the first image sequence and the first coding sequence according to the seventh chaotic sequence and the ninth chaotic sequence to obtain a second image sequence;
[0205] The ninth module 809 is used to perform ciphertext feedback processing on the second image sequence according to the sixth chaotic sequence to obtain a third image sequence;
[0206] The tenth module 810 is used to decode the third image sequence according to the eighth chaotic sequence to obtain an encrypted image.
[0207] The contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0208] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. An image encryption method, characterized in that: The following steps are involved: Get grayscale image; Convert the grayscale image according to the image height and the image width to obtain a first image matrix; According to the first image matrix, a first chaotic sequence, a second chaotic sequence, a third chaotic sequence, a fourth chaotic sequence, a fifth chaotic sequence, a sixth chaotic sequence, a seventh chaotic sequence, an eighth chaotic sequence and a ninth chaotic sequence are calculated, wherein the length of the first chaotic sequence, the length of the second chaotic sequence, the length of the third chaotic sequence, the length of the fourth chaotic sequence, the length of the fifth chaotic sequence, the length of the sixth chaotic sequence and the length of the eighth chaotic sequence are all equal, the length of the seventh chaotic sequence is equal to the length of the ninth chaotic sequence, and the length of the first chaotic sequence is less than the length of the seventh chaotic sequence; According to the first chaotic sequence, the first image matrix is subjected to a glyph scrambling process to obtain a second image matrix; According to the second chaotic sequence and the third chaotic sequence, performing bit-level scrambling processing on the second image matrix to obtain a third image matrix; According to the fourth chaotic sequence, performing a first encoding process on the third image matrix to obtain a first image sequence; According to the fourth chaotic sequence, performing a second coding process on the fifth chaotic sequence to obtain a first coding sequence; performing diffusion processing on the first image sequence and the first coding sequence according to the seventh chaotic sequence and the ninth chaotic sequence to obtain a second image sequence; According to the sixth chaotic sequence, performing ciphertext feedback processing on the second image sequence to obtain a third image sequence; According to the eighth chaotic sequence, the third image sequence is decoded to obtain an encrypted image; The step of performing glyph scrambling processing on the first image matrix according to the first chaotic sequence to obtain a second image matrix includes: Calculating a scanning start position value according to the first chaotic sequence; Performing a V-shaped scan on the first image matrix according to the scan start position value, the image height, and the image width to obtain a plurality of scan values; Exchanging the plurality of scan values with a plurality of maximum row pixel values that have not been exchanged in the first image matrix until each row is exchanged, thereby obtaining the second image matrix, wherein the number of the scan values is equal to the number of the maximum row pixel values, and the exchange process is used to exchange the scan values and the maximum row pixel values that are located in the same column; The step of performing bit-level scrambling processing on the second image matrix according to the second chaotic sequence and the third chaotic sequence to obtain a third image matrix includes: Calculating a bit conversion mode value according to the second chaotic sequence; Performing quaternary conversion processing on the third chaotic sequence and the second image matrix; According to the quaternary number scrambling rule and the bit conversion mode value, the third chaotic sequence after the quaternary conversion process is subjected to a first bit conversion to obtain a quaternary chaotic sequence; According to the quaternary number scrambling rule and the bit conversion mode value, performing a second bit conversion on the second image matrix after the quaternary conversion processing to obtain a quaternary image matrix; Performing decimal conversion processing on the quaternary chaotic sequence and the quaternary image matrix; Calculating the pixel arrangement order according to the quaternary chaotic sequence after decimal conversion; Sorting the quaternary image matrix after decimal conversion according to the pixel arrangement order to obtain the third image matrix; The step of performing diffusion processing on the first image sequence and the first coding sequence according to the seventh chaotic sequence and the ninth chaotic sequence to obtain a second image sequence includes: Calculating a sequence change judgment value according to the seventh chaotic sequence; Calculating a diffusion mode value according to the ninth chaotic sequence; The first image sequence and the first coding sequence are diffused according to a diffusion rule, the sequence change judgment value and the diffusion mode value to obtain the second image sequence.
2. The method according to claim 1, characterized in that The step of calculating, according to the first image matrix, a first chaotic sequence, a second chaotic sequence, a third chaotic sequence, a fourth chaotic sequence, a fifth chaotic sequence, a sixth chaotic sequence, a seventh chaotic sequence, an eighth chaotic sequence and a ninth chaotic sequence comprises: Using a preset hash algorithm to perform a hash operation on the first image matrix to obtain an external key; Dividing the external key according to a preset number of groups to obtain a plurality of subkeys; Calculating a chaotic parameter set according to the plurality of sub-keys; Calculating the initial value set of the chaotic system according to the chaotic parameter set; Substituting the initial value set of the chaotic system into the three-dimensional chaotic system according to a preset number of iterations to calculate the chaotic sequence set; According to the chaotic sequence set, a first chaotic sequence to be intercepted, a second chaotic sequence to be intercepted and a third chaotic sequence to be intercepted are calculated; Performing a first interception process on the first chaotic sequence to be intercepted to obtain the first chaotic sequence, the second chaotic sequence, the third chaotic sequence, the fourth chaotic sequence and the fifth chaotic sequence; Performing a second interception process on the second chaotic sequence to be intercepted to obtain the sixth chaotic sequence and the seventh chaotic sequence; A third interception process is performed on the third chaotic sequence to be intercepted to obtain the eighth chaotic sequence and the ninth chaotic sequence.
3. The method according to claim 1, characterized in that The step of performing a first encoding process on the third image matrix according to the fourth chaotic sequence to obtain a first image sequence comprises: Calculating a coding mode value according to the fourth chaotic sequence; Performing binary conversion processing on the third image matrix; According to the encoding rule and the encoding mode value, the third image matrix after the binary conversion process is encoded to obtain the first image sequence.
4. The method according to claim 1, characterized in that: The step of performing ciphertext feedback processing on the second image sequence according to the sixth chaotic sequence to obtain a third image sequence comprises: Performing a first division on the sixth chaotic sequence to obtain a plurality of chaotic sequence blocks; Performing a second division on the second image sequence to obtain a plurality of image sequence blocks; If the sequence number of the image sequence block is 1, the image sequence block and the chaotic sequence block are subjected to a first XOR process to calculate a first encryption block, and the sequence number of the image sequence block is equal to the sequence number of the chaotic sequence block; If the sequence number of the image sequence block is greater than 1, the sum of the image sequence block and the previous encryption block is calculated, and a second XOR process is performed with the chaotic sequence block to calculate the corresponding second encryption block; The first encryption block and a plurality of the second encryption blocks are connected to obtain the third image sequence.
5. The method according to claim 3, characterized in that: The step of decoding the third image sequence according to the eighth chaotic sequence to obtain an encrypted image comprises: Calculating a decoding mode value according to the eighth chaotic sequence; The third image sequence is decoded according to the encoding rule and the decoding mode value to obtain the encrypted image.
6. The method according to claim 1, characterized in that The method further comprises the following steps: Performing a security experimental analysis on the encrypted image; The safety experimental analysis includes: Conduct key security analysis; Alternatively, perform key sensitivity analysis; Alternatively, statistical analysis of pixel values may be performed; Alternatively, adjacent pixel correlation analysis may be performed; Alternatively, conduct differential attack resistance analysis; Alternatively, perform noise attack resistance analysis.
7. An image encryption device, characterized in that: include: The first module is used to obtain a grayscale image; The second module is used to convert the grayscale image according to the image height and the image width to obtain a first image matrix; a third module, for calculating a first chaotic sequence, a second chaotic sequence, a third chaotic sequence, a fourth chaotic sequence, a fifth chaotic sequence, a sixth chaotic sequence, a seventh chaotic sequence, an eighth chaotic sequence and a ninth chaotic sequence according to the first image matrix, wherein the length of the first chaotic sequence, the length of the second chaotic sequence, the length of the third chaotic sequence, the length of the fourth chaotic sequence, the length of the fifth chaotic sequence, the length of the sixth chaotic sequence and the length of the eighth chaotic sequence are all equal, the length of the seventh chaotic sequence is equal to the length of the ninth chaotic sequence, and the length of the first chaotic sequence is less than the length of the seventh chaotic sequence; A fourth module is used to perform a glyph scrambling process on the first image matrix according to the first chaotic sequence to obtain a second image matrix; A fifth module is used to perform bit-level scrambling processing on the second image matrix according to the second chaotic sequence and the third chaotic sequence to obtain a third image matrix; A sixth module is used to perform a first encoding process on the third image matrix according to the fourth chaotic sequence to obtain a first image sequence; A seventh module is used to perform a second coding process on the fifth chaotic sequence according to the fourth chaotic sequence to obtain a first coding sequence; an eighth module, configured to perform diffusion processing on the first image sequence and the first coding sequence according to the seventh chaotic sequence and the ninth chaotic sequence to obtain a second image sequence; A ninth module, configured to perform ciphertext feedback processing on the second image sequence according to the sixth chaotic sequence to obtain a third image sequence; A tenth module is used to decode the third image sequence according to the eighth chaotic sequence to obtain an encrypted image; The step of performing glyph scrambling processing on the first image matrix according to the first chaotic sequence to obtain a second image matrix includes: Calculating a scanning start position value according to the first chaotic sequence; Performing a V-shaped scan on the first image matrix according to the scan start position value, the image height, and the image width to obtain a plurality of scan values; Exchanging the plurality of scan values with a plurality of maximum row pixel values that have not been exchanged in the first image matrix until each row is exchanged, thereby obtaining the second image matrix, wherein the number of the scan values is equal to the number of the maximum row pixel values, and the exchange process is used to exchange the scan values and the maximum row pixel values that are located in the same column; The step of performing bit-level scrambling processing on the second image matrix according to the second chaotic sequence and the third chaotic sequence to obtain a third image matrix includes: Calculating a bit conversion mode value according to the second chaotic sequence; Performing quaternary conversion processing on the third chaotic sequence and the second image matrix; According to the quaternary number scrambling rule and the bit conversion mode value, the third chaotic sequence after the quaternary conversion process is subjected to a first bit conversion to obtain a quaternary chaotic sequence; According to the quaternary number scrambling rule and the bit conversion mode value, performing a second bit conversion on the second image matrix after the quaternary conversion processing to obtain a quaternary image matrix; Performing decimal conversion processing on the quaternary chaotic sequence and the quaternary image matrix; Calculating the pixel arrangement order according to the quaternary chaotic sequence after decimal conversion; Sorting the quaternary image matrix after decimal conversion according to the pixel arrangement order to obtain the third image matrix; The step of performing diffusion processing on the first image sequence and the first coding sequence according to the seventh chaotic sequence and the ninth chaotic sequence to obtain a second image sequence includes: Calculating a sequence change judgment value according to the seventh chaotic sequence; Calculating a diffusion mode value according to the ninth chaotic sequence; The first image sequence and the first coding sequence are diffused according to a diffusion rule, the sequence change judgment value and the diffusion mode value to obtain the second image sequence.
Citation Information
Patent Citations
Image encryption method based on chaotic sequence and DNA coding
CN113225449A
Image encryption method based on block selection Zigzag scrambling and wheel disc rotation coding
CN117579756A