Image encryption method, electronic device and computer program product

By using key sequence algorithm and image transformation diffusion encryption technology in image encryption, the problem of low image encryption security in the prior art is solved, and higher image encryption security and data protection effects are achieved.

CN119893000APending Publication Date: 2025-04-25GUANGZHOU HUADA PETROCHEMICAL CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411933598.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

The existing image encryption algorithm is relatively low in security, and there is a greater risk of leakage of face images after key leakage.

Method used

By inputting the image to be encrypted into the key sequence algorithm, the corresponding key sequence is determined, and image transformation and diffusion encryption is performed on the image based on the key sequence to generate a target encrypted image.

Benefits of technology

Improve the security of encrypted images, enhance the difficulty of cracking images through dynamically changing key sequences, and reduce the risk of data leakage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119893000A_ABST
    Figure CN119893000A_ABST
Patent Text Reader

Abstract

The embodiment of the invention is suitable for the technical field of computers, and provides an image encryption method, electronic equipment and a computer program product, and the method comprises the steps: inputting a to-be-encrypted image into a key sequence algorithm, and determining a key sequence corresponding to the to-be-encrypted image; the key sequence algorithm is used for converting binary data corresponding to the to-be-encrypted image into the key sequence; performing image transformation on the to-be-encrypted image based on the key sequence, and determining a transformed image corresponding to the to-be-encrypted image; and performing diffusion encryption on the pixel value of the transformed image based on the key sequence to generate a target encrypted image. According to the method provided by the embodiment of the invention, the key sequence is determined according to the binary data of the image to be encrypted, namely, the key sequence is dynamic and non-fixed, so that the method provided by the embodiment of the invention can improve the security of the encrypted image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application belong to the field of computer technology, and in particular, relate to an image encryption method, an electronic device, and a computer program product. Background Art

[0002] In order to improve the management efficiency and safety of factories, the application scenarios of face recognition technology in factories are gradually increasing. In order to facilitate equipment installation and reduce equipment costs, the face recognition equipment deployed in factories generally only has the collection function, and the face verification function needs to be transmitted to the central control device or server for implementation. When the face recognition device encapsulates the face image, it generally encrypts the face image with a preset key. Therefore, once the key is leaked, the face image is at a greater risk of leakage. It can be seen that the existing image encryption algorithm has low security. Summary of the invention

[0003] In view of this, embodiments of the present application provide an image encryption method, an electronic device, and a computer program product to improve the security of encrypted images.

[0004] A first aspect of an embodiment of the present application provides an image encryption method, comprising:

[0005] Inputting the image to be encrypted into a key sequence algorithm to determine the key sequence corresponding to the image to be encrypted; the key sequence algorithm is used to convert the binary data corresponding to the image to be encrypted into the key sequence;

[0006] Performing image transformation on the image to be encrypted based on the key sequence to determine a transformed image corresponding to the image to be encrypted;

[0007] The pixel values ​​of the transformed image are diffusely encrypted based on the key sequence to generate a target encrypted image.

[0008] In a possible implementation manner of the first aspect, the key sequence includes a first key sequence and a second key sequence;

[0009] The performing image transformation on the image to be encrypted based on the key sequence to determine a transformed image corresponding to the image to be encrypted includes:

[0010] Based on the first key sequence, the channel matrix corresponding to each channel of the image to be encrypted is disturbed to generate a disturbed image; the channel matrix is ​​generated based on the grayscale value of each first pixel on the corresponding channel of the image to be encrypted; the first pixel is a pixel on the image to be encrypted;

[0011] The disturbed image is subjected to image diffusion based on the second key sequence to generate the transformed image.

[0012] In a possible implementation manner of the first aspect, performing image scrambling on a channel matrix corresponding to each channel of the image to be encrypted based on the first key sequence to generate a scrambled image includes:

[0013] Perform matrix splicing based on the channel matrices corresponding to the channels in the image to be encrypted to obtain a color matrix corresponding to the image to be encrypted;

[0014] Inputting the first key sequence into a preset index sequence algorithm to generate a row index sequence and a column index sequence corresponding to the first key sequence;

[0015] The color matrix is ​​permuted based on the row index sequence and the column index sequence to generate the disturbed image.

[0016] In a possible implementation manner of the first aspect, the performing image diffusion on the disturbed image based on the second key sequence to generate the transformed image includes:

[0017] Inputting the second key sequence into the first matrix construction algorithm to generate a diffusion matrix corresponding to the second key sequence;

[0018] Inputting the pixel value corresponding to each second pixel in the disturbed image into a second matrix construction algorithm to generate a transformation matrix corresponding to the disturbed image; the second pixel is a pixel in the disturbed image;

[0019] The diffusion matrix and the transformation matrix are input into a preset diffusion function to generate the transformation image.

[0020] In a possible implementation manner of the first aspect, the first matrix construction algorithm includes a reconstruction algorithm and a Fibonacci algorithm;

[0021] The step of inputting the second key sequence into the first matrix construction algorithm to generate a diffusion matrix corresponding to the second key sequence includes:

[0022] Inputting the second key sequence and the second image size of the scrambled image into the reconstruction algorithm to generate a chaotic matrix; the reconstruction algorithm is used to reconstruct the second key sequence into the chaotic matrix whose matrix size is consistent with the second image size according to the second image size;

[0023] The chaotic matrix is ​​input into the Fibonacci algorithm to generate the diffusion matrix.

[0024] In a possible implementation manner of the first aspect, the reconstruction algorithm is as follows:

[0025] FN′=reshape((100×S2(1:H2×W2)),W2,H2)

[0026] FN = round(mod(FN′,17)+3)

[0027] Among them, FN is the chaotic matrix; round is the rounding function; mod is the modular operation function; FN′ is the first intermediate matrix; H2 is the height value in the second image size; W2 is the width value in the second image size; S2 is the second key sequence; reshape(A,p,q) is a dimensionality transformation function, which is used to construct A into a matrix with p rows and q columns.

[0028] In a possible implementation manner of the first aspect, inputting the image to be encrypted into a key sequence algorithm to determine the key sequence corresponding to the image to be encrypted includes:

[0029] Inputting the binary data of the image to be encrypted into a preset hash function to determine the hash value corresponding to the image to be encrypted;

[0030] Inputting the Hash value into a key function to generate a key parameter corresponding to the Hash value;

[0031] Inputting the key parameter into a first chaotic sequence function to determine a first key sequence corresponding to the image to be encrypted;

[0032] The key parameter is input into a second chaotic sequence function to determine a second key sequence corresponding to the image to be encrypted.

[0033] In a possible implementation manner of the first aspect, the first chaotic sequence function is as follows:

[0034] S1=((2D_LSCM(a+0.1,b+0.1,c,3×H1×W1))×10000)mod255

[0035] Wherein, S1 is the first key sequence; 2D_LSCM is a two-dimensional discrete chaotic function; a is a first key parameter; b is a second key parameter; c is a third key parameter; H1 is a height value in the first image size corresponding to the image to be encrypted; W1 is a width value in the first image size corresponding to the image to be encrypted; mod is a modulus operation function;

[0036] Correspondingly, the second chaotic sequence function is as follows:

[0037] S2=((2D_LSCM(a+0.2,b+0.2,c,3×H1×W1))×10000)mod255

[0038] Among them, S2 is the second key sequence.

[0039] A second aspect of an embodiment of the present application provides an image encryption device, comprising:

[0040] A key determination module, used to input the image to be encrypted into a key sequence algorithm to determine the key sequence corresponding to the image to be encrypted; the key sequence algorithm is used to determine the key sequence according to the binary data corresponding to the image to be encrypted;

[0041] An image transformation module, used to perform image transformation on the image to be encrypted based on the key sequence, and determine a transformed image corresponding to the image to be encrypted;

[0042] The diffusion encryption module is used to perform diffusion encryption on the pixel values ​​of the transformed image based on the key sequence to generate a target encrypted image.

[0043] A third aspect of an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the image encryption method as described in the first aspect above is implemented.

[0044] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the image encryption method as described in the first aspect above is implemented.

[0045] A fifth aspect of the embodiments of the present application provides a computer program product. When the computer program product is run on a computer, the computer executes the image encryption method described in the first aspect.

[0046] Compared with the prior art, the embodiments of the present application have the following advantages:

[0047] In an embodiment of the present application, the electronic device can input the image to be encrypted into the key sequence algorithm to determine the key sequence corresponding to the image to be encrypted through the key sequence algorithm; wherein the key sequence algorithm can be used to convert the binary data of the image to be encrypted into the key sequence corresponding to the image to be encrypted; then, the electronic device can perform image transformation on the image to be encrypted according to the key sequence to determine the transformed image corresponding to the image to be encrypted; the electronic device can diffusely encrypt the pixel values ​​of the transformed image through the key sequence to generate a target encrypted image. Through the method provided in this embodiment, since the electronic device can determine the key sequence of the image to be encrypted according to the binary data of the image to be encrypted, that is, different images to be encrypted have different key sequences used in the encryption process, therefore, the key sequence in the embodiment of the present application is dynamically changing, which can improve the encryption security of the image. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or prior art descriptions. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0049] Figure 1 is a schematic diagram of an image encryption method provided in an embodiment of the present application;

[0050] Figure 2 is a schematic diagram of a color matrix provided in an embodiment of the present application;

[0051] Figure 3 It is a schematic diagram of a calculation process of a confusion function provided in an embodiment of the present application;

[0052] Figure 4 is a schematic diagram of another image encryption method provided in an embodiment of the present application;

[0053] Figure 5 is a schematic diagram of an image encryption device provided in an embodiment of the present application;

[0054] Figure 6 It is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0055] In the following description, specific details such as specific system structures, technologies, etc. are proposed for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from hindering the description of the present application.

[0056] In order to deal with the information security issues caused by data leakage, the embodiment of the present application provides an image encryption scheme to improve the information security during image transmission. Among them, the method provided by the embodiment of the present application can be applied to the field of image transmission with private information, such as in the face recognition system of a factory, to reduce the probability of data leakage when the face image is transmitted to the central control device or server.

[0057] In order to improve the management efficiency and safety of factories, the application of face recognition technology in factories is also increasing. For example, in terms of security management, face recognition technology can be used in scenarios where employee identity verification is required, such as entering a specific area, operating key equipment, etc. By quickly confirming the identity of employees through face recognition technology, it can be ensured that only employees with corresponding permissions can enter specific areas or operate key equipment, thereby ensuring the safety and production order of the factory. In order to ensure the miniaturization of face recognition devices installed in specific areas and / or operating key equipment, face recognition devices usually need to hand over the processing tasks of face recognition to other devices. After collecting facial images, the face recognition device can transmit the collected facial images to the central control device or server, and compare the facial images with the user data stored in the database through the central control device or server to obtain the permission information corresponding to the facial image. However, facial images are vulnerable to network attacks during data transmission, resulting in data leakage.

[0058] In view of this, the embodiment of the present application proposes an image encryption method that can be applied to a face recognition system in a factory. The technical solution of the present application is described below through specific embodiments.

[0059] Reference Figure 1 , shows a schematic diagram of an image encryption method provided by an embodiment of the present application. The method can be applied to face recognition devices in factories and various distributed terminals in factories, such as an operating device with a camera in a factory. The above-mentioned image encryption method can specifically include the following steps:

[0060] S101, inputting the image to be encrypted into a key sequence algorithm to determine the key sequence corresponding to the image to be encrypted.

[0061] In this embodiment, an infrared sensor may be installed on the electronic device, and the infrared sensor may be used to continuously detect whether a person is approaching. After detecting that a person is approaching, the electronic device may turn on the camera to collect the original image. After collecting the original image, the electronic device may input the original image into a preset face detection algorithm to extract the image of the area where the face is located from the original image as the image to be encrypted. After acquiring the image to be encrypted, the electronic device may input the image to be encrypted into a key sequence algorithm to determine the key sequence corresponding to the image to be encrypted. Among them, the key sequence algorithm can be used to determine the key sequence corresponding to the image to be encrypted based on the binary data corresponding to the image to be encrypted.

[0062] In a possible implementation, the face detection algorithm may include a filtering algorithm, a boundary extraction algorithm, and a corrosion and expansion algorithm. The face detection algorithm used in the electronic device to extract the image to be encrypted may be specifically as follows. After acquiring the original image, the electronic device may first input the original image into the filtering algorithm to filter the image to reduce the details in the original image. Specifically, the filtering algorithm in the face detection algorithm may be a mean filtering algorithm. Then, in order to reduce the amount of calculation in the face detection process, the electronic device may perform a binarization operation on the filtered original image to generate a binarized image. Specifically, when the filtered original image is a grayscale image, the electronic device may convert the pixel value of each pixel in the filtered original image to 0 or 1. Among them, when the pixel value of a pixel in the grayscale image is greater than or equal to the grayscale threshold, the electronic device converts the pixel value of the pixel to 1; when the pixel value of a pixel in the grayscale image is less than the grayscale threshold, the electronic device converts the pixel value of the pixel to 0. When the filtered original image is a color image, the electronic device may convert the color image into a grayscale image, and then perform a binarization operation according to the processing method corresponding to the grayscale image.

[0063] After generating a binary image, the electronic device can input the binary image into a preset boundary extraction algorithm to determine the initial boundaries of each object in the binary image through the boundary extraction algorithm. Specifically, the boundary extraction algorithm can extract the initial boundaries corresponding to each object in the binary image whose contour is similar to the graphic template according to the graphic template pre-set by the R&D personnel. Then, the electronic device can input each initial boundary in the binary image into the erosion and expansion algorithm to optimize the initial boundaries corresponding to each object through the erosion and expansion algorithm to generate the object boundary corresponding to the object.

[0064] Specifically, because the face, neck, hair, and clothing of a person are all distributed vertically, the boundary extraction algorithm easily separates the adjacent parts of these vertical distributions, so that the face area is divided into multiple object boundaries. Therefore, in the erosion and expansion algorithm, the electronic device can first perform a vertical closing operation on the vertical strip-shaped structural elements in each initial boundary to reconnect the upper and lower areas of the face. Further, since there are usually a large number of connected domains in the part below the face area in the original image, this may interfere with the electronic device's recognition of the largest connected domain, thereby affecting the face detection result of the electronic device. Considering that the part below the face area is usually distributed vertically, in the erosion and expansion algorithm, the electronic device can also perform a horizontal erosion operation on the horizontal strip-shaped structural elements in each initial boundary to further refine each initial boundary and determine the object boundary corresponding to each object. After determining the object boundary corresponding to each object, the electronic device can identify the area within each object boundary as the connected domain corresponding to each object. Then, the electronic device can identify the connected domain with the largest size and the size that meets the preset size condition as the area where the face is located, and identify the area at the same position in the original image as the image to be encrypted.

[0065] Through the method provided in this embodiment, since the electronic device can extract the image of the area where the face is located as the image to be encrypted through the face detection algorithm, the method provided in this embodiment can make the electronic device not need to encrypt the original image as a whole, but only encrypt the image of the area where the face is located in the original image, thereby avoiding the electronic device from processing irrelevant information, reducing the consumption of computing resources, and thus improving the image encryption efficiency of the electronic device.

[0066] In a possible implementation, after acquiring the image to be encrypted, the electronic device may input the binary data of the image to be encrypted and the preset length value into the hash function preset by the developer, so as to determine the hash value corresponding to the image to be encrypted through the hash function. Among them, the above-mentioned length value can be used to limit the byte length of the generated hash value. Specifically, the electronic device may input the image to be encrypted into the cryptographic hash function (Secure Hash Algorithm 256-bit, SHA-256) to generate the hash value corresponding to the image to be encrypted through the cryptographic hash function. Exemplarily, the developer may set the length value to 64 bits, and after the electronic device inputs the binary data of the image to be encrypted into the cryptographic hash function, the cryptographic hash function may output the 64-bit hash value corresponding to the image to be encrypted. Since the hash value calculated by the cryptographic hash function is usually a hexadecimal number, in order to facilitate calculation, the electronic device may convert each digit in the hash value into a decimal number. After the electronic device performs base conversion on the hash value, the base converted hash value may be input into the key function preset by the developer, so as to generate the key parameter corresponding to the hash value through the key function. The key function may be specifically as follows.

[0067]

[0068] Wherein, a can be the first key parameter, b can be the second key parameter, c can be the third key parameter, d can be the fourth key parameter, mod can be the modulus operation function. i The i-th digit in the 64-bit hash value corresponding to the image to be encrypted can be represented by the key function, wherein the value range of i in the key function can be [0, 64]. For example, each decimal digit in the 64-bit hash value corresponding to the image to be encrypted can be represented by Hash1, Hash2, Hash3, ..., Hash 64 Hash1 may represent the first digit in the 64-bit hash value corresponding to the image to be encrypted.

[0069] After the electronic device determines the key parameters through the key function, the key parameters can be input into the preset chaotic sequence function to determine the key sequence corresponding to the image to be encrypted through the chaotic sequence function. Specifically, since the steps of the electronic device encrypting the image to be encrypted can include three steps of image disturbance, image diffusion and diffusion encryption, the electronic device can implement the above steps through different chaotic sequence functions, for example, image disturbance is implemented through the first chaotic sequence function, image diffusion is implemented through the second chaotic sequence function, and diffusion encryption is implemented through the chaotic matrix function. Specifically, the electronic device can input the key parameters into the first chaotic sequence function, the second chaotic sequence function and the chaotic matrix function to respectively determine the first key sequence, the second key sequence, the first key matrix and the second key matrix.

[0070] Among them, the first key sequence can be a key sequence for image scrambling. The second key sequence can be a key sequence for image diffusion. The first key matrix and the second key matrix can be key matrices for diffusion encryption. Correspondingly, the first chaotic sequence function can be a function for calculating the key for image scrambling of the encrypted image. The second chaotic sequence function can be a function for calculating the key for image diffusion of the encrypted image. The chaotic matrix function can be a function for calculating the key for diffusion encryption of the encrypted image. Specifically, the first chaotic sequence function and the second chaotic sequence function can be functions constructed based on a two-dimensional discrete chaotic system. The chaotic matrix function can be a function constructed based on a four-dimensional autonomous chaotic system. Among them, the first chaotic sequence function can be specifically as follows.

[0071] S1=((2D_LSCM(a+0.1,b+0.1,c,3×H1×W1))×10000)mod255

[0072] Wherein, S1 may be a first key sequence. 2D_LSCM is a two-dimensional discrete chaotic function. a may be a first key parameter. b may be a second key parameter. c may be a third key parameter. H1 may be a height value in the first image size corresponding to the image to be encrypted. W1 may be a width value in the first image size corresponding to the image to be encrypted; and mod may be a modulus operation function.

[0073] The second chaotic sequence function can be specifically shown as follows.

[0074] S2=((2D_LSCM(a+0.2,b+0.2,c,3×H1×W1))×10000)mod255

[0075] Among them, S2 can be the second key sequence.

[0076] The chaos matrix function can be specifically shown as follows.

[0077] x1=a(x2-x1)+λ1x4

[0078] x2=bx1-x1x3+λ2x4

[0079] x3=-cx3+x1x2+λ3x4

[0080] x4=-dx1

[0081] A1=[x1,x2]

[0082] A2=[x3,x4]

[0083] Wherein, x1 may be a first encryption matrix. x2 may be a second encryption matrix. x3 may be a third encryption matrix. x4 may be a fourth encryption matrix. [x1,x2] may indicate that the first encryption matrix and the second encryption matrix are connected head to tail. [x3,x4] may indicate that the third encryption matrix and the fourth encryption matrix are connected head to tail. A1 may be a first key matrix. A2 may be a second key matrix. λ1 may indicate a first chaotic parameter. λ2 may indicate a second chaotic parameter. λ3 may indicate a third chaotic parameter. d may indicate a fourth key parameter.

[0084] Cryptographic hash function is a key function in the field of cryptography and information security. Cryptographic hash function has the ability to convert binary data of arbitrary length into a hash value of fixed length to ensure the integrity and security of binary data. Cryptographic hash function algorithms play an important role in fields such as data integrity verification, cryptographic security, and digital signatures. Therefore, compared with the prior art that uses a single hash value as a key, the method provided in the embodiment of the present application generates a key sequence corresponding to the image to be encrypted through a cryptographic hash function. Therefore, compared with the prior art that uses a single hash value as a key, the method provided in this embodiment significantly improves the security of the image encryption algorithm.

[0085] In addition, in this embodiment, after determining the key parameters, the electronic device can determine multiple different key sequences based on a variety of different chaotic functions, and apply each key sequence to different encryption steps, that is, in different encryption steps, the electronic device uses different key sequences to encrypt the image. Therefore, the method provided in this embodiment can increase the difficulty of cracking the target encrypted image, thereby improving the security of the target encrypted image.

[0086] S102: Perform image transformation on the image to be encrypted based on the key sequence to determine a transformed image corresponding to the image to be encrypted.

[0087] In this embodiment, after determining the key sequence, the electronic device may perform image transformation on the image to be encrypted according to the determined key sequence to determine the transformed image corresponding to the image to be encrypted. Among them, the operation of the electronic device to perform image transformation on the image to be encrypted may include image disturbance operation and image diffusion operation. Therefore, after the electronic device calculates the key parameter corresponding to the image to be encrypted according to the hash value of the image to be encrypted, the key parameter may be input into the first chaotic sequence function and the second chaotic sequence function respectively to determine the first key sequence and the second key sequence corresponding to the image to be encrypted. The electronic device may perform image disturbance on the image to be encrypted based on the first key sequence, and perform image diffusion on the image to be encrypted according to the second key sequence to generate a transformed image. Exemplarily, the electronic device may first perform image disturbance on the image to be encrypted based on the first key sequence to generate a disturbed image, and then perform image diffusion on the disturbed image according to the second key sequence to generate a transformed image.

[0088] S103: Perform diffusion encryption on the pixel values ​​of the transformed image based on the key sequence to generate a target encrypted image.

[0089] In this embodiment, after generating the transformed image, the electronic device can also diffuse and encrypt the pixel values ​​of the transformed image according to the key sequence to generate a target encrypted image. After generating the target encrypted image, the electronic device can transmit the generated target encrypted image to the server or the central control device through a preset image transmission channel, and transmit the key parameters corresponding to the target encrypted image to the server or the central control device through the encryption channel. The electronic device can transmit the target encrypted image and the key parameters respectively through different data packets to improve the information security of the target encrypted image. The server or the central control device can perform an inverse operation on the target encrypted image according to the key parameters to obtain the image to be encrypted, and perform face verification according to the decrypted image to be encrypted. Specifically, after receiving the target encrypted image and the key parameters, the server or the central control device can first calculate the key sequence corresponding to the target encrypted image according to the key parameters and the key sequence function, and then decrypt the target encryption according to the key sequence and the inverse operation method corresponding to the encryption method provided in the embodiment of the present application to determine the image to be encrypted corresponding to the target encrypted image.

[0090] Through the method provided in this embodiment, since the electronic device can transform the image to be encrypted according to the key sequence after determining the key sequence, and diffusely encrypt the transformed image according to the key sequence, the method provided in this embodiment enables the electronic device to encrypt the image to be encrypted by multiple methods at the same time, thereby improving the encryption security of the image data. In addition, although in the method provided in this embodiment, the electronic device needs to transmit the key parameters corresponding to the target encrypted image to the server or the central control device, since the key parameters and the target encrypted image are transmitted through different data packets, the attacker cannot determine the corresponding relationship between the key parameters and the target encrypted image, and the attacker cannot directly decrypt the target encrypted image according to the key parameters. Therefore, the method provided in this embodiment can still improve the confidentiality of the encrypted image.

[0091] In a possible implementation, the electronic device can determine the first key matrix and the second key matrix corresponding to the image to be encrypted through a chaotic matrix function, and diffusely encrypt the pixel values ​​of the transformed image through the first key matrix and the second key matrix to generate a target encrypted image. Specifically, after the electronic device determines the transformed image corresponding to the image to be encrypted through the first key sequence and the second key sequence, it can obtain the grayscale values ​​corresponding to each third pixel in the transformed image on each channel. The electronic device can generate a channel matrix of the transformed image on a certain channel according to the grayscale values ​​corresponding to all pixels in the transformed image on a certain channel. Among them, the element at a certain position in the channel matrix can be the first pixel at that position of the image to be encrypted, and its grayscale value on the channel corresponding to the channel matrix. Specifically, when the image to be encrypted is a color image, the electronic device can respectively obtain the first channel matrix on the red channel, the second channel matrix on the green channel, and the third channel matrix on the blue channel of the image to be encrypted. Among them, the element at a certain position in the first channel matrix can be the first pixel at that position of the image to be encrypted, and its grayscale value on the red channel; the element at a certain position in the second channel matrix can be the first pixel at that position of the image to be encrypted, and its grayscale value on the green channel; the element at a certain position in the third channel matrix can be the first pixel at that position of the image to be encrypted, and its grayscale value on the blue channel.

[0092] Then, the electronic device can perform matrix splicing according to the channel matrices corresponding to the transformed image on each channel to obtain the color matrix corresponding to the transformed image. Figure 2 , shows a schematic diagram of a color matrix provided by an embodiment of the present application. Figure 2As shown, when performing matrix splicing, the electronic device can stack the first channel matrix, the second channel matrix and the third channel matrix in sequence to generate a color matrix. Among them, the first channel matrix can be located at the top of the color matrix, the second channel matrix can be located in the middle of the color matrix, and the third channel matrix can be located at the bottom of the color matrix. The electronic device can input each element value in the color matrix of the transformed image and the element value at the same position in the first key matrix into the block diffusion function one by one to determine the color matrix corresponding to the diffusion image, and determine the diffusion image according to the calculated color matrix. Among them, the third pixel is a pixel in the transformed image.

[0093] The block diffusion function can be specifically shown as follows.

[0094]

[0095] in, It can represent the element value of the i-th row and j-th column of the k-th channel matrix in the color matrix corresponding to the diffusion image. The color matrix corresponding to the diffusion image can be formed by splicing the first channel matrix of the diffusion image on the red channel, the second channel matrix on the green channel, and the third channel matrix on the blue channel. It can represent the element value of the i-th row and j-th column in the first key matrix. It can represent the element value of the i-th row and j-th column of the k-th channel matrix in the color matrix corresponding to the transformed image. Similarly, the color matrix corresponding to the transformed image can be formed by concatenating the first channel matrix of the transformed image on the red channel, the second channel matrix on the green channel, and the third channel matrix on the blue channel. It can represent the element value of the Wth row and the Hth column of the k-1th channel matrix in the color matrix corresponding to the diffusion image. For example, The W in can be the width value of the diffuse image corresponding to the fourth image size, The H in may be a height value of the diffusion image corresponding to the fourth image size. It can represent the element value of the Wth row and the Hth column of the third channel matrix in the color matrix corresponding to the transformed image. Exemplarily, The W in can be the width value of the transformed image corresponding to the third image size, The H in can be the height value of the transformed image corresponding to the third image size.

[0096] After the electronic device generates the diffusion image according to the first key matrix, the pixel value corresponding to each fourth pixel in the diffusion image and the second key matrix can be input into the obfuscation function to obfuscate each pixel of the transformed image through the obfuscation function to generate a target encrypted image. The fourth pixel is a pixel in the diffusion image. Specifically, the obfuscation function can be as follows.

[0097] I(i,ci)=(C3(i,ci)+A2(i,ci-1))mod 256,i∈[1,W4],ci∈[1,H4]

[0098] I(ri,i)=(C3(ri,i)+A2(ri-1,i))mod 256,i∈[1,W4],ci∈[1,H4]

[0099] C=(I+A2)mod 256

[0100] Among them, I can represent the matrix composed of the pixel values ​​of each pixel in the intermediate encrypted image. C can represent the matrix composed of the pixel values ​​of each pixel in the target encrypted image. C3 can represent the matrix composed of the pixel values ​​of each pixel in the diffusion image. A2 can represent the second chaotic matrix. I(i,ci) can represent the element value of the i-th row and ci-th column in the matrix I. I(ri,i) can represent the element value of the ri-th row and i-th column in the matrix I. C3(i,ci) can represent the element value of the i-th row and ci-th column in the matrix C3. C3(ri,i) can represent the element value of the ri-th row and i-th column in the matrix C3. A2(ri-1,i) can represent the element value of the ri-th row and i-th column in the matrix A2. A2(i,ci-1) can represent the element value of the i-th row and ci-th column in the matrix A2. W4 can represent the width value of the diffusion image corresponding to the fourth image size. H4 can be the height value of the diffusion image corresponding to the fourth image size.

[0101] See also Figure 3 , shows a schematic diagram of a calculation process of a confusion function provided in an embodiment of the present application. Among them, Figure 3 Each small grid in can represent a pixel of the diffusion image. Figure 3 As shown, the obfuscation function can divide the diffused image into pixel groups 211 to 217 according to the diagonal lines of the image, each pixel group includes a row direction and a column direction, and obfuscates and encrypts the pixels in the row direction and the column direction in the pixel group respectively, for example, obfuscates and encrypts the pixel group 211 in the row direction and the column direction respectively. Therefore, the method provided in this embodiment enables the electronic device to obfuscate and encrypt the pixel values ​​of the image from both the row and column directions, thereby improving the sufficiency and parallelism of obfuscating and encrypting the pixel values, and further improving the security of the target encrypted image generated by the electronic device.

[0102] Figure 4 FIG. 1 shows a specific implementation flow chart of an image encryption method S102 provided in the second embodiment of the present application. Figure 4 , compared to Figure 1In the embodiment, in an image encryption method provided in this embodiment, S102 includes: S1021-S1022, which are described in detail as follows:

[0103] S1021. Perform image disturbance on the channel matrix corresponding to each channel of the image to be encrypted based on the first key sequence to generate a disturbed image.

[0104] In this embodiment, after determining the key parameters corresponding to the image to be encrypted, the electronic device can input the key parameters into the first chaotic sequence function to determine the first key sequence corresponding to the image to be encrypted. Then, the electronic device can perform image perturbation on the channel matrix corresponding to each channel of the image to be encrypted according to the first key sequence to generate a perturbed image. The channel matrix is ​​generated by the electronic device based on the grayscale value of each first pixel on the corresponding channel of the image to be encrypted. The first pixel is a pixel on the image to be encrypted.

[0105] Among them, the method for the electronic device to determine the channel matrix of the image to be encrypted on each channel is similar to the method for determining the channel matrix of the transformed image on each channel in the first embodiment of the present application. The reader can refer to the method in the embodiment of the present application for understanding. Exemplarily, when the first image size of the image to be encrypted is W1×H1, that is, the width value of the image to be encrypted is W1 and the height value is H1, the matrix size corresponding to each channel matrix can also be W1×H1, that is, the number of rows of each channel matrix is ​​W1 and the number of columns is H1. Since the channel matrix of the image to be encrypted on each channel is usually represented in decimal, in order to facilitate calculation, the electronic device can also perform base conversion on the decimal channel matrix to generate the binary channel matrix corresponding to each channel in the image to be encrypted. Among them, when the matrix size of the channel matrix on a certain channel is W1×H1 in decimal, after the electronic device converts it into binary, its matrix size can be W1×8H1.

[0106] Then, the electronic device can perform matrix splicing on the channel matrices corresponding to each channel in the image to be encrypted to obtain the color matrix corresponding to the image to be encrypted. Specifically, the electronic device can use the first channel matrix of the image to be encrypted on the red channel as the top part of the color matrix, the second channel matrix on the green channel as the middle part of the color matrix, and the third channel matrix on the blue channel as the bottom part of the color matrix.

[0107] After determining the color matrix corresponding to the image to be encrypted, the electronic device may input the first key sequence into the index sequence algorithm to generate a row index sequence and a column index sequence corresponding to the first key sequence. Specifically, the index sequence algorithm may map each key value in the first key sequence to the range of rows corresponding to the image to be encrypted to generate a row index sequence corresponding to the first key sequence; the index sequence algorithm may also map each key value in the first key sequence to the range of rows corresponding to the image to be encrypted to generate a column index sequence corresponding to the first key sequence.

[0108] Specifically, the index sequence algorithm may include a first mapping function and a second mapping function. When the width value in the first image size of the image to be encrypted is W1 and the height value is H1, the electronic device may input each key value in the first key sequence into the first mapping function respectively, so as to convert each key value in the first key sequence into an integer range of [0, W1-1] through the first mapping function, and generate a row index sequence corresponding to the first key sequence; the electronic device may input each key value in the first key sequence into the second mapping function respectively, so as to convert each key value in the first key sequence into an integer range of [0, H1-1] through the second mapping function, and generate a column index sequence corresponding to the first key sequence. The first mapping function is specifically as follows.

[0109] rowK i =[s i ×W1]modW1

[0110] Among them, rowK i Can be used to represent the i-th row index value in a row index sequence. i It can be used to represent the i-th key value in the first key sequence. W1 can be used to represent the width value in the first image size.

[0111] The second mapping function is specifically as follows.

[0112] colK i =[s i ×H1]modH1

[0113] Among them, colK i It can be used to represent the i-th column index value in the column index sequence. H1 can be used to represent the height value in the first image size.

[0114] After determining the row index sequence and the column index sequence, the electronic device can perform matrix permutation on the color matrix through the row index sequence and the column index sequence to generate a scrambled image. Specifically, the electronic device can generate a permutation matrix consistent with the matrix size of the color matrix according to the row index sequence and the column index sequence. Then, for each first element in the color matrix, the electronic device can obtain the second element at the same position in the permutation matrix, and input the first element and the second element into a preset permutation function respectively to determine the pixel value corresponding to each second pixel in the scrambled image, and generate a scrambled image.

[0115] Image perturbation is a commonly used encryption technology, which conforms to the principles of confusion and diffusion in Shannon's cryptography theory. Therefore, adding image perturbation to the image encryption algorithm can enhance the security performance of the image encryption algorithm. In the prior art, there are two main methods of image perturbation: pixel-level perturbation and bit-level perturbation. Among them, pixel-level perturbation only changes the pixel position of the image, and does not change the gray value of the pixel. Therefore, the statistical histogram of the image after pixel-level perturbation is consistent with the image before perturbation. This makes the image after pixel-level perturbation vulnerable to statistical analysis attacks. Bit-level perturbation not only changes the pixel position of the image, but also changes the gray value of the pixel, so the security of bit-level perturbation is higher. However, the existing bit-level perturbation has a large amount of calculation and a relatively low computational efficiency. The image perturbation method provided in the embodiment of the present application not only changes the pixel position of the image, but also changes the gray value of the pixel, that is, the image perturbation method provided in the embodiment of the present application belongs to bit-level perturbation, has high security, and compared with the existing bit-level perturbation method, the method provided in this embodiment has a smaller amount of calculation and a lower computational efficiency.

[0116] S1022: Perform image diffusion on the disturbed image based on the second key sequence to generate a transformed image.

[0117] In this embodiment, some researchers point out that encrypting images by image scrambling is unsafe because they are vulnerable to attacks by chosen plaintext or known plaintext, and the attack complexity of encryption algorithms involving only scrambling operations depends on the number of keys and is proportional to the square of the number of required keys. In view of this, after generating a scrambled image, the electronic device can perform image diffusion on the scrambled image according to a second key sequence corresponding to the second chaotic sequence function to generate a transformed image.

[0118] In a possible implementation, after determining the second key sequence, the electronic device may first input the second key sequence into the first matrix construction algorithm to generate a diffusion matrix corresponding to the second key sequence. The matrix size of the diffusion matrix may be consistent with the second image size of the disturbed image. The electronic device may also input the pixel values ​​corresponding to each second pixel in the disturbed image into the second matrix construction algorithm to generate a transformation matrix corresponding to the disturbed image. The second pixel is a pixel in the disturbed image, and the matrix size of the transformation matrix may be consistent with the second image size of the disturbed image. The second matrix construction algorithm may be specifically as follows.

[0119]

[0120] Among them, C x may represent the transformation matrix corresponding to the disturbed image. C1(i,j) may represent the pixel value corresponding to the pixel in the i-th row and j-th column of the disturbed image. W2 may represent the width value of the disturbed image in the second image size. H2 may represent the height value of the disturbed image in the second image size.

[0121] After determining the diffusion matrix corresponding to the second key sequence and the transformation matrix corresponding to the scrambled image, the electronic device can input the diffusion matrix and the transformation matrix into a preset diffusion function to generate a transformation image. The diffusion function can be specifically as follows. The electronic device can input the second key sequence and the second image size corresponding to the scrambled image into a reconstruction algorithm to generate a chaotic matrix. The second image size corresponding to the scrambled image can include a height value and a width value corresponding to the scrambled image. Specifically, the height value corresponding to the scrambled image can be used to represent the number of second pixels contained in each column of the scrambled image; the width value corresponding to the scrambled image can be used to represent the number of second pixels contained in each row of the scrambled image.

[0122] In a possible implementation, the first matrix construction algorithm may include a reconstruction algorithm and a Fibonacci algorithm. The specific method by which the electronic device generates a diffusion matrix corresponding to the second key sequence through the first matrix construction algorithm may be described as follows. The electronic device may first input the second key sequence and the second image size corresponding to the disturbed image into the reconstruction algorithm to generate a chaotic matrix through the reconstruction algorithm. Among them, the second image size corresponding to the disturbed image may include a height value and a width value corresponding to the disturbed image. The reconstruction algorithm may be used to reconstruct the second key sequence into a chaotic matrix whose matrix size is consistent with the second image size according to the second image size. Then, the electronic device may input the chaotic matrix into the Fibonacci algorithm to generate a diffusion matrix corresponding to the second key sequence.

[0123] The reconstruction algorithm may be specifically as follows.

[0124] x=reshape((100×S2(1:W2×H2)),[W2,H2])

[0125] FN = round(mod(x,17)+3)

[0126] Wherein, FN may represent a chaotic matrix. x may represent a second intermediate matrix. reshape may represent a reconstruction function for rearranging the dimensions of an array or matrix and converting it into a new structure with a different number of rows and columns (or a different shape in a higher dimension). S2 may represent a second key sequence. W2 may represent a width value in a second image size. H2 may represent a height value in a second image size. round may represent a rounding function for converting a floating point number or a value with a decimal part to the nearest integer.

[0127] The Fibonacci algorithm can be specifically described as follows.

[0128]

[0129] Among them, S n may represent a diffusion matrix corresponding to the second key sequence. FN(i,j) may represent an element value of the i-th row and j-th column of the chaotic matrix. F(n) may represent a Fibonacci function. W2 may represent a width value in the second image size. H2 may represent a height value in the second image size.

[0130] After determining the diffusion matrix and the transformation matrix, the electronic device may input the diffusion matrix and the transformation matrix into a preset diffusion function to generate a transformation image. The diffusion function may be specifically as follows.

[0131] fz=S n ×C x

[0132]

[0133] C2=mod(C′,256)

[0134] Wherein, C2 may represent a matrix composed of pixel values ​​of each third pixel in the transformed image. C′ may be a third intermediate matrix. fz may be a fourth intermediate matrix. S n It can be the diffusion matrix corresponding to the second key sequence. xIt can be the transformation matrix corresponding to the disturbed image. C′(i,j) can represent the element value of the i-th row and j-th column of the third intermediate matrix. fz(1,1) can represent the element value of the 1st row and 1st column of the fourth intermediate matrix. fz(1,2) can represent the element value of the 1st row and 2nd column of the fourth intermediate matrix. fz(2,1) can represent the element value of the 2nd row and 1st column of the fourth intermediate matrix. fz(2,2) can represent the element value of the 2nd row and 2nd column of the fourth intermediate matrix.

[0135] Through the method provided in this embodiment, since the electronic device can generate a diffusion matrix corresponding to the second key sequence through a reconstruction algorithm and a Fibonacci algorithm, and provide a diffusion matrix to perform image diffusion on the disturbed image, the method provided in this embodiment can improve the ability of the target encrypted image to resist plaintext attacks, thereby improving the security of the target encrypted image.

[0136] It should be noted that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0137] Reference Figure 5 , shows a schematic diagram of an image encryption device provided by an embodiment of the present application, which may specifically include a key determination module, wherein:

[0138] The key determination module 501 is used to input the image to be encrypted into the key sequence algorithm to determine the key sequence corresponding to the image to be encrypted; the key sequence algorithm is used to determine the key sequence according to the binary data corresponding to the image to be encrypted;

[0139] An image transformation module 502 is used to perform image transformation on the image to be encrypted based on the key sequence to determine a transformed image corresponding to the image to be encrypted;

[0140] The diffusion encryption module 503 is used to perform diffusion encryption on the pixel values ​​of the transformed image based on the key sequence to generate a target encrypted image.

[0141] The image transformation module can also be used to perform image perturbation on the channel matrix corresponding to each channel of the image to be encrypted based on the first key sequence to generate a perturbed image; the channel matrix is ​​generated based on the grayscale value of each first pixel on the corresponding channel of the image to be encrypted; the first pixel is a pixel on the image to be encrypted; and perform image diffusion on the perturbed image based on the second key sequence to generate the transformed image.

[0142] The image transformation module can also be used to perform matrix splicing based on the channel matrices corresponding to the channels in the image to be encrypted to obtain a color matrix corresponding to the image to be encrypted; input the first key sequence into a preset index sequence algorithm to generate a row index sequence and a column index sequence corresponding to the first key sequence; and perform matrix permutation on the color matrix based on the row index sequence and the column index sequence to generate the disturbed image.

[0143] The image transformation module can also be used to input the second key sequence into the first matrix construction algorithm to generate a diffusion matrix corresponding to the second key sequence; input the pixel value corresponding to each second pixel in the disturbed image into the second matrix construction algorithm to generate a transformation matrix corresponding to the disturbed image; the second pixel is a pixel in the disturbed image; and input the diffusion matrix and the transformation matrix into a preset diffusion function to generate the transformed image.

[0144] The image transformation module can also be used to input the second key sequence and the second image size of the disturbed image into the reconstruction algorithm to generate a chaotic matrix; the reconstruction algorithm is used to reconstruct the second key sequence into the chaotic matrix whose matrix size is consistent with the second image size according to the second image size; and input the chaotic matrix into the Fibonacci algorithm to generate the diffusion matrix.

[0145] The reconstruction algorithm in the image transformation module is as follows:

[0146] FN′=reshape((100×S2(1:H2×W2)),W2,H2)

[0147] FN = round(mod(FN′,17)+3)

[0148] Among them, FN is the chaotic matrix; round is the rounding function; mod is the modular operation function; FN′ is the first intermediate matrix; H2 is the height value in the second image size; W2 is the width value in the second image size; S2 is the second key sequence; reshape(A,p,q) is a dimensionality transformation function, which is used to construct A into a matrix with p rows and q columns.

[0149] The key determination module can also be used to input the binary data of the image to be encrypted into a preset hash function to determine the hash value corresponding to the image to be encrypted; input the hash value into the key function to generate the key parameter corresponding to the hash value; input the key parameter into the first chaotic sequence function to determine the first key sequence corresponding to the image to be encrypted; input the key parameter into the second chaotic sequence function to determine the second key sequence corresponding to the image to be encrypted.

[0150] The first chaotic sequence function in the key determination module is as follows:

[0151] S1=((2D_LSCM(a+0.1,b+0.1,c,3×H1×W1))×10000)mod255

[0152] Wherein, S1 is the first key sequence; 2D_LSCM is a two-dimensional discrete chaotic function; a is a first key parameter; b is a second key parameter; c is a third key parameter; H1 is a height value in the first image size corresponding to the image to be encrypted; W1 is a width value in the first image size corresponding to the image to be encrypted; mod is a modulus operation function;

[0153] Correspondingly, the second chaotic sequence function is as follows:

[0154] S2=((2D_LSCM(a+0.2,b+0.2,c,3×H1×W1))×10000)mod255

[0155] Among them, S2 is the second key sequence.

[0156] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment part.

[0157] Reference Figure 6 , shows a schematic diagram of an electronic device provided by an embodiment of the present application. Figure 6 As shown, the electronic device 600 in the embodiment of the present application includes: a processor 610, a memory 620, and a computer program 621 stored in the memory 620 and executable on the processor 610. When the processor 610 executes the computer program 621, the steps in each embodiment of the above-mentioned image encryption method are implemented, such as Figure 1 Alternatively, when the processor 610 executes the computer program 621, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Figure 3 Functions of modules 301 to 303 are shown.

[0158] Exemplarily, the computer program 621 may be divided into one or more modules / units, which are stored in the memory 620 and executed by the processor 610 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which may be used to describe the execution process of the computer program 621 in the electronic device 600. For example, the computer program 621 may be divided into a key determination module, an image transformation module, and a diffusion encryption module, and the specific functions of each module are as follows:

[0159] A key determination module, used to input the image to be encrypted into a key sequence algorithm to determine the key sequence corresponding to the image to be encrypted; the key sequence algorithm is used to determine the key sequence according to the binary data corresponding to the image to be encrypted;

[0160] An image transformation module, used to perform image transformation on the image to be encrypted based on the key sequence, and determine a transformed image corresponding to the image to be encrypted;

[0161] The diffusion encryption module is used to perform diffusion encryption on the pixel values ​​of the transformed image based on the key sequence to generate a target encrypted image.

[0162] The electronic device 600 may be the face recognition device and various distributed terminals in the above-mentioned embodiments. The electronic device 600 may include, but is not limited to, a processor 610 and a memory 620. Those skilled in the art will understand that Figure 6 It is only an example of the electronic device 600 and does not constitute a limitation of the electronic device 600. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device 600 may also include input and output devices, network access devices, buses, etc.

[0163] The processor 610 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0164] The memory 620 may be an internal storage unit of the electronic device 600, such as a hard disk or memory of the electronic device 600. The memory 620 may also be an external storage device of the electronic device 600, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 600. Further, the memory 620 may also include both an internal storage unit of the electronic device 600 and an external storage device. The memory 620 is used to store the computer program 621 and other programs and data required by the electronic device 600. The memory 620 may also be used to temporarily store data that has been output or is to be output.

[0165] An embodiment of the present application also discloses an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the image encryption method as described in the above-mentioned embodiments when executing the computer program.

[0166] The embodiment of the present application further discloses a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the image encryption method as described in the above-mentioned embodiments is implemented.

[0167] The embodiment of the present application further discloses a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the image encryption method described in the above-mentioned embodiments.

[0168] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application is described in detail with reference to the above-mentioned embodiments, a person skilled in the art should understand that the technical solutions described in the above-mentioned embodiments can still be modified, or some of the technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. An image encryption method, characterized in that: include: Inputting the image to be encrypted into the key sequence algorithm to determine the key sequence corresponding to the image to be encrypted; The key sequence algorithm is used to convert the binary data corresponding to the image to be encrypted into the key sequence; Performing image transformation on the image to be encrypted based on the key sequence to determine a transformed image corresponding to the image to be encrypted; The pixel values ​​of the transformed image are diffusely encrypted based on the key sequence to generate a target encrypted image.

2. The method according to claim 1, characterized in that: The key sequence includes a first key sequence and a second key sequence; The performing image transformation on the image to be encrypted based on the key sequence to determine a transformed image corresponding to the image to be encrypted includes: Based on the first key sequence, the channel matrix corresponding to each channel of the image to be encrypted is disturbed to generate a disturbed image; the channel matrix is ​​generated based on the grayscale value of each first pixel on the corresponding channel of the image to be encrypted; the first pixel is a pixel on the image to be encrypted; The disturbed image is subjected to image diffusion based on the second key sequence to generate the transformed image.

3. The method according to claim 2, characterized in that The step of performing image scrambling on the channel matrix corresponding to each channel of the image to be encrypted based on the first key sequence to generate a scrambled image includes: Perform matrix splicing based on the channel matrices corresponding to the channels in the image to be encrypted to obtain a color matrix corresponding to the image to be encrypted; Inputting the first key sequence into a preset index sequence algorithm to generate a row index sequence and a column index sequence corresponding to the first key sequence; The color matrix is ​​permuted based on the row index sequence and the column index sequence to generate the disturbed image.

4. The method according to claim 2, characterized in that: The step of performing image diffusion on the disturbed image based on the second key sequence to generate the transformed image includes: Inputting the second key sequence into the first matrix construction algorithm to generate a diffusion matrix corresponding to the second key sequence; Inputting the pixel value corresponding to each second pixel in the disturbed image into a second matrix construction algorithm to generate a transformation matrix corresponding to the disturbed image; the second pixel is a pixel in the disturbed image; The diffusion matrix and the transformation matrix are input into a preset diffusion function to generate the transformation image.

5. The method according to claim 4, characterized in that The first matrix construction algorithm includes a reconstruction algorithm and a Fibonacci algorithm; The step of inputting the second key sequence into the first matrix construction algorithm to generate a diffusion matrix corresponding to the second key sequence includes: Inputting the second key sequence and the second image size of the scrambled image into the reconstruction algorithm to generate a chaotic matrix; the reconstruction algorithm is used to reconstruct the second key sequence into the chaotic matrix whose matrix size is consistent with the second image size according to the second image size; The chaotic matrix is ​​input into the Fibonacci algorithm to generate the diffusion matrix.

6. The method according to claim 5, characterized in that The reconstruction algorithm is as follows: FN′=reshape((100×S2(1:H2×W2)),W2,H2) FN = round(mod(FN′,17)+3) Among them, FN is the chaotic matrix; round is the rounding function; mod is the modular operation function; FN′ is the first intermediate matrix; H2 is the height value in the second image size; W2 is the width value in the second image size; S2 is the second key sequence; reshape(A,p,q) is a dimensionality transformation function, which is used to construct A into a matrix with p rows and q columns.

7. The method according to any one of claims 2 to 6, characterized in that: The step of inputting the image to be encrypted into a key sequence algorithm to determine the key sequence corresponding to the image to be encrypted includes: Inputting the binary data of the image to be encrypted into a preset hash function to determine the hash value corresponding to the image to be encrypted; Inputting the hash value into a key function to generate a key parameter corresponding to the hash value; Inputting the key parameter into a first chaotic sequence function to determine a first key sequence corresponding to the image to be encrypted; The key parameter is input into a second chaotic sequence function to determine a second key sequence corresponding to the image to be encrypted.

8. The method according to claim 7, characterized in that The first chaotic sequence function is as follows: S1=((2D_LSCM(a+0.1,b+0.1,c,3×H1×W1))×10000)mod255 Wherein, S1 is the first key sequence; 2D_LSCM is a two-dimensional discrete chaotic function; a is a first key parameter; b is a second key parameter; c is a third key parameter; H1 is a height value in the first image size corresponding to the image to be encrypted; W1 is a width value in the first image size corresponding to the image to be encrypted; mod is a modulus operation function; Correspondingly, the second chaotic sequence function is as follows: S2=((2D_LSCM(a+0.2,b+0.2,c,3×H1×W1))×10000)mod255 Among them, S2 is the second key sequence.

9. An electronic device, characterized in that: The electronic device comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the electronic device implements the image encryption method as described in any one of claims 1 to 8.

10. A computer program product, characterized in that The invention comprises a computer program, which enables the image encryption method according to any one of claims 1 to 8 to be executed when the computer program is executed.