Adaptive jpeg compression image encryption method device, equipment and medium
By adaptively generating keys and pseudo-random number sequences to encrypt the DC and AC coefficients of JPEG images, this method addresses the shortcomings of existing JPEG image encryption algorithms in terms of compatibility and security, achieving efficient image encryption and anti-attack capabilities.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SOUTH CHINA UNIV OF TECH
- Filing Date
- 2024-12-09
- Publication Date
- 2026-04-28
AI Technical Summary
Existing JPEG image encryption algorithms are inadequate in terms of compatibility and file size consistency, and are vulnerable to chosen-plaintext attacks and cannot effectively defend against contour attacks.
An adaptive JPEG compressed image encryption method is adopted. By generating adaptive keys KDC, KAC and KBlk, a pseudo-random number sequence is generated using a chaotic system to encrypt the DC and AC coefficients. Combined with overflow threshold management of the DC coefficients and fragment scrambling of the AC coefficients, the encryption process is ensured to not damage the file structure and file size.
While maintaining compatibility with the JPEG standard, this technology enhances the security and resistance to attacks of encrypted images, ensuring that each image has a unique key and preventing file size increases and contour attacks.
Smart Images

Figure CN119653024B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image information security, and in particular to an adaptive JPEG compressed image encryption method, apparatus, and medium. Background Technology
[0002] Thanks to the rapid development of internet technology and the increase in mobile bandwidth, people have gradually shifted their information exchange methods from text to various internet information carriers such as voice, images, and video, utilizing the convenient and fast network. JPEG format images are widely used in various digital mobile devices, such as mobile phones and digital cameras, which store images in JPEG format by default. Research on the security and privacy protection of JPEG images, especially high-value images such as military maps, medical images, and personal archives, has also attracted many scholars.
[0003] The best solution to this problem is to directly encrypt the JPEG image. Past research has proposed many encryption schemes for JPEG compressed images. These schemes suffer from two main problems: one is the disruption of the correlation between coefficients in the file data, leading to an increase in the encrypted image file size; the other is the destruction of the file's syntax, making the file impossible to fully recover or decode. Currently, state-of-the-art encryption algorithms for JPEG images achieve good results in terms of format compatibility and maintaining consistent file size before and after encryption. However, they also introduce problems such as the inability to encrypt images with low quality factors and vulnerability to chosen-plaintext attacks. Summary of the Invention
[0004] In order to at least partially solve one of the technical problems existing in the prior art, the present invention aims to provide an adaptive JPEG compressed image encryption method, apparatus, and medium.
[0005] The first technical solution adopted in this invention is:
[0006] An adaptive JPEG compressed image encryption method includes the following steps:
[0007] Obtain JPEG image and user key K init ;
[0008] Based on the JPEG image and user key K init Adaptive generation of key K DC Key K AC and key K Blk ;
[0009] According to key K DC Generate the first pseudo-random number sequence seq1, based on the key K.AC Generate a second pseudo-random number sequence seq2 based on the key K. Blk Generate the third pseudo-random number sequence seq3;
[0010] Decode the JPEG image to obtain the DC coefficients and AC coefficients;
[0011] The DC coefficients are encrypted based on the first pseudo-random number sequence seq1;
[0012] The AC coefficients are encrypted using the second pseudo-random number sequence seq2;
[0013] Encode the encrypted DC and AC coefficients to obtain the encrypted JPEG image.
[0014] Furthermore, the step of using the JPEG image and user key K... init Adaptive generation of key K DC Key K AC and key K Blk ,include:
[0015] make Represents n blocks (Blk1, Blk2, ..., Blk) of an image n The sum of the AC coefficients at position r in the frequency domain is used to obtain the key K in the following way. DC :
[0016]
[0017] make The key K is obtained by representing the number of non-zero AC coefficients in the frequency domain of n blocks of an image at position r, as follows: AC :
[0018]
[0019] The key K is obtained through the following method. Blk :
[0020]
[0021] In the formula, SHA 256 () represents SHA 256 The function, ⊕ represents the XOR operation.
[0022] Furthermore, the statement based on key K DC Generate the first pseudo-random number sequence seq1, based on the key K. AC Generate a second pseudo-random number sequence seq2 based on the key K. Blk Generate the third pseudo-random number sequence seq3, including:
[0023] According to key K DC Obtain the initial chaotic values (θ1, x1, y1) according to the key K. AC Obtain the initial chaotic values (θ2, x2, y2) according to the key K. Blk Obtain the initial chaotic values (θ3, x3, y3); where θ1, θ2, θ3 are preset values;
[0024] A chaotic system is used to iterate through the initial chaotic value multiple times to obtain a sequence of chaotic numbers of arbitrary length N, called chaos. seq ;
[0025] For the chaotic number sequence chaos seq After sorting, the sequence of their original indices is the pseudo-random sequence required for encryption; the three chaotic initial values correspond to three pseudo-random number sequences respectively;
[0026] Where, x j and y j Obtained through the following methods:
[0027] After obtaining the key required for the corresponding pseudo-random number sequence, the 256 bits of the key (b1, b2, ..., b...) are... 256 The data is divided into two groups, each containing 128 bits. The following formula is used to sequentially generate a set of initial chaotic values for x, based on the number of "1" bits in each group. θ and y θ value,
[0028]
[0029] Further, the encryption of the DC coefficients based on the first pseudo-random number sequence seq1 includes:
[0030] The DC coefficient set D, sequentially decoded from the JPEG image, is then subjected to inverse DPCM encoding to obtain...
[0031] Will After restoring to a two-dimensional matrix, for S-shaped scan obtained Will Re-encode DPCM to obtain D s ;
[0032] The values of the overflow thresholds UF and DF are determined using the interval factor α, and then D is... s The system is divided into several overflow critical intervals (OCI). The DC coefficients in each overflow critical interval (OCI) are scrambled using the first pseudo-random number sequence seq1, resulting in the encrypted set of DC coefficients D. α ;
[0033] Using the new interval factor β, the overflow thresholds UF and DF are obtained again, and the encrypted D is then... α The system is divided into several overflow critical intervals (OCI), and then each overflow critical interval (OCI) is scrambled and encrypted again to obtain the DC coefficient set D. β Where β > α.
[0034] Furthermore, the expressions for the upward overflow threshold UF and the downward overflow threshold DF, determined using the interval factor α, are as follows:
[0035]
[0036] Where α∈(0,1], This indicates that the number is rounded down.
[0037] Further, the encryption of the AC coefficients based on the second pseudo-random number sequence seq2 includes:
[0038] Given a frequency domain r, divide the AC coefficients of all blocks in an image into two parts according to the given frequency domain r;
[0039] The first and second halves of the blocks where the AC coefficients at frequency r are not zero are extracted and placed into the first scramble set FSS, respectively. r (Front Scrambled Set) and Back Scrambled Set (BSS) r (Back Scrambled Set);
[0040] The front scrambled set FSS r and the rear scramble set BSS r The internal coefficient segments are scrambled using the second pseudo-random number sequence seq2, and then sequentially reinserted into the corresponding blocks to encrypt the AC coefficients.
[0041] Furthermore, the step of encrypting the AC coefficients based on the second pseudo-random number sequence seq2 also includes the following steps:
[0042] After the scrambled fragments are put back into the corresponding blocks, the blocks are scrambled according to the third pseudo-random number sequence seq3.
[0043] The second technical solution adopted in this invention is:
[0044] An adaptive JPEG compressed image encryption device, comprising:
[0045] Image input module, used to acquire JPEG images and user key K init ;
[0046] The key generation module is used to generate a key based on a JPEG image and the user key K.init Adaptive generation of key K DC Key K AC and key K Blk ;
[0047] The random sequence generation module is used to generate random sequences based on the key K. DC Generate the first pseudo-random number sequence seq1, based on the key K. AC Generate a second pseudo-random number sequence seq2 based on the key K. Blk Generate the third pseudo-random number sequence seq3;
[0048] The image decoding module is used to decode JPEG images to obtain DC and AC coefficients;
[0049] The DC encryption module is used to encrypt the DC coefficients based on the first pseudo-random number sequence seq1.
[0050] The AC encryption module is used to encrypt the AC coefficients based on the second pseudo-random number sequence seq2.
[0051] The image encoding module is used to encode the encrypted DC coefficients and AC coefficients to obtain an encrypted JPEG image.
[0052] The third technical solution adopted in this invention is:
[0053] An electronic device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set, or an instruction set, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to implement an adaptive JPEG compressed image encryption method as described above.
[0054] The fourth technical solution adopted in this invention is:
[0055] A computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement an adaptive JPEG compressed image encryption method as described above.
[0056] The fifth technical solution adopted in this invention is:
[0057] A computer program product or computer program includes computer instructions stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium and execute the computer instructions, causing the computer device to perform the aforementioned adaptive JPEG compressed image encryption method.
[0058] The beneficial effect of this invention is that it only requires the user to provide their own initialization key K. init It adaptively generates random number keys required for the encryption scheme based on the content of the JPEG image itself, thereby ensuring that the key for each image to be encrypted is different and improving security. Attached Figure Description
[0059] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following description is provided with accompanying drawings of the relevant technical solutions in the embodiments of the present invention or the prior art. It should be understood that the accompanying drawings described below are only for the purpose of clearly illustrating some embodiments of the technical solutions of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0060] Figure 1 This is a schematic diagram of the encoding components of a JPEG file;
[0061] Figure 2 This is the intended representation of JPEG's standard luminance quantization table and standard chrominance quantization table;
[0062] Figure 3 This is a schematic diagram of pixel block encoding;
[0063] Figure 4 This is an example image of the quantized block contour features;
[0064] Figure 5 This is a comparison chart of the embedding capacity required to encrypt Lena images and the provided embedding capacity;
[0065] Figure 6 This is an overall flowchart of an adaptive JPEG compressed image encryption method provided by the present invention;
[0066] Figure 7 This is a schematic diagram of DC coefficient encryption;
[0067] Figure 8 This is a comparison chart of quantization block scanning methods, in which... Figure 8 (a) is a JPEG scan. Figure 8 (b) shows an S-shaped scan;
[0068] Figure 9This is a diagram illustrating the re-encryption of the DC coefficients;
[0069] Figure 10 This is a schematic diagram of AC coefficient encryption;
[0070] Figure 11 This is a distribution of non-zero AC coefficients in Lena's image.
[0071] Figure 12 There are five plaintext images (first row) and their encrypted images (second row);
[0072] Figure 13 This is a Lena graph encrypted using different combinations of interval factors (α, β); where null represents the absence of β.
[0073] Figure 14 This is a schematic diagram showing the average PSNR values of five images;
[0074] Figure 15 These are encrypted Lena graphs (first row) and encrypted Aerial graphs (second row) under different quality factors;
[0075] Figure 16 It consists of four color plaintext images (first row) and their encrypted images (second row);
[0076] Figure 17 It consists of encrypted Lena and Airplane graphs and their contour attack graphs; where a2)-a4) in the graph represent contour attacks on a1), and b2)-b4) in the graph represent contour attacks on b1).
[0077] Figure 18 This is a diagram illustrating how different encryption schemes defend against contour attacks. Detailed Implementation
[0078] The embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention. The step numbers in the following embodiments are set only for ease of explanation, and there is no limitation on the order between the steps. The execution order of each step in the embodiments can be adaptively adjusted according to the understanding of those skilled in the art.
[0079] In the description of this invention, it should be understood that the orientation descriptions, such as up, down, front, back, left, right, etc., are based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limiting this invention.
[0080] In the description of this invention, "several" means one or more, "more than" means two or more, "greater than," "less than," and "exceeding" are understood to exclude the stated number, while "above," "below," and "within" are understood to include the stated number. The use of "first" and "second" in the description is merely for distinguishing technical features and should not be construed as indicating or implying relative importance, or implicitly indicating the number of indicated technical features, or implicitly indicating the order of the indicated technical features.
[0081] In the description of this invention, unless otherwise explicitly defined, terms such as "set up," "install," and "connect" should be interpreted broadly, and those skilled in the art can reasonably determine the specific meaning of the above terms in this invention in conjunction with the specific content of the technical solution.
[0082] Technical explanation:
[0083] (1) JPEG image structure
[0084] A JPEG image file consists of several coded segments, each of which records different information needed to decode the image. Figure 1 The document describes the details of eight commonly used segments, and Table 1 provides the encoding information and descriptions for each segment. It can be seen that the related information stored between segments cannot be arbitrarily changed. If the image is directly encrypted using existing DES or AES encryption algorithms, the decoder will be unable to recognize the valid segment identifier information of the encrypted image (for example, the segment marker code FFD8 at the beginning of the file becomes FFFF after encryption), and the encrypted image will be unopenable because it destroys the standard file structure.
[0085] Table 1 Common Segment Identifiers and Explanations for JPEG Image Files
[0086]
[0087] (2) Introduction to JPEG Encoding Process
[0088] 2.1) Color space conversion
[0089] Before compressing a digital image, its color channels (RGB channels) need to be converted into luminance and chrominance channels (YUV channels, where Y is the luminance channel and UV is the chrominance channel). Because the human eye is more sensitive to changes in brightness, the chrominance channel UV can be appropriately downsampled to achieve preliminary compression.
[0090] 2.2) Blocking and Point Translation
[0091] After dividing the image with width and height W and height H into non-overlapping pixel blocks of size 8×8, the pixel value in each pixel block needs to be reduced by 128, that is, the range of the original pixel value is changed from [0, 255] to [-128, 127], in order to prepare for the subsequent Discrete Cosine Transform (DCT).
[0092] 2.3) DCT Transformation
[0093] The Discrete Cosine Transform (DCT) transforms pixels from a two-dimensional spatial domain to a frequency domain, which is the core reason for the high compression rate of the JPEG algorithm. Transforming an 8×8 pixel block B(m, n) yields the transformed coefficient matrix Y(u, v). The more energy-intensive (information-rich) parts of the image are concentrated in the low-frequency region at the top left corner of the coefficient matrix, while the less energy-intensive parts are distributed in the high-frequency region at the bottom right corner. Of the 64 coefficients in matrix Y, the coefficient at the top left corner (Y(0, 0)) is called the DC coefficient, and the remaining 63 coefficients are collectively called the AC coefficients.
[0094] 2.4) Quantification
[0095] The coefficient matrix obtained after DCT transformation needs to be further compressed using a quantization table. (JPEG standard luminance quantization table Q...) L and standard colorimetric table Q C like Figure 2 As shown, Figure 2 (a) is the JPEG standard luminance quantization table. Figure 2 (b) shows the standard quantization table. Based on the quality factor QF selected by the user when compressing the image, the quantization table Q(u, v) used for image compression is obtained by solving the provided standard quantization table. Dividing each of the 64 coefficients in the coefficient matrix Y by the corresponding quantization coefficient in the quantization table Q and rounding to the nearest integer yields the final quantization matrix Y to be entropy encoded. q (u, v).
[0096] 2.5) Entropy Coding
[0097] Considering the differences in the number and energy carried by DC and AC coefficients, JPEG employs different encoding strategies for DC and AC coefficients. For DC coefficients, the DC coefficients of all quantized matrices are first extracted, then encoded using Differential Pulse Code Modulation (DPCM) followed by Huffman coding. This leverages the high similarity between local image regions to further reduce the number of encoded bits. For AC coefficients, all AC coefficients of a quantized matrix are arranged into a one-dimensional matrix using a Zig-Zag scan order. Then, using non-zero AC coefficients as the core, several intermediate encoding formats in ZRV form are formed (where V represents a non-zero AC coefficient, R represents the binary encoding length of V, and Z represents the number of consecutive 0 AC coefficients preceding V). Huffman coding is then performed on ZR, and binary coding is performed on V, forming the encoded bitstream of the AC coefficients. For ease of understanding, Figure 3 A brief process for compressed encoding of an 8×8 pixel block with a quality factor (QF) of 85 is given.
[0098] (3) DC coefficient overflow problem
[0099] As mentioned earlier, before performing Huffman coding on the DC coefficients, the DC coefficients of all quantization blocks are pre-extracted and then DPCM encoded. Assuming a JPEG image contains W×H quantization blocks, the DC coefficients of the n quantization blocks (where n = W×H) decoded sequentially from the image bitstream are represented by the set D. The set D is described as follows (note that the decoded DC coefficients are DPCM encoded):
[0100] D={d i |1≤i≤n} (1)
[0101] Where d i The set D represents the DC coefficient of the i-th quantization block. The set D can be obtained by performing inverse DPCM encoding using equation (2). That is, the set of DC coefficients after only quantization.
[0102]
[0103] Quantized DC coefficients (i.e., coefficients Y in each block) q The range of values for (0,0) should be within [d min ,d max Within the interval, where d min and d max The values are as follows: [*] indicates rounding *, and Q(0,0) is the DC quantization coefficient stored in the image file.
[0104]
[0105] If an encryption algorithm encrypts an image, the set of DC coefficients of the encrypted image is... Any DC coefficient d r The value does not satisfy d r ∈[d mun ,d max If this occurs, it is called DC coefficient overflow, and once overflow occurs, this encryption algorithm no longer meets the JPEG standard.
[0106] (4) Contour attack
[0107] Contour attacks primarily exploit the number and positional characteristics of non-zero AC coefficients in a quantized block to construct a pixel block where all pixels are identical, thereby obtaining the contour of the encrypted image. Existing contour attacks mainly fall into three categories: Non-zero AC Coefficients Counting Attack (NCC attack), Energy of AC Coefficients Attack (EAC attack), and Position of Last Non-zero AC Coefficients Attack (PLZ attack). Using A... i Let A represent all AC coefficients of the i-th quantized block decoded from a JPEG image. Then, the set of all AC coefficients of the n quantized blocks of this image can be represented as: A = {A_i} i |1≤i≤n}.
[0108] A i ={a i,r |1≤i≤n,1≤r≤63} (4)
[0109] Where a i,r This represents the AC coefficient of the i-th quantization block at frequency r (Note: An 8×8 pixel block has 64 frequency domains after DCT transformation and Zig-Zag scanning).
[0110] Relevant contour information of a quantization block: NCC(A) i ), EAC(A i ) and PLZ(A i The AC coefficients of this quantization block can be used to describe it. Equations (5) to (7) give the calculation methods for the above three contour features contained in a quantization block, where # represents the number of elements taken. The encryption algorithm must change these three features as much as possible in order to effectively resist contour attacks.
[0111] NCC(A i )=#{a i,r |a i,r ≠0,1≤r≤63}(5)
[0112]
[0113] (5) Choose plaintext attack
[0114] In a recent study, He et al. proposed an attack method to obtain the contour information of an encrypted image by constructing a plaintext image with a similar structure to the encrypted image. Specifically, the specially constructed plaintext image is re-inputted into the encryption system to obtain a new encrypted image. By comparing the constructed plaintext image with the obtained encrypted image, the block scrambling sequence of the original encrypted image can be cracked. The similarity feature utilized in the algorithm is the number of all ZRVs within the quantized block and the sequence of Zs. This feature is represented using NSR (Number of ZRVs And The Sequence of Zero Runs), and the NSR feature of a quantized block is as follows:
[0115] NSR(A i ) = NCC(A i ),{z i,r |a i,r ≠0,1≤r≤63}(8)
[0116] Where z i,r The non-zero AC coefficient a i,r Previously, this referred to the number of consecutive AC coefficients with a value of 0. For ease of understanding, Figure 4 Given a quantization block A i The four types of intra-block features contained after Zig-Zag scanning.
[0117] (6) Information Embedding Problem
[0118] While some research has shown that encryption schemes can achieve good encryption results, they have also revealed new problems. These schemes generate additional auxiliary information during the encryption process for image decryption. However, due to the quality factor used in image compression and the reversible data hiding algorithm used in the encryption scheme, it cannot be guaranteed that all auxiliary information can be embedded when encrypting certain images. This means that these images cannot be encrypted (otherwise, the encrypted image cannot be fully recovered).
[0119] For example, taking Lena images as an example, if the quality factor used during image compression is small, encryption schemes will be unable to encrypt these images. Figure 5In this case, when the quality factor of an image is less than 75 during compression, the information embedding capacity provided by the RDH algorithm used in the encryption scheme is less than the embedding capacity required for encryption, which will result in the inability to encrypt these low-quality factor images.
[0120] Example 1
[0121] like Figure 6 As shown, this embodiment provides an adaptive JPEG compressed image encryption method, including the following steps:
[0122] S1. Obtain the JPEG image and user key K init ;
[0123] S2, Based on the JPEG image and user key K init Adaptive generation of key K DC Key K AC and key K Blk ;
[0124] S3, based on key K DC Generate the first pseudo-random number sequence seq1, based on the key K. AC Generate a second pseudo-random number sequence seq2 based on the key K. Blk Generate the third pseudo-random number sequence seq3;
[0125] S4. Decode the JPEG image to obtain the DC coefficient and AC coefficient;
[0126] S5. Encrypt the DC coefficients according to the first pseudo-random number sequence seq1;
[0127] S6. Encrypt the AC coefficients according to the second pseudo-random number sequence seq2;
[0128] S7. Encode the encrypted DC coefficients and AC coefficients to obtain the encrypted JPEG image.
[0129] The encryption scheme consists of three main parts: For DC coefficients, the sequentially decoded DC coefficients are first subjected to inverse DPCM encoding and S-shaped scanning. Then, DPCM encoding is performed again, and the blocks are divided into several overflow critical intervals. Finally, the coefficients within each overflow critical interval are scrambled to ensure that DC coefficient overflow does not occur during encryption. AC coefficient encryption involves dividing the AC coefficients of all blocks into two parts based on the frequency domain. These two parts are then scrambled and reinserted into their respective blocks. Finally, it can be selected whether to scramble blocks excluding DC coefficients, depending on the situation.
[0130] The following describes each part of the method of this embodiment in detail with reference to the accompanying drawings and specific embodiments.
[0131] (1) Image Adaptive Key Generation
[0132] Chaotic systems are widely used due to their high sensitivity and unpredictability. To address the aforementioned differential attacks and key-sensitive attacks, this embodiment selects the chaotic system of equation (9) as the generator of the chaotic number sequence in order to further generate the pseudo-random number sequence required in the encryption process. Of course, other chaotic systems can also be applied to the scheme in this paper. In this embodiment, the chaotic system only plays the role of providing random sequences.
[0133]
[0134] When the parameter θ∈(0,0.34)∪(0.67,1), the system of equation (9) exhibits chaotic behavior. By giving the initial value of the parameter θ, x θ and y θ Furthermore, by iterating through equation (9) multiple times, a sequence of chaotic numbers of arbitrary length N can be obtained. seq Chaos seq After sorting, the sequence of their original indices is the pseudo-random sequence required for encryption. seq .Depend on Figure 6 As can be seen, this embodiment requires three sets of pseudo-random number sequences: seq1, seq2, and seq3 for encryption. Therefore, three sets of chaotic initial values (θ1, x1, y1), (θ2, x2, y2), and (θ3, x3, y3) are also needed as the initial random number keys. To combat known-plaintext attacks and avoid using the same key for all encrypted images, the three sets of chaotic initial values are used with the user key K. init Parameter generation related to image content. Let Represents n blocks (Blk1, Blk2, ..., Blk) of an image n The sum of the AC coefficients at position r in the frequency domain is given by equation (10). Then the key K used to generate seq1 is... DC As shown in equation (11):
[0135]
[0136] SHA 256 () represents SHA 256 The function, ⊕ represents the XOR operation, K DC The final result is a bit sequence of length 256. Next, let... The number of non-zero AC coefficients in the n blocks of the image at frequency r is represented by equations (12) to (14), and the key K of seq2 is obtained. AC .
[0137]
[0138] Finally, the key K for block scrambling is obtained by combining equations (10) and (12). Blk .
[0139]
[0140] Once the key required for the corresponding pseudo-random number sequence is obtained, the 256 bits of the key (b1, b2, ..., b...) will be... 256 The data is divided into two groups, each with 128 bits. Using equation (17), the number of bits that are "1" in the two bit sequences is used to generate a set of chaotic initial values x. θ and y θ The values θ, where θ is set by the user, are used. It is recommended that the three θ values (θ1, θ2, θ3) be set to be the same. This completes the generation of the initialization keys for the three sets of pseudo-random numbers required in the encryption scheme. As you can see, only the user needs to provide their own initialization key K. init The adaptive key algorithm automatically generates a random key required for the encryption scheme based on the content of the image itself, thereby ensuring that the key for each image to be encrypted is different.
[0141]
[0142] (2) DC coefficient encryption scheme
[0143] As mentioned above, the overflow threshold d of the DC coefficient of a JPEG image min and d max The value of d depends on the DC quantization coefficient in the quantization table used during image compression. By setting the DC quantization coefficient in the quantization table stored in the image to 1, d... min and d max These will become -1024 and 1016 respectively. As long as all coefficients of the encrypted DC coefficient set D after inverse DPCM encoding are within the range of [-1024, 1016], coefficient overflow will not occur. This is because in the JPEG standard luminance quantization table Q... L In the DC quantization coefficient Q L (0,0) and AC quantization coefficient Q L The (0,3) values are the same, so even if the DC quantization coefficient is set to 1 during encryption, Q can still be used when decrypting and restoring the image. L Restore the value of (0,3) Q L (0,0).
[0144] 2.1) Obtain the overflow point of the DC coefficient
[0145] First, an upward overflow threshold UF (Upward Overflow Threshold) and a downward overflow threshold DF (Downward Overflow Threshold) are set for D using an interval factor α (where α∈(0,1]) to ensure that coefficient overflow does not occur after D is encrypted. The values of UF and DF are as follows:
[0146]
[0147] The DC coefficients in D are iterated sequentially, and the sum of all non-negative DC coefficients pos and the sum of negative DC coefficients neg are calculated using equation (19). When the conditions of equation (19) are not met during the iteration, the DC coefficient p is... i This is called the Overflow Point Coefficient (OPC). The location information i of this overflow point coefficient is recorded using the set points. Then, the values of pos and neg are updated using equations (21) and (22) to facilitate the calculation of the next overflow point. By processing D using equations (19) to (22), the locations of all overflow point coefficients in D can be obtained, preparing for the next encryption step. The initial values of pos and neg are both 0.
[0148]
[0149] points = points ∪ i, if pos + d i >UF or neg+d i <LF (20)
[0150] sum = pos + neg + d i (twenty one)
[0151]
[0152]
[0153]
[0154] Based on the DC coefficient position information recorded in the points, D can be divided into several overflow critical intervals (OCIs). Then, a pseudo-random number sequence can be used to scramble the DC coefficients within each OCI. For ease of understanding, Algorithm I provides pseudocode for obtaining the overflow point coefficient set points. Figure 7 A schematic diagram of dividing the OCI based on points is given. Based on the information recorded by the points, the 25 DC coefficients can be divided into 5 OCIs.
[0155] 2.2) Reduce the number of overflow point coefficients.
[0156] from Figure 7 It can be observed that all DC coefficients whose location information is recorded in points are not involved in encryption. To counter currently unknown attacks, it is necessary to minimize the number of OPCs. One of the simplest methods is to change the value of α. A larger α value increases the overflow thresholds UF and DF, and also increases the number of DC coefficients in each OCI, ultimately reducing the number of OPCs. When α is 1, the number of OPCs in D reaches its minimum. Besides changing the value of α, further research and consideration have revealed that the number of OPCs can also be further reduced by changing the scanning method of the quantization blocks.
[0157] The standard JPEG algorithm scans the quantization blocks in a left-to-right, top-to-bottom scanning order (e.g., ...). Figure 8 In the order of (a)), this scanning method fully utilizes the local similarity of the image between quantization blocks in a single row. However, in adjacent rows of quantization blocks, the difference between the quantization block at the end of the previous row and the quantization block at the beginning of the next row is relatively large. This means that the DC coefficient values of these two quantization blocks will differ significantly, which is not conducive to compression during DPCM encoding. Here, we propose using an S-shaped scanning method (such as...) Figure 8 (b) in the diagram scans the quantization block to further utilize image similarity. The decoded DC coefficients from the image are then... (Note that at this time) After being restored to an H×W two-dimensional matrix (through inverse DPCM encoding), it is then re-obtained using an S-shaped scanning method. Next Re-encode DPCM to obtain D s Because it uses an S-shaped scanning method, D s Some of the DC coefficients in D have smaller absolute values than the DC coefficients in D, which helps to reduce the number of overflow points.
[0158] Table 2 shows the number of OPCs generated by two scanning methods under different values of the interval factor α when the Lena grayscale image is compressed with a quality factor QF = 85. After adopting the S-shaped scanning method, the number of OPCs decreased, proving that the proposed S-shaped scanning method is effective.
[0159] Table 2. Number of OPCs under different scanning methods
[0160]
[0161] 2.3) Optimization
[0162] Since encryption targets the DC coefficients within each OCI, even with a further reduction in the number of overflow point coefficients, some DC coefficients will still be excluded from encryption. Here, the values of UF and DF can be updated using the new interval factor β (β>α) and equation (18) to encrypt the set of DC coefficients D after encryption with α. α After further OCI partitioning and encryption, D is obtained. β This allows all coefficients in D to participate in encryption. Figure 9 The use of new UF and DF pairs is given Figure 7 The example shows how the already encrypted DC coefficients are re-encrypted. It can be seen that... Figure 7 The DC coefficients (i.e., -1, 1, -2, 2) that are not involved in encryption are in Figure 9 All of them can participate in encryption, completely solving the problem that some DC coefficients cannot participate in encryption.
[0163] Finally, the proposed DC coefficient encryption scheme does not cause DC coefficient overflow because the encryption targets the DC coefficients within each OCI. When scrambling each OCI, the sum of all non-negative DC coefficients within that OCI is already recorded using pos, and pos ≤ UF ≤ 1024, so there is no overflow. Similarly, there is no underflow. The encryption process for the DC coefficients is summarized as follows:
[0164] 1) Perform inverse DPCM encoding on the DC coefficient set D sequentially decoded from a JPEG image (containing H×W blocks) to obtain...
[0165] 2) After restoring it to an H×W two-dimensional matrix, for S-shaped scan obtained Will Re-encode DPCM to obtain D s .
[0166] 3) First, use the interval factor α and equation (18) to determine the values of the overflow thresholds UF and DF, and then use algorithm I to convert D s The system is divided into several OCIs. Finally, the DC coefficients in each OCI are scrambled using a pseudo-random number sequence to obtain the DC coefficients D after the first encryption. α .
[0167] 4) Using the new interval factor β and equation (18), we obtain UF and DF again, and then use algorithm I to encrypt the D. α Divide the data into several OCIs, and then scramble and encrypt each OCI again to obtain the final encrypted DC coefficient D. β.
[0168] (3) AC coefficient encryption scheme
[0169] When encoding AC coefficients, non-zero AC coefficients are used as the core. The 63 AC coefficients within a block are transformed into an intermediate format of several ZRV structures, and then entropy encoding is performed on each ZRV. In previous studies, it was precisely because arbitrary encryption destroyed the ZRV structure that problems such as increased size of encrypted image files were caused.
[0170] Through observation and research, it can be found that a ZRV contains information about Z+1 AC coefficients, namely one non-zero AC coefficient and Z consecutive AC coefficients with a value of 0. Consider the following scenario: the AC coefficient A of the i-th block of an image... i It contains a ZRV with a large Z value, such as (9 / 1,1), and the AC coefficient A of the j-th (j≠i) block. j If a variable contains three ZRV values with relatively small Z values, such as (0 / 1, 1), (3 / 1, -1), and (4 / 2, 2), then A... i The ZRV in this context can be compared with A. j The three ZRVs in the block are swapped, and neither block causes coefficient overflow after the swap (because the ZRVs involved in the swap record 10 AC coefficients, which is equivalent to equal-length replacement). At the same time, the structure of the original ZRV is preserved, so no bit overhead is added in the entropy coding stage. Inspired by this, an encryption strategy based on scrambling AC coefficient fragments is proposed.
[0171] Given the frequency domain r, all AC coefficients A of a block can be obtained. i Divided into the first part and the later part The two parts, the two AC coefficient segments, are described as follows:
[0172]
[0173] After dividing the AC coefficients of all blocks in an image into two parts according to a given frequency domain r, the first and second halves of the blocks whose AC coefficients at frequency domain r are not zero are extracted and placed into the first scrambling set FSS, respectively. r (FrontScrambled Set) and BackScrambled Set (BSS) r (Back Scrambled Set). FSS r and BSS r The internal coefficient segments are scrambled using pseudo-random numbers and then sequentially reinserted into the corresponding blocks to achieve AC coefficient encryption. Figure 10A schematic diagram is given showing the encryption of the AC coefficients of 6 blocks when the frequency domain r = 10. At this time, only the AC coefficients of three blocks are not zero at the frequency domain r = 10, that is, only three blocks participate in this encryption.
[0174]
[0175] Table 3 also contains statistics. Figure 10 The changes in block characteristics before and after encryption are shown. It can be seen that the characteristics of the three blocks (A2, A4, A6) involved in encryption have changed after encryption. For the blocks that did not participate in encryption (A1, A3, A5), we can similarly classify and encrypt all blocks again by changing the value of the frequency domain r. For example, when r = 2, all blocks except the last block A6 can participate in encryption (note: the blocks participating in encryption must satisfy that the AC coefficient at frequency domain r is not zero).
[0176] Table 3 Block characteristics before and after encryption
[0177]
[0178] If encryption is performed using only one frequency domain value 'r', blocks with AC coefficients equal to 0 at frequency 'r' cannot participate in encryption. Therefore, we can gradually involve all blocks in the image in encryption by taking values from 63 to 1. This is because after DCT transformation, non-zero AC coefficients will be concentrated in the low-frequency region with smaller 'r' values (e.g., ...). Figure 11 As shown in the diagram, the purpose of taking values for r from large to small is to gradually involve more and more blocks in the encryption process, thereby achieving a better scrambling effect. After the AC coefficients have been encrypted, because the characteristics within the blocks have changed, the scrambling of blocks excluding the DC coefficients can be selectively performed, and block scrambling is not always necessary.
[0179] Finally, it is worth noting that encrypting the AC coefficients does not affect the generation of the adaptive key described in Section (1) above, because encrypting the AC coefficients only changes the relative positions of the coefficients within each frequency domain, and the energy within each frequency domain remains unchanged. Number of non-zero AC coefficients Nothing has changed, and the key required for decryption can be completely recovered.
[0180] (4) Experimental Results and Analysis
[0181] To verify the adaptability and effectiveness of the proposed method, this embodiment selected three well-known image databases (containing images of different sizes and contents) as test objects: the USC-SIPI database, the UCID database, and the BOWS-2 database. Five widely used images (Aerial, Airplane, Couple, Lena, Pepper) were selected from the USC-SIPI database for specific analysis and comparison with previous methods. All images used in the experiment were converted to grayscale using the OpenCV library (except for the experiments on color images), and then compressed with a quality factor of 85. Finally, unless otherwise specified, the interval factors α and β were set to 0.5 and 1, respectively, during the encryption process of the DC coefficients.
[0182] 4.1) Visual encryption effect
[0183] For information carriers like images or videos, we acquire information through vision. Therefore, encrypting images or videos inevitably results in significant distortion, resembling a noisy image. Figure 12 Five test images, both plaintext and encrypted, are presented. It can be seen that all images achieve good visual encryption, making it difficult to extract any information related to the original image from the encrypted version. Using Peak Signal-to-Noise Ratio (PSNR) as an indicator of image distortion, all five images also perform well in terms of PSNR.
[0184] a) The influence of interval factor β
[0185] In the proposed DC coefficient encryption scheme, the object of encryption is the DC coefficient in each OCI, so the number of OCIs undoubtedly directly affects the encryption performance. When encryption is performed using only the interval factor α, the larger the value of α, the fewer the number of OCIs in the image, and the better the encryption effect will be. However, even when α = 1, all overflow point coefficients OPC still cannot participate in encryption. Therefore, it is necessary to use a new interval factor β again for encryption so that all DC coefficients can participate in encryption.
[0186] from Figure 13 As can be seen, visually, the difference between the image without interval factor β (first row) and the image with β is indistinguishable to the naked eye. However, there is no doubt that using interval factor β will help reduce the number of OCIs and OPCs. For example, after using β, Figure 7 The five OCIs in Figure 9 The number of OCI scrambling points was increased to three, thus expanding the OCI scrambling space. Furthermore, the number of OPCs decreased from four to two.
[0187] After encryption using β, the PSNR values of the five images all decreased (e.g. Figure 14 As shown in the diagram, it can also be confirmed that using β has a gain effect on encryption. When using interval factor β for encryption, the larger the β value, the better the effect will be. Therefore, it is recommended to set the β value to 1. The value of α is recommended to be set to [0.5, 0.75] so that the multiple OCIs generated by α encryption can be merged into a single OCI for encryption when using β.
[0188] b) The effect of the quality factor QF
[0189] Besides the set interval factors α and β affecting the number of OCIs, the quality factor QF used when compressing the image also influences the number of OCIs. A larger quality factor and a smaller absolute value of the DC coefficient result in more OCIs. Table 4 shows the number of OCIs in the five-image set when α = 1 and without using β. Although the number of OCIs varies significantly when compressing the same image using different quality factors, the proposed DC coefficient encryption scheme can still effectively encrypt images compressed under different quality factors, achieving good encryption results. Figure 15 Even with increased quality factor, the naked eye still cannot extract any information from encrypted images.
[0190] Table 4. Number of OCI values for five images under different quality factors.
[0191]
[0192] Finally, the proposed encryption method can be applied not only to grayscale images but also extended to color images, simply by performing the same encryption operation on each of the three channels (YUV) of the color image. Note that by setting the DC quantization coefficient of the color metric quantization table of the color JPEG image to 1, it can also be recovered using the coefficients in the luminance table (see...). Figure 2 ). Figure 16 The encryption results and PSNR values of four color images after applying the method presented in this paper are given. All color images underwent YUV sampling compression at a ratio of 4:1:1. Visually, the encrypted color images appear to have better distortion reduction.
[0193] 4.2) Format compatibility
[0194] After an image is JPEG encoded, decoding the DC coefficients requires inverse DPCM encoding. If the values of all DC coefficients after inverse DPCM encoding are within [d...] min d maxWithin the range of [-1024, 1016], the encryption algorithm is format-compatible with the DC coefficients. Because the encryption scheme proposed in this paper sets the DC quantization coefficients of the quantization table stored in the image file to 1, regardless of the quality factor QF used during image compression, the legal range of DC coefficient values for all encrypted images becomes [-1024, 1016]. Table 5 compares the DC coefficient overflow cases of our method with those of previous related methods. The method of Li et al. causes DC coefficient overflow to varying degrees due to arbitrarily changing the position of the DC coefficients. However, the methods of this embodiment, He et al., and Qin et al. do not experience DC coefficient overflow.
[0195] Table 5. DC coefficient overflow under different encryption schemes
[0196]
[0197]
[0198] Compared to DC coefficients, AC coefficients only need to ensure that their number within a block does not exceed 63 to be considered format-compatible. This is because the AC coefficient encryption scheme proposed in this paper only changes the relative positions of the 63 coefficients within the frequency domain. The scrambling of the AC coefficient segments in the encrypted block uses equal-length swaps, so it will not cause the number of AC coefficients in any block to exceed 63. Therefore, the AC coefficient encryption scheme is also format-compatible.
[0199] 4.3) File size consistency
[0200] The main factors affecting the file size of JPEG images are the entropy encoding of the DC and AC coefficients. For the AC coefficients, when using block fragment scrambling, the value of the AC coefficient within each fragment remains unchanged, and the intermediate format ZRV for each non-zero AC coefficient maintains consistency before and after encryption. Therefore, theoretically, the proposed AC coefficient encryption scheme should not cause any change in file size. Regarding the DC coefficients, because an S-shaped scanning method is used, further utilizing local image similarity, the absolute value of some DC coefficients will be reduced. Theoretically, this will help reduce file size, and corresponding experimental results confirm the above analysis. Compared with the previous state-of-the-art methods, the scheme in this embodiment also has the advantage of ensuring consistent file size. Table 6 shows the file size changes of five test images under different encryption schemes. Under our scheme, He et al.'s scheme, and Qin et al.'s scheme, the file size of the five images all showed slight changes. However, this is due to the bit alignment mechanism in the JPEG compression algorithm, not a defect in the encryption algorithm.
[0201] To avoid randomness, this embodiment also randomly selected a corresponding number of images from three image databases widely used for image testing to test the proposed scheme. The changes in file size and average PSNR value of the encrypted images are shown in Table 7. It can be found that the file size of the images in all three databases shows a decreasing trend after encryption, which indirectly proves that the S-shaped scanning method proposed above is effective.
[0202] Table 6. Changes in the size of encrypted image files under different encryption schemes.
[0203]
[0204] Table 7 shows the average PSNR value and file size changes across the three databases.
[0205]
[0206]
[0207] 4.4) Algorithm Complexity Analysis
[0208] The encryption scheme of this application comprises three parts: scrambling encryption of DC coefficients, fragment swapping encryption of AC coefficients, and block scrambling encryption. For DC coefficient encryption, firstly, all DC coefficients of the image need to be divided into OCIs using the set overflow thresholds UF and LF. Then, the DC coefficients within each OCI are encrypted using a scrambling sequence. As seen in Algorithm I, the OCI division can be completed by traversing the DC coefficient sequence set D only once; therefore, the time complexity of encrypting DC coefficients is O(DC) = O(N). For AC coefficient encryption, the n blocks of the image need to be divided into two fragment sets at frequency domain r according to conditions. The value range of frequency domain r is [1, 63], so the time complexity of AC coefficient encryption is O(AC) = O(63N). Finally, the n blocks of the image are scrambled using a scrambling sequence, with a time complexity of O(Blk) = O(N). In summary, the overall algorithm time complexity of this embodiment is O(N).
[0209] Table 8 compares the encryption times of different encryption schemes on five test images. The scheme proposed in this paper has the shortest time, followed by the scheme of He et al., while the schemes of Qin and Li have the longest time. In fact, the main time consumption of the schemes proposed in this paper and those of He et al. lies in scrambling the coefficients using a random sequence, as even the algorithmic complexity of obtaining a pseudo-random number sequence using a sorting algorithm is at least O(nlogn). In Qin's scheme, in addition to the pseudo-random number sequence, it is also necessary to predict the DC coefficients and then encrypt the residuals; the AC coefficients also need to be checked for overflow when they are replaced, making the encryption scheme relatively complex. Li's scheme requires pre-coding tests on 16×16 pixel blocks, and whether to further divide the blocks depends on the block encoding length. This is equivalent to performing an extra encoding for each block, and the encryption time is mainly concentrated here. Finally, both Qin's and Li's encryption schemes generate redundant data during the encryption process, requiring the use of an additional RDH algorithm for data embedding, which undoubtedly increases the time consumption of the schemes.
[0210] Table 8 Comparison of encryption time for different encryption schemes
[0211]
[0212] 4.5) Contour attack
[0213] There are three main types of contour attacks: non-zero AC coefficient number attack (NCC attack), AC coefficient energy attack (EAC attack), and last non-zero AC coefficient position attack (PLZ attack). Figure 17 The visual effects of the proposed solution under three types of attacks are presented. Regardless of the type of attack, the method in this embodiment can successfully resist it and has sufficient security.
[0214] Since the AC coefficient encryption scheme can effectively change the intra-block features of each block in the image, the proposed scheme can still resist contour attacks without using block scrambling, which also proves the superiority of the proposed scheme. Figure 18 This demonstrates how our method compares to previous state-of-the-art methods in resisting contour attacks (none of the three methods use block scrambling). For ease of observation, the DC coefficients of all encrypted Lena images are set to 0. Experiments show that all three schemes achieve good visual encryption results without block scrambling (e.g., ...). Figure 18As shown in the first column. In He's scheme, the ZRVs extracted from the block are divided into several categories based on run length. After scrambling each category, they are put back into each block. This changes the EAC of each block, but the NCC and PLZ remain unchanged. Similarly, in Qin's scheme, a set threshold number of ZRVs are extracted from each block, scrambled, and then put back. When an overflow occurs, a new block is searched and the overflowing ZRVs are put back. Although the EAC of each block changes, the number of overflowing blocks is very small (experiments showed only about a dozen blocks), and the NCC and PLZ of most blocks remain unchanged. In summary, in He's and Qin's schemes, without block scrambling, the encrypted image has only some resistance to EAC attacks, but is completely defenseless against NCC and PLZ attacks.
[0215] Example 2
[0216] This embodiment provides an adaptive JPEG compressed image encryption device, comprising:
[0217] Image input module, used to acquire JPEG images and user key K init ;
[0218] The key generation module is used to generate a key based on a JPEG image and the user key K. init Adaptive generation of key K DC Key K AC and key K Blk ;
[0219] The random sequence generation module is used to generate random sequences based on the key K. DC Generate the first pseudo-random number sequence seq1, based on the key K. AC Generate a second pseudo-random number sequence seq2 based on the key K. Blk Generate the third pseudo-random number sequence seq3;
[0220] The image decoding module is used to decode JPEG images to obtain DC and AC coefficients;
[0221] The DC encryption module is used to encrypt the DC coefficients based on the first pseudo-random number sequence seq1.
[0222] The AC encryption module is used to encrypt the AC coefficients based on the second pseudo-random number sequence seq2.
[0223] The image encoding module is used to encode the encrypted DC coefficients and AC coefficients to obtain an encrypted JPEG image.
[0224] Since this device is an adaptive JPEG compressed image encryption device according to an embodiment of the present invention, and the principle of the device in solving the problem is similar to that of the method, the implementation of this device can refer to the implementation process of the above method embodiment, and the repeated parts will not be described again.
[0225] Example 3
[0226] This invention also provides an electronic device, which includes a processor and a memory. The memory stores at least one instruction, at least one program, a code set, or an instruction set. The at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to achieve the following: Figure 6 This illustrates an adaptive JPEG compressed image encryption method.
[0227] It is understood that the memory may include random access memory (RAM) or read-only memory. Optionally, the memory may include non-transitory computer-readable storage medium. The memory can be used to store instructions, programs, code, code sets, or instruction sets. The memory may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for at least one function, instructions for implementing the various method embodiments described above, etc.; the stored data area may store data created according to the use of the server, etc.
[0228] A processor may include one or more processing cores. The processor connects to various parts of the server via various interfaces and lines, executing instructions, programs, code sets, or instruction sets stored in memory, and accessing data stored in memory to perform various server functions and process data. Optionally, the processor may be implemented using at least one of the following hardware forms: Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor may integrate one or more of the following: Central Processing Unit (CPU) and Modem. The CPU primarily handles the operating system and applications; the modem handles wireless communication. It is understood that the modem may also be implemented as a separate chip without being integrated into the processor.
[0229] Since this electronic device is the electronic device corresponding to the adaptive JPEG compressed image encryption method of this invention, and the principle of solving the problem by this electronic device is similar to that of this method, the implementation of this electronic device can refer to the implementation process of the above method embodiment, and the repeated parts will not be described again.
[0230] Example 4
[0231] This invention also provides a computer-readable storage medium storing at least one instruction, at least one program, a code set, or an instruction set, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to achieve the following: Figure 6 This illustrates an adaptive JPEG compressed image encryption method.
[0232] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-Erasable Programmable Read-Only Memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.
[0233] Since this storage medium is the storage medium corresponding to an adaptive JPEG compressed image encryption method in this embodiment of the invention, and the principle of this storage medium in solving the problem is similar to that of this method, the implementation of this storage medium can refer to the implementation process of the above method embodiment, and the repeated parts will not be described again.
[0234] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0235] The above embodiments are merely illustrative of the technical concept and features of the present invention, and are intended to enable those skilled in the art to understand the content of the present invention and implement it accordingly. They should not be construed as limiting the scope of protection of the present invention. All equivalent changes or modifications made based on the essence of the content of the present invention should be covered within the scope of protection of the present invention.
Claims
1. An adaptive JPEG compressed image encryption method, characterized in that, Includes the following steps: Obtain JPEG image and user key ; Based on the JPEG image and user key Adaptive key generation Key and key ; According to the key Generate the first pseudo-random number sequence According to the key Generate the second pseudo-random number sequence According to the key Generate a third pseudo-random number sequence ; Decode the JPEG image to obtain the DC coefficients and AC coefficients; Based on the first pseudo-random number sequence Encrypt the DC coefficients; Based on the second pseudo-random number sequence Encrypt the AC coefficients; Encode the encrypted DC and AC coefficients to obtain the encrypted JPEG image; The JPEG image and user key Adaptive key generation Key and key ,include: make Representing an image blocks ( , , ... , In the frequency domain The AC coefficient energy at the location is obtained by the following method to obtain the key. : make Representing an image Each block is in the frequency domain The number of non-zero AC coefficients at a given point is obtained by obtaining the key in the following way. : Obtain the key in the following ways : In the formula, express The function, ⊕ represents the XOR operation.
2. The adaptive JPEG compressed image encryption method according to claim 1, characterized in that, According to the key Generate the first pseudo-random number sequence According to the key Generate the second pseudo-random number sequence According to the key Generate a third pseudo-random number sequence ,include: According to the key Get the initial value of chaos ( , , ), based on the key Get the initial value of chaos ( , , ), based on the key Get the initial value of chaos ( , , );in , , This is the default value; The chaotic system is used to iterate the initial chaotic value multiple times to obtain an arbitrary length of... Chaotic number sequence ; For chaotic number sequences After sorting, the sequence of their original indices is the pseudo-random sequence required for encryption; the three chaotic initial values correspond to three pseudo-random number sequences respectively; in, and , It can be obtained through the following methods: After obtaining the key required for the corresponding pseudo-random number sequence, the 256 bits of the key ( , , ..., The data is divided into two groups, each containing 128 bits. The following formula is used to sequentially generate a set of initial chaotic values, using the number of "1" bits in each group. and value, 。 3. The adaptive JPEG compressed image encryption method according to claim 1, characterized in that, The first pseudo-random number sequence Encrypting the DC coefficients includes: The set of DC coefficients decoded sequentially from JPEG images Perform inverse DPCM encoding to obtain ; Will After restoring to a two-dimensional matrix, for S-shaped scan obtained ,Will Re-encode DPCM to obtain ; Using interval factors Determine the overflow threshold and The value, then Divide the data into several overflow critical intervals (OCI), and use the first pseudo-random number sequence. The DC coefficients in each overflow critical interval OCI are scrambled to obtain the encrypted set of DC coefficients. ; Using new interval factors The overflow threshold is obtained again. and encrypt again The system is divided into several overflow critical intervals (OCI), and then each overflow critical interval (OCI) is scrambled and encrypted again to obtain the DC coefficient set. ;in, .
4. The adaptive JPEG compressed image encryption method according to claim 3, characterized in that, Using interval factors Determined upward overflow threshold and downward overflow threshold The expression is as follows: in, , This indicates that the number is rounded down.
5. The adaptive JPEG compressed image encryption method according to claim 1, characterized in that, The second pseudo-random number sequence Encrypting the AC coefficients includes: Given frequency domain The AC coefficients of all blocks in an image are calculated according to a given frequency domain. Divided into two parts; In the frequency domain Extract the first and second halves of blocks where the AC coefficient is not 0, and place them into the first scrambled set respectively. and rear scramble set ; Scramble the front part and rear scramble set The internal coefficient fragments utilize a second pseudo-random number sequence. After being scrambled separately, the corresponding blocks are put back in sequence to encrypt the AC coefficients.
6. The adaptive JPEG compressed image encryption method according to claim 5, characterized in that, The second pseudo-random number sequence The steps for encrypting AC coefficients also include the following: After placing the scrambled fragment back into the corresponding block, according to the third pseudo-random number sequence Perform block scrambling.
7. An adaptive JPEG compressed image encryption device, characterized in that, include: Image input module, used to acquire JPEG images and user keys. ; The key generation module is used to generate a key based on a JPEG image and a user key. Adaptive key generation Key and key ; The random sequence generation module is used to generate random sequences based on the key. Generate the first pseudo-random number sequence According to the key Generate the second pseudo-random number sequence According to the key Generate a third pseudo-random number sequence ; The image decoding module is used to decode JPEG images to obtain DC and AC coefficients; The DC encryption module is used to determine the first pseudo-random number sequence. Encrypt the DC coefficients; The AC encryption module is used to determine the second pseudo-random number sequence. Encrypt the AC coefficients; The image encoding module is used to encode the encrypted DC coefficients and AC coefficients to obtain an encrypted JPEG image; The JPEG image and user key Adaptive key generation Key and key ,include: make Representing an image blocks ( , , ... , In the frequency domain The AC coefficient energy at the location is obtained by the following method to obtain the key. : make Representing an image Each block is in the frequency domain The number of non-zero AC coefficients at a given point is obtained by obtaining the key in the following way. : Obtain the key in the following ways : In the formula, express The function, ⊕ represents the XOR operation.
8. An electronic device, characterized in that, The electronic device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set, or an instruction set, and the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to implement the method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The storage medium stores at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
JPEG image encryption method compatible in format and invariant in size
CN107578452A
JPEG (Joint Photographic Experts Group) image high-precision reservation thumbnail encryption method
CN115630390A