Image encryption method and system
By receiving the original image input by the user in real time, using the preset hash function to calculate the target hash value as the encryption key, generating the improved chaotic sequence and the adversarial neural network, performing z-shaped diffusion and chaos processing, and finally cyclically encrypted through the round function to generate the target encrypted image, solving the problem that the encrypted images in the existing technology are easily cracked, and achieving high-security image encryption processing.
Patent Information
- Application Number
- CN202510046343.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-13
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2045-01-13
AI Technical Summary
The encrypted images in the prior art are easily cracked by the outside world, resulting in a decrease in user experience.
By receiving the original image input by the user in real time, using the preset hash function to calculate the target hash value as the encryption key, generating the improved chaotic sequence and the adversarial neural network, performing z-shaped diffusion and mess processing, and finally cyclically encrypted through the round function to generate the target encrypted image.
Multiple encryption processing of images is realized, the security and randomness of encryption are improved, information leakage is avoided, and user experience is improved.
Smart Images

Figure CN119449969B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to an image encryption method and system. Background Art
[0002] With the advancement of science and technology and the rapid development of the times, the Internet and communication technology have become increasingly mature and have been popularized in people's daily lives. In the process of users transmitting images through the Internet, since the images may involve the privacy of users, corresponding encryption processing is required.
[0003] In order to quickly complete the encryption processing of images, the prior art has developed corresponding encryption algorithms and encryption sequences, and directly encrypts the user's image through the encryption algorithm for subsequent transmission.
[0004] Furthermore, in actual applications, since the structure of the existing encryption algorithm is relatively simple, the randomness of the generated encryption sequence may be insufficient, resulting in the encrypted image being easily cracked by the outside world, thereby correspondingly reducing the user experience. Summary of the invention
[0005] Based on this, the purpose of the present invention is to provide an image encryption method and system to solve the problem that the encrypted images in the prior art are easily cracked by the outside world, resulting in a reduced user experience.
[0006] The first aspect of the embodiment of the present invention proposes:
[0007] An image encryption method, wherein the method comprises:
[0008] Receiving an original image input by a user in real time, and calculating a target hash value corresponding to the original image in real time through a preset hash function, and setting the target hash value as an encryption key corresponding to the original image;
[0009] Based on preset rules, a number of system initial values adapted to the improved chaotic system are generated in real time according to the encryption key, and a corresponding chaotic sequence is output in real time according to the improved chaotic system and the number of system initial values, and an adversarial neural network adapted to the improved chaotic system is trained in real time according to the chaotic sequence;
[0010] Performing zigzag diffusion processing on the chaotic sequence to generate a corresponding image matrix in real time, and performing scrambling processing on the image matrix by a preset scrambling algorithm to generate a corresponding scrambled image in real time;
[0011] A corresponding round function is constructed in real time according to the chaotic sequence and the generated data of the adversarial neural network, and the scrambled image is cyclically encrypted by the round function in real time to generate a target encrypted image corresponding to the original image in real time.
[0012] The beneficial effects of the present invention are as follows: by performing a hash operation on the original image received in real time, the corresponding initial encryption can be completed. Based on this, a pre-improved chaotic system will be called out, and a corresponding chaotic sequence can be further output according to the target hash value. Furthermore, the image matrix of the current original image can be scrambled by the chaotic sequence to generate a corresponding scrambled image, and the required target encrypted image can finally be constructed according to the scrambled image, thereby completing multiple encryption processing of the original image, avoiding information leakage, and correspondingly improving the user experience.
[0013] Furthermore, the step of generating a plurality of system initial values adapted to the improved chaotic system in real time according to the encryption key based on a preset rule comprises:
[0014] When the encryption key is obtained in real time, a plurality of original hash values corresponding to the encryption key are extracted in real time;
[0015] Grouping the plurality of original hash values once to generate a plurality of first arrays correspondingly, wherein the values contained in each of the first arrays are all decimal numbers;
[0016] A plurality of system initial values are generated in real time according to a plurality of the first arrays, and each of the system initial values is unique.
[0017] Furthermore, the step of generating a plurality of system initial values in real time according to a plurality of the first arrays includes:
[0018] When a plurality of the first arrays are acquired in real time, the plurality of the first arrays are grouped twice to generate a plurality of second arrays correspondingly, each of the second arrays comprising eight numbers;
[0019] Detecting in real time the target quantity corresponding to the plurality of the original hash values, and dividing each value in the second array by the target quantity to obtain the corresponding target result in real time;
[0020] The target result is screened in real time to generate a number of system initial values accordingly, and the target result includes a specific numerical value.
[0021] Furthermore, the expression of the improved chaotic system is:
[0022]
[0023] Among them, a, b, c, d, e, and r represent the control parameters of the chaotic system, and x, y, z, and w represent the chaotic sequence.
[0024] Furthermore, the step of scrambling the image matrix by using a preset scrambling algorithm to generate a corresponding scrambled image in real time includes:
[0025] When the image matrix is acquired in real time, the image matrix is converted into a corresponding one-dimensional vector in real time;
[0026] Calculating a corresponding scrambling key in real time according to the one-dimensional vector, and performing real-time parsing processing on the scrambling key to detect in real time a number of key sequences corresponding to the scrambling key;
[0027] A plurality of the key sequences are integrated to generate the scrambled image accordingly.
[0028] Furthermore, the step of integrating the plurality of key sequences to generate the scrambled image accordingly includes:
[0029] When a plurality of key sequences are acquired in real time, determining in real time whether there are repeated sequences in the plurality of key sequences;
[0030] If it is determined in real time that there are duplicate sequences in some of the key sequences, the existing duplicate sequences are correspondingly eliminated, and it is determined in real time whether there are defects in the remaining key sequences;
[0031] If it is determined in real time that there are defects in the remaining key sequences, the defective key sequences are complemented to generate the corresponding target scrambling key in real time, and the scrambled image is generated in real time according to the target scrambling key.
[0032] Furthermore, the expression of the preset random algorithm is:
[0033]
[0034] Wherein, ScrKey represents the scrambling key, Temp represents the temporary register, A represents the replacement object, M×N represents the size of the image, and i represents the index position of the image vector.
[0035] The second aspect of the embodiment of the present invention proposes:
[0036] An image encryption system, wherein the system comprises:
[0037] A calculation module, used to receive an original image input by a user in real time, and calculate a target hash value corresponding to the original image in real time through a preset hash function, and set the target hash value as an encryption key corresponding to the original image;
[0038] A training module, used for generating a plurality of system initial values adapted to the improved chaotic system in real time according to the encryption key based on a preset rule, and outputting a corresponding chaotic sequence in real time according to the improved chaotic system and the plurality of system initial values, and training an adversarial neural network adapted to the improved chaotic system in real time according to the chaotic sequence;
[0039] A processing module, used for performing zigzag diffusion processing on the chaotic sequence to generate a corresponding image matrix in real time, and performing scrambling processing on the image matrix through a preset scrambling algorithm to generate a corresponding scrambled image in real time;
[0040] The encryption module is used to construct a corresponding round function in real time according to the chaotic sequence and the generated data of the adversarial neural network, and to perform cyclic encryption processing on the scrambled image through the round function in real time to generate a target encrypted image corresponding to the original image in real time.
[0041] Furthermore, the training module is specifically used for:
[0042] When the encryption key is obtained in real time, a plurality of original hash values corresponding to the encryption key are extracted in real time;
[0043] Grouping the plurality of original hash values once to generate a plurality of first arrays correspondingly, wherein the values contained in each of the first arrays are all decimal numbers;
[0044] A plurality of system initial values are generated in real time according to a plurality of the first arrays, and each of the system initial values is unique.
[0045] Furthermore, the training module is specifically used for:
[0046] When a plurality of the first arrays are acquired in real time, the plurality of the first arrays are grouped twice to generate a plurality of second arrays correspondingly, each of the second arrays comprising eight numbers;
[0047] Detecting in real time the target quantity corresponding to the plurality of the original hash values, and dividing each value in the second array by the target quantity to obtain the corresponding target result in real time;
[0048] The target result is screened in real time to generate a number of system initial values accordingly, and the target result includes a specific numerical value.
[0049] Furthermore, the expression of the improved chaotic system is:
[0050]
[0051] Among them, a, b, c, d, e, and r represent the control parameters of the chaotic system, and x, y, z, and w represent the chaotic sequence.
[0052] Furthermore, the processing module is specifically used for:
[0053] When the image matrix is acquired in real time, the image matrix is converted into a corresponding one-dimensional vector in real time;
[0054] Calculating a corresponding scrambling key in real time according to the one-dimensional vector, and performing real-time parsing processing on the scrambling key to detect in real time a number of key sequences corresponding to the scrambling key;
[0055] A plurality of the key sequences are integrated to generate the scrambled image accordingly.
[0056] Furthermore, the processing module is specifically used for:
[0057] When a plurality of key sequences are acquired in real time, determining in real time whether there are repeated sequences in the plurality of key sequences;
[0058] If it is determined in real time that there are duplicate sequences in some of the key sequences, the existing duplicate sequences are correspondingly eliminated, and it is determined in real time whether there are defects in the remaining key sequences;
[0059] If it is determined in real time that there are defects in the remaining key sequences, the defective key sequences are complemented to generate the corresponding target scrambling key in real time, and the scrambled image is generated in real time according to the target scrambling key.
[0060] Furthermore, the expression of the preset random algorithm is:
[0061]
[0062] Wherein, ScrKey represents the scrambling key, Temp represents the temporary register, A represents the replacement object, M×N represents the size of the image, and i represents the index position of the image vector.
[0063] The third aspect of the embodiment of the present invention proposes:
[0064] A computer comprises 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 above when executing the computer program.
[0065] The fourth aspect of the embodiments of the present invention proposes:
[0066] A readable storage medium stores a computer program, wherein the program implements the image encryption method as described above when executed by a processor.
[0067] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] Figure 1 A flowchart of an image encryption method provided by a first embodiment of the present invention;
[0069] Figure 2 A schematic diagram of a scrambling algorithm in an image encryption method provided in a second embodiment of the present invention;
[0070] Figure 3 A schematic diagram of an encryption process in an image encryption method provided in a second embodiment of the present invention;
[0071] Figure 4 This is a structural block diagram of an image encryption system provided in the third embodiment of the present invention.
[0072] The following specific implementation manner will further illustrate the present invention in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION
[0073] In order to facilitate the understanding of the present invention, the present invention will be described more fully below with reference to the relevant drawings. Several embodiments of the present invention are given in the drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present invention more thorough and comprehensive.
[0074] It should be noted that when an element is referred to as being "fixed to" another element, it may be directly on the other element or there may be a central element. When an element is considered to be "connected to" another element, it may be directly connected to the other element or there may be a central element at the same time. The terms "vertical", "horizontal", "left", "right" and similar expressions used herein are for illustrative purposes only.
[0075] 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 the present invention belongs. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0076] See also Figure 1 , which shows the image encryption method provided by the first embodiment of the present invention. The image encryption method provided by this embodiment can quickly and effectively complete multiple encryption processing of various types of images, thereby correspondingly improving the user experience.
[0077] Specifically, this embodiment provides:
[0078] An image encryption method specifically comprises the following steps:
[0079] Step S10, receiving the original image input by the user in real time, and calculating the target hash value corresponding to the original image in real time through a preset hash function, and setting the target hash value as the encryption key corresponding to the original image;
[0080] Step S20, based on preset rules, generating in real time a number of system initial values adapted to the improved chaotic system according to the encryption key, and outputting in real time a corresponding chaotic sequence according to the improved chaotic system and the number of system initial values, and training in real time an adversarial neural network adapted to the improved chaotic system according to the chaotic sequence;
[0081] Step S30, performing zigzag diffusion processing on the chaotic sequence to generate a corresponding image matrix in real time, and performing scrambling processing on the image matrix by a preset scrambling algorithm to generate a corresponding scrambled image in real time;
[0082] Step S40, constructing a corresponding round function in real time according to the chaotic sequence and the generated data of the adversarial neural network, and performing cyclic encryption processing on the scrambled image through the round function in real time to generate a target encrypted image corresponding to the original image in real time.
[0083] Second embodiment
[0084] Furthermore, the step of generating a plurality of system initial values adapted to the improved chaotic system in real time according to the encryption key based on a preset rule comprises:
[0085] When the encryption key is obtained in real time, a plurality of original hash values corresponding to the encryption key are extracted in real time;
[0086] Grouping the plurality of original hash values once to generate a plurality of first arrays correspondingly, wherein the values contained in each of the first arrays are all decimal numbers;
[0087] A plurality of system initial values are generated in real time according to a plurality of the first arrays, and each of the system initial values is unique.
[0088] Furthermore, the step of generating a plurality of system initial values in real time according to a plurality of the first arrays includes:
[0089] When a plurality of the first arrays are acquired in real time, the plurality of the first arrays are grouped twice to generate a plurality of second arrays correspondingly, each of the second arrays comprising eight numbers;
[0090] Detecting in real time the target quantity corresponding to the plurality of the original hash values, and dividing each value in the second array by the target quantity to obtain the corresponding target result in real time;
[0091] The target result is screened in real time to generate a number of system initial values accordingly, and the target result includes a specific numerical value.
[0092] Furthermore, the expression of the improved chaotic system is:
[0093]
[0094] Among them, a, b, c, d, e, and r represent the control parameters of the chaotic system, and x, y, z, and w represent the chaotic sequence.
[0095] Furthermore, the step of scrambling the image matrix by using a preset scrambling algorithm to generate a corresponding scrambled image in real time includes:
[0096] When the image matrix is acquired in real time, the image matrix is converted into a corresponding one-dimensional vector in real time;
[0097] Calculating a corresponding scrambling key in real time according to the one-dimensional vector, and performing real-time parsing processing on the scrambling key to detect in real time a number of key sequences corresponding to the scrambling key;
[0098] A plurality of the key sequences are integrated to generate the scrambled image accordingly.
[0099] Furthermore, the step of integrating the plurality of key sequences to generate the scrambled image accordingly includes:
[0100] When a plurality of key sequences are acquired in real time, determining in real time whether there are repeated sequences in the plurality of key sequences;
[0101] If it is determined in real time that there are duplicate sequences in some of the key sequences, the existing duplicate sequences are correspondingly eliminated, and it is determined in real time whether there are defects in the remaining key sequences;
[0102] If it is determined in real time that there are defects in the remaining key sequences, the defective key sequences are complemented to generate the corresponding target scrambling key in real time, and the scrambled image is generated in real time according to the target scrambling key.
[0103] Furthermore, the expression of the preset random algorithm is:
[0104]
[0105] Wherein, ScrKey represents the scrambling key, Temp represents the temporary register, A represents the replacement object, M×N represents the size of the image, and i represents the index position of the image vector.
[0106] In addition, in this embodiment, it should be noted that this embodiment will pre-set a novel 4-dimensional hyperchaotic system, and compared with the traditional chaotic system, three control parameters and one dimension are added, thereby greatly increasing the key space and having a larger Lyapunov index than the traditional chaotic system. Based on this, the specific encryption process provided by this embodiment is:
[0107] Step 1: Calculate the hash value of image P through SHA-256, which is used as a key for the encryption algorithm in this article.
[0108] Step 2: Divide the 256-bit hash value into 8-bit groups, that is, into 32 groups in total, and then convert these 32 groups into corresponding decimal numbers. i is the decimal number of the i-th group, h ij is the j-th digit in the i-th group, i=1,2,…,32, j=1,2,…,8.
[0109]
[0110] Step 3: Group the 32 groups of numbers into 4 groups, each with 8 numbers. Add the 8 numbers in each group and divide by 256 to get the two decimal places of the result. These 4 groups of decimals are used as the 4 initial values of the new hyperchaotic system. }.
[0111]
[0112]
[0113] Among them, Decimel2 is the two decimal places, such as 12.85206, which is 0.85, H represents the sum of the numbers in each group, and L represents a constant.
[0114] Step 4: Set the control parameters of the improved chaotic system, substitute the 4 initial values into the system. To avoid transient effects, iterate 1000 + MxN times, and take the last MxN numbers. Obtain the sequence { }.
[0115] Step 5: Generate a Generative Adversarial Network (GAN): This GAN mainly consists of a generator and a discriminator. Use the y n sequence as the real data of the GAN, and use the plaintext image before encryption as the input data of the generator, and then train it to make the generator output generated data GKdata similar to y n . The purpose is that the discriminator cannot distinguish between the real data and the generated data, and the discriminator is also trained simultaneously to achieve a dynamic balance.
[0116] Step 6: Perform the zigzag diffusion operation. (The image size is MxN)
[0117] (1) First, perform the following operations on the chaotic sequence x n of the new hyperchaotic system: where mod is the modulo operation, floor is the ceiling function, and reshape is to change the matrix shape.
[0118]
[0119]
[0120] (2) Set row = 1, col = 1, and direction = 1 to represent the row index, column index, and traversal direction respectively. When direction = 1, it traverses in the upper right direction, and -1 for the lower left direction.
[0121] (3) Set , as the initial value of N4DHS. According to the formula:
[0122]
[0123] (4) Judge whether the traversal is completed. If it is completed, jump to (12); otherwise, jump to (5).
[0124] (5) Judge what direction is equal to. If it is 1, jump to (6); if it is -1, jump to (9).
[0125] (6) Judge whether row>1&&col<N. If it is satisfied, after performing the following formula, return to (4); otherwise, jump to (7):
[0126]
[0127]
[0128] (7) Whether col is equal to N. If so, after executing the following formula, jump to (4); otherwise, jump to (8):
[0129]
[0130]
[0131] (8) After executing the following formula, jump to (4):
[0132]
[0133]
[0134] (9) Determine whether col > 1 && row < M. If satisfied, after executing the following formula, return to (4); otherwise, jump to (10):
[0135]
[0136]
[0137] (10) Determine whether row is equal to M. If so, after executing the following formula, jump to (4); otherwise, jump to (11):
[0138]
[0139]
[0140] (11) After executing the following formula, jump to (4):
[0141]
[0142]
[0143] (12) End.
[0144] Step 7: Execute the unique position scrambling algorithm
[0145] (1) First, perform the following changes on GKdata to prepare for the subsequent scrambling algorithm, and perform corresponding changes on the chaotic sequences z n , w n to obtain Z and W, the sequences used for scrambling. The specific change formulas are:
[0146]
[0147]
[0148]
[0149] Among them, i=1, 2...M; j=1, 2,...N. Further, the image matrix is converted into a one-dimensional vector, that is, P(idx) (idx= 1, 2..., M*N). The scrambling key ScrKey(idx) is obtained according to the formula. Kidx, zidx, and widx are all set to 1, and the following operations are started:
[0150]
[0151] Among them, idx = 1, 2, ...MN, and then perform the following operations:
[0152]
[0153] After obtaining a part of the corresponding scrambling key, perform the following operations to change the index of the corresponding sequence according to the value of result:
[0154]
[0155] After obtaining the scrambled key SrcKey, simplify the repeated sequences in SrcKey, that is, each sequence is unique in the integer interval [1, MxN], and then fill in the numbers that are not in ScrKey in the interval [1, MxN]:
[0156]
[0157]
[0158]
[0159] unique means eliminating duplicate sequences in ScrKey, IDX means the index position of the original sequence where the single sequence remaining after eliminating duplicate sequences is located, and then the remaining integer values are filled in the interval [1, MxN]:
[0160]
[0161] The function of setdiff means that if ScrKey lacks a value in the integer interval [1,MxN], it will be automatically added as part of ScrKey. The final ScrKey is a single sequence scrambled key, which greatly increases the security of the encryption algorithm.
[0162] (2) Scramble the image that has been diffused: First, make the following changes to the image to obtain a one-dimensional vector A:
[0163]
[0164] (3) Perform scrambling operation on the one-dimensional vector using the scrambling key ScrKey.
[0165] Step 8: PLCBC encryption
[0166] Block encryption is essentially to group plaintext, and operate each group of plaintext with a key or random array to obtain multiple groups of ciphertext. However, for CBC block encryption, due to its single structure and weak anti-attack ability, this paper improves the traditional CBC block encryption structure, adds a round function to encrypt each group of plaintext to obtain ciphertext, and performs cyclic encryption operations, and proposes an improved cyclic CBC block encryption (PLCBC). The encryption process and structure of PLCBC are as follows: Figure 3 As shown:
[0167] The encrypted group generated in each iteration is used as the plaintext group of the next iteration. If the input image size is M*N, then i = 1, 2...M*N / 4, which is represented as the i-th round of encryption. The round function is composed of the chaotic sequence and the generated data of GAN to form a cyclic group encryption network, which improves the anti-attack ability and security of the encryption system.
[0168] 1. Divide the one-dimensional vector A into four groups and get , where i=1,2…,MxN / 4, represents the i-th iteration, and j=1,2,3,4 represents the j-th group.
[0169] 2. Use the round function to perform the first round of encryption:
[0170]
[0171]
[0172]
[0173]
[0174] Where U is a vector of all 1s, that is, all the numbers in the sequence converted to decimal are 255, and the round function sequence , and then divide it into four groups to get , after the next cycle , the subsequent steps are similar.
[0175] 3. Repeat MxN / 4-1 times to get the final encrypted image:
[0176]
[0177]
[0178]
[0179]
[0180] where i=2,3…,MxN / 4, ,j=1,2,3,4.
[0181] 4. After the above process, Merge them together in order to get C, transform C by C=reshape(C,M,N) to finally get the encrypted image C.
[0182] See also Figure 4 , the third embodiment of the present invention provides:
[0183] An image encryption system, wherein the system comprises:
[0184] A calculation module, used to receive an original image input by a user in real time, and calculate a target hash value corresponding to the original image in real time through a preset hash function, and set the target hash value as an encryption key corresponding to the original image;
[0185] A training module, used for generating a plurality of system initial values adapted to the improved chaotic system in real time according to the encryption key based on a preset rule, and outputting a corresponding chaotic sequence in real time according to the improved chaotic system and the plurality of system initial values, and training an adversarial neural network adapted to the improved chaotic system in real time according to the chaotic sequence;
[0186] A processing module, used for performing zigzag diffusion processing on the chaotic sequence to generate a corresponding image matrix in real time, and performing scrambling processing on the image matrix through a preset scrambling algorithm to generate a corresponding scrambled image in real time;
[0187] The encryption module is used to construct a corresponding round function in real time according to the chaotic sequence and the generated data of the adversarial neural network, and to perform cyclic encryption processing on the scrambled image through the round function in real time to generate a target encrypted image corresponding to the original image in real time.
[0188] Furthermore, the training module is specifically used for:
[0189] When the encryption key is obtained in real time, a plurality of original hash values corresponding to the encryption key are extracted in real time;
[0190] Grouping the plurality of original hash values once to generate a plurality of first arrays correspondingly, wherein the values contained in each of the first arrays are all decimal numbers;
[0191] A plurality of system initial values are generated in real time according to a plurality of the first arrays, and each of the system initial values is unique.
[0192] Furthermore, the training module is specifically used for:
[0193] When a plurality of the first arrays are acquired in real time, the plurality of the first arrays are grouped twice to generate a plurality of second arrays correspondingly, each of the second arrays comprising eight numbers;
[0194] Detecting in real time the target quantity corresponding to the plurality of the original hash values, and dividing each value in the second array by the target quantity to obtain the corresponding target result in real time;
[0195] The target result is screened in real time to generate a number of system initial values accordingly, and the target result includes a specific numerical value.
[0196] Furthermore, the expression of the improved chaotic system is:
[0197]
[0198] Among them, a, b, c, d, e, and r represent the control parameters of the chaotic system, and x, y, z, and w represent the chaotic sequence.
[0199] Furthermore, the processing module is specifically used for:
[0200] When the image matrix is acquired in real time, the image matrix is converted into a corresponding one-dimensional vector in real time;
[0201] Calculating a corresponding scrambling key in real time according to the one-dimensional vector, and performing real-time parsing processing on the scrambling key to detect in real time a number of key sequences corresponding to the scrambling key;
[0202] A plurality of the key sequences are integrated to generate the scrambled image accordingly.
[0203] Furthermore, the processing module is specifically used for:
[0204] When a plurality of key sequences are acquired in real time, determining in real time whether there are repeated sequences in the plurality of key sequences;
[0205] If it is determined in real time that there are duplicate sequences in some of the key sequences, the existing duplicate sequences are correspondingly eliminated, and it is determined in real time whether there are defects in the remaining key sequences;
[0206] If it is determined in real time that there are defects in the remaining key sequences, the defective key sequences are complemented to generate the corresponding target scrambling key in real time, and the scrambled image is generated in real time according to the target scrambling key.
[0207] Furthermore, the expression of the preset random algorithm is:
[0208]
[0209] Wherein, ScrKey represents the scrambling key, Temp represents the temporary register, A represents the replacement object, M×N represents the size of the image, and i represents the index position of the image vector.
[0210] A fourth embodiment of the present invention provides a computer, comprising 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 described above when executing the computer program.
[0211] A fifth embodiment of the present invention provides a readable storage medium having a computer program stored thereon, wherein the program implements the image encryption method as described above when executed by a processor.
[0212] In summary, the image encryption method and system provided by the above embodiments of the present invention can quickly and effectively complete multiple encryption processing of various types of images, thereby correspondingly improving the user experience.
[0213] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0214] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0215] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.
[0216] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0217] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0218] The above-described embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the present invention. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the attached claims.
Claims
1. An image encryption method, characterized in that: The method comprises: Receiving an original image input by a user in real time, and calculating a target hash value corresponding to the original image in real time through a preset hash function, and setting the target hash value as an encryption key corresponding to the original image; Based on preset rules, a number of system initial values adapted to the improved chaotic system are generated in real time according to the encryption key, and a corresponding chaotic sequence is output in real time according to the improved chaotic system and the number of system initial values, and an adversarial neural network adapted to the improved chaotic system is trained in real time according to the chaotic sequence; Performing zigzag diffusion processing on the chaotic sequence to generate a corresponding image matrix in real time, and performing scrambling processing on the image matrix by a preset scrambling algorithm to generate a corresponding scrambled image in real time; A corresponding round function is constructed in real time according to the chaotic sequence and the generated data of the adversarial neural network, and the scrambled image is cyclically encrypted by the round function in real time to generate a target encrypted image corresponding to the original image in real time.
2. The image encryption method according to claim 1, characterized in that: The step of generating a plurality of system initial values adapted to the improved chaotic system in real time according to the encryption key based on a preset rule comprises: When the encryption key is obtained in real time, a plurality of original hash values corresponding to the encryption key are extracted in real time; Grouping the plurality of original hash values once to generate a plurality of first arrays correspondingly, wherein the values contained in each of the first arrays are all decimal numbers; A plurality of system initial values are generated in real time according to a plurality of the first arrays, and each of the system initial values is unique.
3. The image encryption method according to claim 2, characterized in that: The step of generating a plurality of system initial values in real time according to a plurality of the first arrays comprises: When a plurality of the first arrays are acquired in real time, the plurality of the first arrays are grouped twice to generate a plurality of second arrays correspondingly, each of the second arrays comprising eight numbers; Detecting in real time the target quantity corresponding to the plurality of the original hash values, and dividing each value in the second array by the target quantity to obtain the corresponding target result in real time; The target result is screened in real time to generate a number of system initial values accordingly, and the target result includes a specific numerical value.
4. The image encryption method according to claim 3, characterized in that: The expression of the improved chaotic system is: Among them, a, b, c, d, e, and r represent the control parameters of the chaotic system, and x, y, z, and w represent the chaotic sequence.
5. The image encryption method according to claim 1, characterized in that: The step of scrambling the image matrix by using a preset scrambling algorithm to generate a corresponding scrambled image in real time comprises: When the image matrix is acquired in real time, the image matrix is converted into a corresponding one-dimensional vector in real time; Calculating a corresponding scrambling key in real time according to the one-dimensional vector, and performing real-time parsing processing on the scrambling key to detect in real time a number of key sequences corresponding to the scrambling key; A plurality of the key sequences are integrated to generate the scrambled image accordingly.
6. The image encryption method according to claim 5, characterized in that: The step of integrating the plurality of key sequences to generate the scrambled image accordingly comprises: When a plurality of key sequences are acquired in real time, determining in real time whether there are repeated sequences in the plurality of key sequences; If it is determined in real time that there are duplicate sequences in some of the key sequences, the existing duplicate sequences are correspondingly eliminated, and it is determined in real time whether there are defects in the remaining key sequences; If it is determined in real time that there are defects in the remaining key sequences, the defective key sequences are complemented to generate the corresponding target scrambling key in real time, and the scrambled image is generated in real time according to the target scrambling key.
7. The image encryption method according to claim 6, characterized in that: The expression of the preset random algorithm is: Wherein, ScrKey represents the scrambling key, Temp represents the temporary register, A represents the replacement object, M×N represents the size of the image, and i represents the index position of the image vector.
8. An image encryption system, characterized in that: The system comprises: A calculation module, used to receive an original image input by a user in real time, and calculate a target hash value corresponding to the original image in real time through a preset hash function, and set the target hash value as an encryption key corresponding to the original image; A training module, used for generating a plurality of system initial values adapted to the improved chaotic system in real time according to the encryption key based on a preset rule, and outputting a corresponding chaotic sequence in real time according to the improved chaotic system and the plurality of system initial values, and training an adversarial neural network adapted to the improved chaotic system in real time according to the chaotic sequence; A processing module, used for performing zigzag diffusion processing on the chaotic sequence to generate a corresponding image matrix in real time, and performing scrambling processing on the image matrix through a preset scrambling algorithm to generate a corresponding scrambled image in real time; The encryption module is used to construct a corresponding round function in real time according to the chaotic sequence and the generated data of the adversarial neural network, and to perform cyclic encryption processing on the scrambled image through the round function in real time to generate a target encrypted image corresponding to the original image in real time.
9. A computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the image encryption method according to any one of claims 1 to 7 is implemented.
10. A readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the image encryption method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Image encryption method and device based on novel two-dimensional composite chaotic mapping and SHA-256
CN113538203A
Visual security image encryption method based on compressed sensing and cyclic generative adversarial network
CN117353970A