Adaptive JPEG (Joint Photographic Experts Group) compressed image encryption method and device, equipment and medium

The DC coefficients and AC coefficients of JPEG images are encrypted through adaptive generation of keys and pseudo-random number sequences, which solves the problem that images under low-quality factors cannot be encrypted and are vulnerable to selected plaintext attacks in the prior art, and achieves efficient and secure JPEG image encryption.

CN119653024AActive Publication Date: 2025-03-18SOUTH CHINA UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411798250.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-09
Publication Date
2025-03-18
Estimated Expiration
2044-12-09

AI Technical Summary

Technical Problem

While maintaining format compatibility and file size consistency, existing JPEG image encryption schemes have problems that cannot encrypt images under low quality factors and are vulnerable to selected plaintext attacks.

Method used

Adaptive JPEG compressed image encryption method is adopted to obtain the JPEG image and user key, and adaptively generate the key, generate a pseudo-random number sequence to encrypt the DC coefficient and AC coefficient, and encode the encrypted coefficients to generate the encrypted JPEG image.

Benefits of technology

The security of encrypted images is achieved without destroying the consistency of file format and file size, avoiding the problem that images under low-quality factors cannot be encrypted, and improving the resistance to plaintext attacks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119653024A_ABST
    Figure CN119653024A_ABST
Patent Text Reader

Abstract

The invention discloses a self-adaptive JPEG (Joint Photographic Experts Group) compressed image encryption method and device, equipment and a medium. The method comprises the following steps: acquiring a JPEG image and a user key Kinit; according to the JPEG image and a user secret key Kinit, three secret keys are generated in a self-adaptive mode; generating three pseudo-random number sequences according to the three keys; decoding the JPEG image to obtain a DC (Direct Current) coefficient and an AC (Alternating Current) coefficient; encrypting the DC coefficient according to the first pseudo-random number sequence; encrypting the AC coefficient according to the second pseudo random number sequence; and encoding the encrypted DC coefficient and AC coefficient to obtain an encrypted JPEG image. According to the invention, the user only needs to provide the own initialization key Kinit, and the random number key required in the encryption scheme is adaptively generated according to the own content of the JPEG image, so that the key of each to-be-encrypted image is ensured to be different, and the security is improved. The method can be widely applied to the field of image information security.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image information security, and in particular to an adaptive JPEG compression image encryption method, device, equipment and medium. Background Art

[0002] Thanks to the rapid development of Internet technology and the increase in mobile bandwidth, people have gradually realized the transformation of information exchange from text to voice, image, video and other Internet information carriers by using convenient and fast networks. JPEG images are widely used in various digital mobile devices, such as mobile phones and digital cameras, which are stored in JPEG format by default. The research on the security and privacy protection of JPEG images, especially some high-value images such as military maps, medical images, personal files, etc., has also attracted many scholars.

[0003] The best solution to this problem is to encrypt JPEG images directly. In past studies, many encryption schemes for JPEG compressed images have been proposed. The problems in these encryption schemes can be roughly divided into two categories: one is that the correlation between the coefficients of the file data part is destroyed, resulting in an increase in the size of the encrypted image file; the other is that the relevant grammatical components of the file are destroyed, resulting in the inability to completely restore or decode the file. At present, in the most advanced research work, the encryption algorithm for JPEG format images can achieve good results in terms of format compatibility of the encrypted image and consistency of file size before and after encryption, but it also produces problems such as being unable to encrypt images with low quality factors and being vulnerable to chosen plaintext attacks. Summary of the invention

[0004] In order to solve at least one of the technical problems existing in the prior art to a certain extent, the present invention aims to provide an adaptive JPEG compression image encryption method, device, equipment and medium.

[0005] The first technical solution adopted by the present invention is:

[0006] An adaptive JPEG compressed image encryption method comprises the following steps:

[0007] Get the JPEG image and user key K init ;

[0008] According to the JPEG image and the user key K init Adaptively generate the key K DC , key K AC and key K Blk ;

[0009] According to the key K DC Generate a first pseudo-random number sequence seq1, according to the key KAC Generate a second pseudo-random number sequence seq2, according to the key K Blk Generate a third pseudo-random number sequence seq3;

[0010] Decode the JPEG image to obtain the DC coefficient and AC coefficient;

[0011] Encrypting the DC coefficient according to a first pseudo-random number sequence seq1;

[0012] Encrypting the AC coefficients according to a second pseudo-random number sequence seq2;

[0013] The encrypted DC coefficient and AC coefficient are encoded to obtain an encrypted JPEG image.

[0014] Further, the JPEG image and the user key K init Adaptively generate the key K DC , key K AC and key K Blk ,include:

[0015] make n blocks (Blk1, Blk2, ..., Blk n ) is the AC coefficient energy sum at position r in the frequency domain, and the key K is obtained by the following method DC :

[0016]

[0017] make The number of non-zero AC coefficients of n blocks of the image at frequency domain r is represented by the key K obtained by AC :

[0018]

[0019] The key K is obtained by Blk :

[0020]

[0021] In the formula, SHA 256 () indicates SHA 256 Function, ⊕ represents the XOR operation.

[0022] Further, the key K DC Generate a first pseudo-random number sequence seq1, according to the key K AC Generate a second pseudo-random number sequence seq2, according to the key K Blk Generate a third pseudo-random number sequence seq3, including:

[0023] According to the key K DC Get the initial value of chaos (θ1, x1, y1), according to the key K AC Get the initial value of chaos (θ2, x2, y2), according to the key K Blk Get the initial value of chaos (θ3, x3, y3); where θ1, θ2, θ3 are preset values;

[0024] The chaotic system is used to iterate the chaotic initial value multiple times to obtain a chaotic number sequence chaos with an arbitrary length of N. seq ;

[0025] For the chaotic number sequence chaos seq After sorting, the sequence composed of the original serial numbers is the pseudo-random sequence required for encryption; the three chaotic initial values ​​correspond to three pseudo-random number sequences respectively;

[0026] Among them, x j and j Obtained through:

[0027] After obtaining the key required by the corresponding pseudo-random number sequence, the 256 bits of the key (b1, b2, ..., b 256 ) is divided into two groups, each with 128 bits. The following formula is used to sequentially convert the number of bits "1" in the two groups of bit sequences into the number of x in a set of chaotic initial values: θ and θ value,

[0028]

[0029] Further, the encrypting the DC coefficient according to the first pseudo-random number sequence seq1 includes:

[0030] The DC coefficient set D decoded from the JPEG image is inversely DPCM-encoded to obtain

[0031] Will After restoring to a two-dimensional matrix, Perform an S-type scan to obtain Will Re-encode DPCM to get D s ;

[0032] Use the interval factor α to determine the overflow threshold UF and DF, and then set D s The DC coefficients in each overflow critical interval OCI are scrambled using the first pseudo-random number sequence seq1 to obtain an encrypted DC coefficient set D α ;

[0033] Using the new interval factor β, we can get the overflow threshold UF and DF again, and then convert the encrypted D α Divide it into several overflow critical intervals OCI, and then scramble and encrypt each overflow critical interval OCI again to obtain the DC coefficient set D β ; where β>α.

[0034] Furthermore, the expressions of the overflow threshold UF and the overflow threshold DF determined by the interval factor α are as follows:

[0035]

[0036] Among them, α∈(0,1], Indicates rounding a number down.

[0037] Further, encrypting the AC coefficient according to the second pseudo-random number sequence seq2 includes:

[0038] Given a frequency domain r, the AC coefficients of all blocks of an image are divided into two parts according to the given frequency domain r;

[0039] The front fragment and the second half of the block whose AC coefficient is not 0 at frequency domain r are extracted and put into the front scrambling set FSS respectively. r (Front Scrambled Set) and Back Scrambled Set BSS r (Back Scrambled Set);

[0040] Set the front scrambled set FSS r and the back scrambling set BSS r The internal coefficient fragments are scrambled respectively using the second pseudo-random number sequence seq2 and then put back into the corresponding blocks in sequence to achieve encryption of the AC coefficients.

[0041] Furthermore, the step of encrypting the AC coefficients according to the second pseudo-random number sequence seq2 further includes the following steps:

[0042] After the scrambled segments are put back into the corresponding blocks, block scrambling is performed according to the third pseudo-random number sequence seq3.

[0043] The second technical solution adopted by the present invention is:

[0044] An adaptive JPEG compressed image encryption device, comprising:

[0045] Image input module, used to obtain JPEG image and user key K init ;

[0046] The key generation module is used to generate a key based on the JPEG image and the user key Kinit Adaptively generate the key K DC , key K AC and key K Blk ;

[0047] The random sequence generation module is used to generate a random sequence according to the key K DC Generate a first pseudo-random number sequence seq1, according to the key K AC Generate a second pseudo-random number sequence seq2, according to the key K Blk Generate a third pseudo-random number sequence seq3;

[0048] An image decoding module is used to decode a JPEG image to obtain a DC coefficient and an AC coefficient;

[0049] A DC encryption module, used for encrypting a DC coefficient according to a first pseudo-random number sequence seq1;

[0050] An AC encryption module, used for encrypting AC coefficients according to a second pseudo-random number sequence seq2;

[0051] The image encoding module is used to encode the encrypted DC coefficient and AC coefficient to obtain an encrypted JPEG image.

[0052] The third technical solution adopted by the present invention is:

[0053] An electronic device comprises 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, 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 by the present invention is:

[0055] A computer-readable storage medium 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 a processor to implement an adaptive JPEG compressed image encryption method as described above.

[0056] The fifth technical solution adopted by the present invention is:

[0057] A computer program product or a computer program, the computer program product or the computer program includes computer instructions, the computer instructions are 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 the processor executes the computer instructions, so that the computer device executes the above-mentioned adaptive JPEG compression image encryption method.

[0058] The beneficial effect of the present invention is that the present invention only requires the user to provide his own initialization key K init , adaptively generates the random number key required in the encryption scheme according to the content of the JPEG image itself, so as to ensure that the key of each image to be encrypted is different, thereby improving security. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the embodiments of the present invention or the drawings of related technical solutions in the prior art are introduced below. It should be understood that the drawings introduced below are only for the convenience of clearly describing 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 work.

[0060] Figure 1 This is a schematic diagram of the JPEG file encoding composition;

[0061] Figure 2 It is the standard brightness quantization table and standard chromaticity quantization representation of JPEG;

[0062] Figure 3 It is a schematic diagram of pixel block encoding;

[0063] Figure 4 is an example graph of quantized block contour features;

[0064] Figure 5 It is a comparison chart of the embedding capacity required and the provided embedding capacity when the Lena image is encrypted;

[0065] Figure 6 It is an overall flow chart of an adaptive JPEG compression image encryption method provided by the present invention;

[0066] Figure 7 This is a schematic diagram of DC coefficient encryption;

[0067] Figure 8 is a comparison chart of quantization block scanning methods, where: Figure 8 (a) is a JPEG scan. Figure 8 (b) is an S-shaped scan;

[0068] Fig. 9This is a schematic diagram of the DC coefficient being encrypted again;

[0069] Fig.10 This is a schematic diagram of AC coefficient encryption;

[0070] Fig.11 The distribution of non-zero AC coefficients of Lena image

[0071] Fig.12 There are five plaintext images (first row) and their encrypted images (second row);

[0072] Fig.13 is a Lena graph encrypted using different combinations of interval factors (α, β); where null means β is not used;

[0073] Fig.14 It is a schematic diagram of the average PSNR values ​​of five images;

[0074] Fig.15 The encrypted Lena graph (first row) and the encrypted Aerial graph (second row) under different quality factors;

[0075] Fig.16 There are four colored plaintext images (first row) and their encrypted images (second row);

[0076] Fig.17 These are the encrypted Lena graph and Airplane graph and their contour attack graphs; a2)-a4) in the graph attack the contour of a1) in the graph, and b2)-b4) in the graph attack the contour of b1) in the graph;

[0077] Fig.18 It is a schematic diagram of how different encryption schemes resist contour attacks. DETAILED DESCRIPTION

[0078] The embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and are not to be construed as limitations of the present invention. For the step numbers in the following embodiments, they are only provided for the convenience of explanation, and the order between the steps is not limited in any way, and the execution order of each step in the embodiment can be adaptively adjusted according to the understanding of those skilled in the art.

[0079] In the description of the present invention, it should be understood that descriptions involving orientations, such as up, down, front, back, left, right, etc., and orientations or positional relationships indicated are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present invention.

[0080] In the description of the present invention, "several" means one or more, "more" means more than two, "greater than", "less than", "exceed" etc. are understood as not including the number itself, and "above", "below", "within" etc. are understood as including the number itself. If there is a description of "first" or "second", it is only used for the purpose of distinguishing the technical features, and cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.

[0081] In the description of the present invention, unless otherwise clearly defined, terms such as setting, installing, connecting, etc. should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in the present invention based on the specific content of the technical solution.

[0082] Technical explanation:

[0083] (1) JPEG image structure

[0084] A JPEG image file consists of several coding segments, each of which records different information required to decode the image. Figure 1 The detailed information of the eight commonly used segments is described, and the encoding information and description of each segment are given in Table 1. It can be seen that the relevant information stored between the segments cannot be changed at will. If the image is directly encrypted using the existing DES or AES encryption algorithm, the decoder will not be able to recognize the legal segment identification information of the encrypted image (for example, the segment marker code FFD8 of the file start segment becomes FFFF after encryption), and the encrypted image will not be able to be opened because the standard file structure is destroyed.

[0085] Table 1 Common segment identifiers and descriptions of JPEG image files

[0086]

[0087] (2) Introduction to JPEG encoding process

[0088] 2.1) Color space conversion

[0089] Before compressing a digital image, the color channel (RGB channel) of the digital image needs to be converted into brightness and chroma channels (YUV channels, where Y is the brightness channel and UV is the chroma channel). Because the human eye is more sensitive to changes in brightness, the chroma channel UV can be appropriately downsampled to achieve the purpose of preliminary compression.

[0090] 2.2) Block division and point translation

[0091] After dividing the image with a width of W and a height of H into non-overlapping pixel blocks of size 8×8, it is necessary to subtract 128 from the pixel values ​​in each pixel block, that is, to change the range of the original pixel values ​​from [0, 255] to [-128, 127], in order to prepare for the subsequent discrete cosine transform (DCT).

[0092] 2.3) DCT transform

[0093] Using discrete cosine transform, pixels can be transformed from a two-dimensional spatial domain to a frequency domain, which is also the core of the JPEG algorithm's high compression rate. After transforming an 8×8 pixel block B(m,n), the transformed coefficient matrix Y(u,v) can be obtained. At this time, the part with larger image energy (carrying more information) will be concentrated in the low-frequency area in the upper left corner of the coefficient matrix, while the part with smaller energy is distributed in the high-frequency area in the lower right corner. Among the 64 coefficients of matrix Y, the coefficient in the upper left corner, that is, Y(0,0) is called the DC coefficient, and the remaining 63 coefficients are collectively called AC coefficients.

[0094] 2.4) Quantification

[0095] The coefficient matrix obtained after DCT transformation needs to be further compressed using the quantization table. The standard brightness quantization table Q of JPEG L and standard colorimetric quantification table Q C like Figure 2 As shown, Figure 2 (a) is the JPEG standard brightness quantization table. Figure 2 (b) is the standard chromaticity quantization table. According to the quality factor QF selected by the user when compressing the image, the quantization table Q(u, v) used when compressing the image is solved according to the provided standard quantization table. The 64 coefficients in the coefficient matrix Y are divided by the quantization coefficients of the corresponding positions in the quantization table Q and rounded to the nearest integer to obtain the final quantization matrix Y to be entropy encoded. q (u, v).

[0096] 2.5) Entropy Coding

[0097] Taking into account the different numbers of DC coefficients and AC coefficients and the different energies they carry, JPEG adopts different encoding strategies for DC coefficients and AC coefficients. For DC coefficients, first extract the DC coefficients of all quantized matrices, use Differential Pulse Code Modulation (DPCM) encoding, and then Huffman encode them. This takes advantage of the high similarity between local areas of the image to further reduce the coding bits. For AC coefficients, all AC coefficients of a quantized matrix are arranged in a one-dimensional matrix using Zig-Zag scanning order, and then several ZRV intermediate coding formats are formed with non-zero AC coefficients as the core (where V represents a non-zero AC coefficient, R represents the binary coding length of V, and Z represents the number of AC coefficients with consecutive values ​​of 0 before V), Huffman encode ZR, and binary encode V to form a coded bit stream of AC coefficients. For ease of understanding, Figure 3 A brief compression coding process of an 8×8 pixel block with a quality factor QF of 85 is given.

[0098] (3) DC coefficient overflow problem

[0099] As mentioned above, before Huffman coding the DC coefficient, the DC coefficients of all quantized blocks are extracted for DPCM coding. Assuming that the number of quantized blocks contained in a JPEG image is W×H, the DC coefficients of n (where n=W×H) quantized blocks decoded sequentially from the image bit stream are represented by set D, and set D is described as follows (note that the decoded DC coefficients are DPCM-coded at this time):

[0100] D={d i |1≤i≤n} (1)

[0101] where d i represents the DC coefficient of the i-th quantized block. By using formula (2) to perform inverse DPCM coding on the set D, we can obtain the set That is, it is only a set of DC coefficients that have been quantized.

[0102]

[0103] The quantized DC coefficient (i.e., the coefficient Y in each block) q The value range of (0,0)) should be [d min ,d max ] interval, where d min and d max The values ​​of are as follows, [*] means 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 DC coefficient set of the encrypted image Any DC coefficient d r The value does not satisfy d r ∈[d mun ,d max ], it is called DC coefficient overflow, and once overflow occurs, the encryption algorithm does not meet the JPEG standard.

[0106] (4) Contour attack

[0107] Contour attack mainly uses the number and position characteristics of non-zero AC coefficients in the quantized block to construct a pixel block with all the same pixels, so as to obtain the contour of the encrypted image. There are three main types of existing contour attacks, namely, non-zero AC coefficients counting attack (NCC attack), AC coefficient energy attack (EAC attack), and the last non-zero AC coefficient position attack (PLZ attack). i represents all AC coefficients of the i-th quantized block decoded from the JPEG image, then the set of all AC coefficients of the n quantized blocks of this image can be expressed as: A = {A i |1≤i≤n}.

[0108] A i ={a i,r |1≤i≤n,1≤r≤63} (4)

[0109] where a i,r Represents the AC coefficient of the i-th quantized block at frequency domain r (Note: an 8×8 pixel block has 64 frequency domains after DCT transformation and Zig-Zag scanning).

[0110] Related profile information of a quantized block: NCC (A i )、EAC(A i ) and PLZ(A i ), which can be described by the AC coefficients of this quantization block. Equations (5) to (7) give the calculation method of the above three contour features contained in a quantization block, where # represents the number of elements. The encryption algorithm must change these three features as much as possible to effectively resist contour attacks.

[0111] NCC(A i )=#{a i,r |a i,r ≠0,1≤r≤63}(5)

[0112]

[0113] (5) Chosen Plaintext Attack

[0114] In recent research, He et al. proposed an attack method to obtain the contour information of the encrypted image by constructing a plaintext image with a similar structure to the encrypted image. Specifically, the specially constructed plaintext image is re-input into the encryption system to obtain a new encrypted image. The block scrambling sequence of the original encrypted image is cracked by comparing the constructed plaintext image with the obtained encrypted image. The similarity feature used in the algorithm is the number of all ZRVs in the quantization block and the sequence of Z in it. This feature is represented by NSR (Number of ZRVs And The Sequence of Zero Runs). The NSR feature of a quantization 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 Represents a non-zero AC coefficient a i,r Before, the number of consecutive AC coefficients with a value of 0. For ease of understanding, Figure 4 Given a quantized block A i After Zig-Zag scanning, it contains the above four block features.

[0117] (6) Information Embedding Problem

[0118] In some research works, although the encryption scheme can achieve good encryption effect, it also exposes some new problems, that is, these encryption schemes will generate some additional auxiliary information for decrypting images during the encryption process. However, due to the quality factor used when compressing the image itself and the reversible data hiding algorithm used in the encryption scheme, when encrypting some images, it cannot be guaranteed that all auxiliary information can be embedded, which means that these images cannot be encrypted (otherwise the encrypted images cannot be fully restored).

[0119] For example, taking the Lena images as an example, if the quality factor used when compressing the images is small, the encryption scheme will not be able to encrypt these images. Figure 5In the present invention, 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 during 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, comprising the following steps:

[0122] S1. Get JPEG image and user key K init ;

[0123] S2, based on the JPEG image and user key K init Adaptively generate the key K DC , key K AC and key K Blk ;

[0124] S3, according to the key K DC Generate a first pseudo-random number sequence seq1, according to the key K AC Generate a second pseudo-random number sequence seq2, according to the key K Blk Generate a third pseudo-random number sequence seq3;

[0125] S4, decoding the JPEG image to obtain a DC coefficient and an AC coefficient;

[0126] S5, encrypting the DC coefficient 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 coefficient and AC coefficient to obtain an encrypted JPEG image.

[0129] The encryption scheme consists of three main parts: For the DC coefficient, the decoded DC coefficients are firstly subjected to inverse DPCM coding and S-type scanning, then re-DPCM coding and divided into several overflow critical intervals, and finally the coefficients within each overflow critical interval are scrambled to ensure that the DC coefficient does not overflow during encryption. AC coefficient encryption includes dividing the AC coefficients of all blocks into two parts according to the frequency domain, and then scrambling the two parts and putting them back into the corresponding blocks. Finally, it can be selected whether to perform block scrambling exclusive of DC coefficients according to the situation.

[0130] The following is a detailed description of each part of the method of this embodiment in conjunction with the accompanying drawings and specific implementation methods.

[0131] (1) Image-adaptive key generation

[0132] Chaotic systems are widely used because of their high sensitivity and unpredictability. To deal with the above-mentioned differential attacks and key-sensitive attacks, this embodiment selects the chaotic system of formula (9) as the generator of chaotic number sequences, so as to further generate the pseudo-random number sequences required in the encryption process. Of course, other chaotic systems can also be applied to the scheme of this article. 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 chaos. By giving the initial value parameter θ, x θ and θ And by iterating formula (9) multiple times, we can obtain a chaotic number sequence chaos with any length N seq . seq After sorting, the sequence of its original serial numbers is the pseudo-random sequence random required for encryption. seq .Depend on Figure 6 It can be seen that in this embodiment, three sets of pseudo-random number sequences are required: seq1, seq2, and seq3 for encryption, so three sets of chaotic initial values ​​(θ1, x1, y1), (θ2, x2, y2), and (θ3, x3, y3) are also required as random number initial keys. In order to resist known plaintext attacks and avoid all encrypted images being encrypted with the same key, the three sets of chaotic initial values ​​are encrypted by the user key K init Parameters related to image content are generated. n blocks (Blk1, Blk2, ..., Blk n ) is the AC coefficient energy sum at position r in the frequency domain, that is, equation (10). Then the key K used to generate seq1 DC As shown in formula (11):

[0135]

[0136] Where SHA 256 () indicates SHA 256 function, ⊕ represents XOR operation, K DC The final result is a bit sequence of length 256. Then let The number of non-zero AC coefficients of n blocks of the image at frequency domain 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 equation (10) and equation (12): Blk .

[0139]

[0140] After obtaining the key required by the corresponding pseudo-random number sequence, the 256 bits of the key (b1, b2, ..., b 256 ) is divided into two groups, each with 128 bits. The number of bits with "1" in the two groups of bit sequences is used to generate a set of chaotic initial values ​​x using formula (17). θ and θ The value of θ is set by the user. It is recommended that the three θ values ​​(θ1, θ2, θ3) be set to the same. At this point, the initialization keys of the three sets of pseudo-random numbers required in the encryption scheme are generated. It can be seen that the user only needs to provide his own initialization key K init ,The adaptive key algorithm will automatically generate the random number key required in 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] From the above, we can see that the overflow threshold d of the DC coefficient of a JPEG image is min and d max The value of depends on the DC quantization coefficient in the quantization table used when compressing the image. By setting the DC quantization coefficient in the quantization table stored in the image to 1, d min and d max 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. L In the DC quantization coefficient Q L (0,0) and AC quantization coefficient Q L (0,3) has the same value, so even if the DC quantization coefficient is set to 1 during encryption, the Q can still be used when decrypting and restoring the image. L The value of (0,3) is restored to Q L (0,0).

[0144] 2.1) Get the DC coefficient overflow point

[0145] First, the interval factor α (where α∈(0,1]) is used to set the upward overflow threshold UF (Upward Overflow Threshold) and the downward overflow threshold DF (Downward Overflow Threshold) for D to ensure that no coefficient overflow occurs after D is encrypted. The values ​​of UF and LF are as follows:

[0146]

[0147] The DC coefficients in D are traversed in sequence, and the sum pos of all non-negative DC coefficients and the sum neg of negative DC coefficients are calculated using formula (19). When the conditions of formula (19) are not met during the traversal process, the DC coefficient p at this time is i It is called the overflow point coefficient (OPC). After recording the location information of the overflow point coefficient i using the set points, 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 in order to prepare 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] According to the DC coefficient position information recorded in points, D can be divided into several overflow critical intervals (OCI), and then the DC coefficient inside each OCI can be scrambled using a pseudo-random number sequence. For ease of understanding, Algorithm I gives the pseudo code for obtaining the overflow point coefficient set points. Figure 7 A schematic diagram of dividing OCI according to points is given. According to the information recorded in points, 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 found that all DC coefficients whose position information is recorded by points are not involved in encryption. In order to deal with unknown attacks, the number of OPCs needs to be reduced as much as possible. The simplest method here is to change the value of α. Because the larger the value of α, the larger the overflow thresholds UF and DF will be, and the more DC coefficients will be contained in each OCI, and the number of OPCs will be reduced accordingly. When the value of α is 1, the number of OPCs in D will be minimum. In addition to changing the value of α, after in-depth research and thinking, it is found that the number of OPCs can be further reduced by changing the scanning method of the quantization block.

[0157] The standard JPEG algorithm scans quantized blocks from left to right and from top to bottom (e.g. Figure 8 In this scanning mode, the quantization blocks in a single row fully utilize the local similarity of the image, but in two 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, which also means that the value difference of the DC coefficient of the two quantization blocks will be relatively large, which is not conducive to compression when performing DPCM encoding. Here we propose to use the S-type scanning method (such as Figure 8 (b) in the figure scans the quantized blocks to further exploit image similarity. The DC coefficient decoded from the image is (Note that at this time After the inverse DPCM encoding) is restored to a two-dimensional matrix of H×W, the S-type scanning method is used to obtain Then Re-encode DPCM to get D s , because of the S-type scanning method, D s Some DC coefficients in A have smaller absolute values ​​than those in D, which will help reduce the number of overflow points.

[0158] Table 2 shows the number of OPCs generated by the two scanning methods when the Lena grayscale image is compressed with a quality factor QF=85 and different values ​​of the interval factor α. After adopting the S-type scanning method, the number of OPCs decreases, proving that the S-type scanning method proposed above is effective.

[0159] Table 2 The number of OPCs under different scanning modes

[0160]

[0161] 2.3) Optimization

[0162] Since encryption targets the DC coefficients in each OCI, even if the number of overflow point coefficients is further reduced, there will still be some DC coefficients that cannot participate in encryption. Here, the new interval factor β (β>α) and formula (18) can be used to update the values ​​of UF and DF, and the DC coefficient set D encrypted with α is α Perform OCI partitioning and encryption again to obtain D β , so that all coefficients in D participate in encryption. Fig. 9 The new UF and DF pair is given. Figure 7 An example of re-encrypting the encrypted DC coefficient in . It can be seen that Figure 7 There is no DC coefficient involved in encryption (i.e. -1, 1, -2, 2). Fig. 9 All of them can participate in encryption, which completely solves the problem that some DC coefficients cannot participate in encryption.

[0163] Finally, the proposed DC coefficient encryption scheme will not cause DC coefficient overflow, because the encryption targets the DC coefficient in each OCI, and when scrambling each OCI, the sum of all non-negative DC coefficients in this OCI has been recorded using pos, and pos≤UF≤1024, so there will be no overflow. Similarly, there will be no overflow. The encryption process of the DC coefficient is summarized as follows:

[0164] 1) Perform inverse DPCM encoding on the DC coefficient set D decoded sequentially from a JPEG image (containing H×W blocks) to obtain

[0165] 2) After restoring to a two-dimensional matrix of H×W, Perform an S-type scan to obtain Will Re-encode DPCM to get D s .

[0166] 3) First, use the interval factor α and formula (18) to determine the overflow thresholds UF and DF, and then use algorithm I to convert D s Divide into several OCIs, and finally use the pseudo-random number sequence to scramble the DC coefficient in each OCI to obtain the DC coefficient D after the first encryption α .

[0167] 4) Using the new interval factor β and formula (18), we can get UF and DF again, and use algorithm I again to convert the encrypted D α Divide 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 the AC coefficients, the non-zero AC coefficients are used as the core, and the 63 AC coefficients in a block are converted into several intermediate formats of ZRV structures, and then each ZRV is entropy encoded. In previous studies, it was precisely because of the random encryption that the ZRV structure was destroyed, which eventually caused problems such as the increase in the size of the encrypted image file.

[0170] Through observation and research, it can be found that a ZRV contains the information of Z+1 AC coefficients, that is, a 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 contains a ZRV with a larger Z value, such as (9 / 1,1), and the AC coefficient A of the jth (j≠i) block j There are 3 ZRVs with small Z values, such as (0 / 1,1), (3 / 1,-1), (4 / 2,2), then A i The ZRV in A can be used together with j The three ZRVs in the block are exchanged, and the two blocks will not cause coefficient overflow after the exchange (because the ZRVs involved in the exchange record 10 AC coefficient information, which is equivalent to equal-length replacement). At the same time, the structure of the original ZRV is retained, so the bit overhead will not be increased in the entropy coding stage. Inspired by this, an encryption strategy based on AC coefficient fragment scrambling is proposed.

[0171] Given a frequency domain r, all AC coefficients A of a block can be i Divided into front segments and the rear fragment The two parts, two AC coefficient segments are described as follows:

[0172]

[0173] After the AC coefficients of all blocks of an image are divided into two parts according to the given frequency domain r, the front fragment and the second half of the block whose AC coefficient is not 0 at the frequency domain r are extracted and put into the front scrambled set FSS respectively. r (FrontScrambled Set) and Back Scrambled Set BSS r (Back Scrambled Set). r and BSS r The internal coefficient fragments are scrambled with pseudo-random numbers and then put back into the corresponding blocks in sequence to achieve encryption of the AC coefficients. Fig.10A schematic diagram is given of encrypting the AC coefficients of 6 blocks when the frequency domain r = 10. At this time, at the frequency domain r = 10, only the AC coefficients of three blocks are not 0, that is, only three blocks participate in this encryption.

[0174]

[0175] Table 3 also counts Fig.10 The characteristic changes of the blocks before and after encryption in the figure. It can be seen that the relevant block characteristics of the three blocks (A2, A4, A6) participating in encryption have changed after encryption. For the blocks (A1, A3, A5) not participating in encryption, all blocks can be classified and encrypted again by changing the value of r in the frequency domain. For example, when r = 2, except for the last block A6, the rest of the blocks can participate in encryption (Note: the blocks participating in encryption must satisfy that the AC coefficient at r in the frequency domain is not zero).

[0176] Table 3 Block characteristics before and after encryption

[0177]

[0178] If only one frequency domain r is used for encryption, the blocks whose AC coefficients are 0 at frequency domain r cannot be encrypted. Therefore, we can gradually let all blocks of the image participate in encryption by letting r take values ​​from 63 to 1. After DCT transformation, the non-zero AC coefficients will be more concentrated in the low-frequency area with smaller r values ​​(such as Fig.11 As shown in the figure, the purpose of letting r values ​​from large to small is to gradually allow more and more blocks to participate in encryption to achieve a better chaos effect. After the AC coefficients are encrypted, because the characteristics of the block have changed, the block scrambling that excludes the DC coefficient can be performed selectively, and block scrambling is not necessarily required.

[0179] Finally, it is worth noting that the encryption of AC coefficients does not affect the generation of the adaptive key described in Section (1) above, because the encryption of AC coefficients only changes the relative positions of the coefficients in each frequency domain, and the energy and and the number of non-zero AC coefficients There is no change, and the key required for decryption can be completely restored.

[0180] (4) Experimental results and analysis

[0181] In order to verify the adaptability and effectiveness of the proposed method, this embodiment selected three well-known image databases (including images of different sizes and contents) as test objects, namely USC-SIPI database, UCID database, BOWS-2 database, and selected five widely used pictures (Aerial, Airplane, Couple, Lena, Pepper) from the USC-SIPI database for specific analysis and comparison with the previous method. All images involved in the experiment were converted into grayscale images using the OpenCV library (except for the experiments on color images), and then compressed with a quality factor of 85. Finally, unless otherwise specified, in the encryption process of the DC coefficient, the values ​​of the interval factors α and β are set to 0.5 and 1 respectively.

[0182] 4.1) Visual encryption effect

[0183] For information carriers such as images or videos, we obtain information through vision. Therefore, after encryption, the image or video must show a large distortion, similar to a noisy image. Fig.12 The plaintext images and encrypted images of five test images are shown. It can be seen that all images have achieved good visual encryption effects, and it is difficult to obtain any information related to the original image from the encrypted images. The peak signal-to-noise ratio (PSNR) is used as an indicator to evaluate the degree of image distortion, and the 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 will undoubtedly directly affect the encryption performance. When only the interval factor α is used for encryption, the larger the α value, the fewer the number of OCIs in the image, and the better the encryption effect will undoubtedly be. However, even when α=1, all overflow point coefficients OPC still cannot participate in encryption, so it is necessary to encrypt again using a new interval factor β so that all DC coefficients participate in encryption.

[0186] from Fig.13 As you can see, visually, the difference between the image without the interval factor β (the first row) and the image with β is indistinguishable to the naked eye. But there is no doubt that using the interval factor β will help reduce the number of OCIs and the number of OPCs. For example, after using β, Figure 7 5 of the OCIs are in Fig. 9 The number of OPCs has been changed from 4 to 2, thus expanding the OCI scrambling space.

[0187] After using β for encryption, the PSNR values ​​of the five images are reduced (e.g. Fig.14 As shown in Figure 2, it can also be confirmed that the use of β has a gain effect on encryption. When using the 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 multiple OCIs generated by α encryption can be merged into one OCI for encryption when β is used for encryption.

[0188] b) Influence of quality factor QF

[0189] In addition to the set interval factors α and β that affect the number of OCIs, the quality factor QF used when compressing the image will also affect the number of OCIs. The larger the quality factor, the smaller the absolute value of the DC coefficient, and the greater the number of OCIs. Table 4 shows the number of OCIs contained in the Wufu image when α=1 and β is not used. Although the number of OCIs varies greatly when the same image is compressed using different quality factors, the proposed DC coefficient encryption scheme can still encrypt images compressed under different quality factors well and achieve better encryption effects. Fig.15 Even with the increase of quality factor, the naked eye still cannot obtain any information from the encrypted image.

[0190] Table 4 OCI numbers of five images under different quality factors

[0191]

[0192] Finally, the proposed encryption method can be applied not only to grayscale images, but also to color images, as long as the same encryption operation is performed on the three channels (YUV) of the color image. Note that after the DC quantization coefficient of the chromaticity quantization table of the color JPEG image is set to 1, it can also be restored using the coefficient in the brightness table (see Figure 2 ). Fig.16 The encryption effect and PSNR value of four color images after applying the method in this paper are given. All color images are processed with YUV 4:1:1 sampling compression. From the visual effect, the distortion effect of the encrypted color image seems to be better.

[0193] 4.2) Format Compatibility

[0194] After the image is JPEG-encoded, the DC coefficient needs to be inversely DPCM-encoded when it is decoded. If the values ​​of all DC coefficients after inverse DPCM encoding are within [d min , d max] range, then the encryption algorithm is format compatible for the DC coefficient. Because in the encryption scheme proposed in this article, the DC quantization coefficient of the quantization table stored in the image file has been set to 1, so no matter how much the quality factor QF used in image compression is, the legal value range of the DC coefficient of all encrypted images becomes [-1024, 1016]. Table 5 compares the DC coefficient overflow of our method with the previous related methods. Among them, the method of Li et al. will cause DC coefficient overflow to varying degrees, which is caused by arbitrarily changing the position of the DC coefficient. The method of this embodiment, the method of He et al., and the method of Qin et al. will not cause DC coefficient overflow.

[0195] Table 5 DC coefficient overflow under different encryption schemes

[0196]

[0197]

[0198] Compared with DC coefficients, AC coefficients can be considered format-compatible only if their number in a block does not exceed 63. Because the AC coefficient encryption scheme proposed in this paper only changes the relative positions between the 63 coefficients in the frequency domain, the AC coefficient fragments of the encrypted block are scrambled using equal-length exchange, so it does not cause the number of AC coefficients in a block to exceed 63. Therefore, the AC coefficient encryption scheme is also format-compatible.

[0199] 4.3) File size consistency

[0200] The main factor affecting the file size of JPEG images is the entropy coding of DC coefficients and AC coefficients. For AC coefficients, when using block fragment scrambling, the value of the AC coefficient inside each fragment does not change, and the intermediate format ZRV of each non-zero AC coefficient also maintains the consistency before and after encryption, so theoretically, the proposed AC coefficient encryption scheme will not cause any file size changes. In the processing of DC coefficients, because the S-type scanning method is adopted, the local similarity of the image is further utilized, and the absolute value of a part of the DC coefficient will be reduced. In theory, this will help to reduce the file size, and the corresponding experimental results also confirm the above analysis. Compared with the most advanced methods before, the scheme of this embodiment also has the advantage of ensuring consistent file size. Table 6 shows the file size changes of five test images in different encryption schemes. Under our scheme, the scheme of He et al., and the scheme of Qin et al., the file size of the five blessing images has slight changes, but this is caused by the bit alignment mechanism in the JPEG compression algorithm, not the defect of the encryption algorithm.

[0201] In order to avoid contingency, this embodiment also randomly selects a corresponding number of pictures from three image databases widely used for image testing to test the proposed solution. The file size change of the encrypted image and the average PSNR value are shown in Table 7. It can be found that in terms of the file size change of the encrypted image, the image file sizes of the three databases all show a downward trend, which can also indirectly prove that the S-type scanning method proposed above is effective.

[0202] Table 6 Changes in encrypted image file size under different encryption schemes

[0203]

[0204] Table 7 Average PSNR values ​​and file size changes under three databases

[0205]

[0206]

[0207] 4.4) Algorithm complexity analysis

[0208] The encryption scheme of the present application includes three parts: scrambled encryption of DC coefficients, fragment exchange encryption of AC coefficients, and block scrambled encryption. For DC coefficient encryption, it is first necessary to use the set overflow thresholds UF and LF to divide all DC coefficients of the image into OCIs, and then use the scrambled sequence to encrypt the DC coefficients inside each OCI. It can be seen from Algorithm I that the OCI division can be completed by traversing the DC coefficient sequence set D only once, so the time complexity of encrypting the DC coefficient is O(DC) = O(N). For the encryption of AC coefficients, it is necessary to divide the n blocks of the image into two sets of front and back fragments according to the conditions at the frequency domain r, and the value range of the 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 the scrambled sequence, and the time complexity is O(Blk) = O(N). In summary, the overall algorithm time complexity of the scheme of this embodiment is O(N).

[0209] Table 8 shows the encryption time comparison of different encryption schemes on five test images. Among them, the scheme proposed in this paper takes the shortest time, followed by the scheme of He et al., while the schemes of Qin and Li take the longest time. In fact, the schemes of this paper and He et al. mainly consume time in scrambling the coefficients using random sequences, because the algorithm complexity of obtaining pseudo-random number sequences using sorting algorithms is O(nlogn) at the lowest. In Qin's scheme, in addition to pseudo-random number sequences, it is also necessary to predict the DC coefficients and then encrypt the residuals. When the AC coefficients are put back, it is also necessary to detect whether they will overflow, and the encryption scheme is relatively complicated. Li's scheme needs to pre-code the 16×16 pixel blocks and decide whether to further divide them into blocks according to the block coding length. This is equivalent to encoding each block once more, and the encryption time is mainly concentrated here. Finally, both Qin and Li's encryption schemes will generate redundant data during the encryption process, and an additional RDH algorithm needs to be used for data embedding, which undoubtedly increases the time consumption of the scheme.

[0210] Table 8 Comparison of encryption time of different encryption schemes

[0211]

[0212] 4.5) Contour Attack

[0213] There are three main types of contour attacks, namely, the number of non-zero AC coefficients attack (NCC attack), the energy of AC coefficients attack (EAC attack), and the position of the last non-zero AC coefficient attack (PLZ attack). Fig.17 The visual effects of the proposed solution under three types of attacks are given. Regardless of the type of attack, the method of this embodiment can successfully resist and has sufficient security.

[0214] Because the intra-block features of each block of the image can be effectively changed by using only the AC coefficient encryption scheme, the proposed scheme can still resist contour attacks without using block scrambling, which also proves the superiority of the proposed scheme. Fig.18 The figure shows how our method resists contour attacks compared to the previous state-of-the-art methods (none of the three methods uses block scrambling). For ease of observation, the DC coefficients of all encrypted images Lena are set to 0. The experiment found that the three schemes have better visual effects when block scrambling is not used (e.g. Fig.18As shown in the first column of . In He's scheme, the ZRV extracted from the block is divided into several categories according to the run length. After each category is scrambled, it is put back into each block. This can change the EAC of each block, but the NCC and PLZ are not changed. Similarly, in Qin's scheme, after extracting a set threshold number of ZRVs from each block, all of them are scrambled and put back. When an overflow occurs, the block is searched again and the overflowed ZRV is put back. Although the EAC of each block will change, the number of overflow blocks is very small (experiments show that there are only about a dozen blocks), and the NCC and PLZ of most blocks remain unchanged. In summary, in He's scheme and Qin's scheme, if block scrambling is not used, the encrypted image has a certain 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, including:

[0217] Image input module, used to obtain JPEG image and user key K init ;

[0218] The key generation module is used to generate a key based on the JPEG image and the user key K init Adaptively generate the key K DC , key K AC and key K Blk ;

[0219] The random sequence generation module is used to generate a random sequence according to the key K DC Generate a first pseudo-random number sequence seq1, according to the key K AC Generate a second pseudo-random number sequence seq2, according to the key K Blk Generate a third pseudo-random number sequence seq3;

[0220] An image decoding module is used to decode a JPEG image to obtain a DC coefficient and an AC coefficient;

[0221] A DC encryption module, used for encrypting a DC coefficient according to a first pseudo-random number sequence seq1;

[0222] An AC encryption module, used for encrypting AC coefficients according to a second pseudo-random number sequence seq2;

[0223] The image encoding module is used to encode the encrypted DC coefficient and AC coefficient to obtain an encrypted JPEG image.

[0224] Since the device is an adaptive JPEG compressed image encryption device of an embodiment of the present invention, and the principle of solving the problem by the device is similar to that of the method, the implementation of the device can refer to the implementation process of the above method embodiment, and the repeated parts will not be repeated.

[0225] Example 3

[0226] An embodiment of the present invention further provides an electronic device, the electronic device comprising a processor and a memory, the memory storing 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 being loaded and executed by the processor to implement the following Figure 6 An adaptive JPEG compressed image encryption method is shown.

[0227] It is understood that the memory may include a random access memory (RAM) or a read-only memory (ROM). Optionally, the memory includes a non-transitory computer-readable storage medium. The memory may be used to store instructions, programs, codes, code sets, or instruction sets. The memory may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function, instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data created according to the use of the server, etc.

[0228] The processor may include one or more processing cores. The processor uses various interfaces and lines to connect the various parts of the entire server, and executes various functions of the server and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory, and calling data stored in the memory. Optionally, the processor can be implemented in at least one hardware form of digital signal processing (DSP), field programmable gate array (FPGA), and programmable logic array (PLA). The processor can integrate one or a combination of a central processing unit (CPU) and a modem. Among them, the CPU mainly processes the operating system and application programs; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor, but implemented separately through a chip.

[0229] Since the electronic device is an electronic device corresponding to an adaptive JPEG compression image encryption method of an embodiment of the present invention, and the principle of solving the problem by the electronic device is similar to that of the method, the implementation of the electronic device can refer to the implementation process of the above-mentioned method embodiment, and the repeated parts will not be repeated.

[0230] Example 4

[0231] The embodiment of the present invention further provides a computer-readable storage medium, wherein the storage medium stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, the at least one program, the code set or instruction set is loaded and executed by a processor to implement the following Figure 6 An adaptive JPEG compressed image encryption method is shown.

[0232] Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.

[0233] Since the storage medium is a storage medium corresponding to an adaptive JPEG compression image encryption method of an embodiment of the present invention, and the principle of solving the problem by the storage medium is similar to that of the method, the implementation of the storage medium can refer to the implementation process of the above-mentioned method embodiment, and the repeated parts will not be repeated.

[0234] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. 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 representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0235] The above embodiments are only for illustrating the technical concept and features of the present invention, and their purpose is to enable ordinary technicians in the field to understand the content of the present invention and implement it accordingly, and they cannot be used to limit the protection scope of the present invention. Any equivalent changes or modifications made based on the essence of the content of the present invention should be included in the protection scope of the present invention.

Claims

1. An adaptive JPEG compressed image encryption method, characterized in that: The following steps are involved: Get the JPEG image and user key K init ; According to the JPEG image and the user key K init Adaptively generate the key K DC , key K AC and key K Blk ; According to the key K DC Generate a first pseudo-random number sequence seq1, according to the key K AC Generate a second pseudo-random number sequence seq2, according to the key K Blk Generate a third pseudo-random number sequence seq3; Decode the JPEG image to obtain the DC coefficient and AC coefficient; Encrypting the DC coefficient according to a first pseudo-random number sequence seq1; Encrypting the AC coefficients according to a second pseudo-random number sequence seq2; The encrypted DC coefficient and AC coefficient are encoded to obtain an encrypted JPEG image.

2. The adaptive JPEG compressed image encryption method according to claim 1, characterized in that: According to the JPEG image and the user key K init Adaptively generate the key K DC , key K AC and key K Blk ,include: make n blocks (Blk1, Blk2, ..., Blk n ) is the AC coefficient energy sum at position r in the frequency domain, and the key K is obtained by the following method DC : make The number of non-zero AC coefficients of n blocks of the image at frequency domain r is represented by the key K obtained by AC : The key K is obtained by Blk : In the formula, SHA 256 () indicates SHA 256 function, Represents the exclusive OR operation.

3. The adaptive JPEG compressed image encryption method according to claim 1, characterized in that: The key K DC Generate a first pseudo-random number sequence seq1, according to the key K AC Generate a second pseudo-random number sequence seq2, according to the key K Blk Generate a third pseudo-random number sequence seq3, including: According to the key K DC Get the initial value of chaos (θ1, x1, y1), according to the key K AC Get the initial value of chaos (θ2, x2, y2), according to the key K Blk Get the initial value of chaos (θ3, x3, y3); where θ1, θ2, θ3 are preset values; The chaotic system is used to iterate the chaotic initial value multiple times to obtain a chaotic number sequence chaos with an arbitrary length of N. seq ; For the chaotic number sequence chaos seq After sorting, the sequence composed of its original serial numbers is the pseudo-random sequence required for encryption; The three chaotic initial values ​​correspond to three pseudo-random number sequences respectively; Among them, x j and j Obtained through: After obtaining the key required by the corresponding pseudo-random number sequence, the 256 bits of the key (b1, b2, ..., b 256 ) is divided into two groups, each with 128 bits. The following formula is used to sequentially convert the number of bits "1" in the two groups of bit sequences into the number of x in a set of chaotic initial values. θ and θ value, 4. The adaptive JPEG compressed image encryption method according to claim 1, characterized in that: The encrypting the DC coefficient according to the first pseudo-random number sequence seq1 comprises: The DC coefficient set D decoded from the JPEG image is inversely DPCM-encoded to obtain Will After restoring to a two-dimensional matrix, Perform an S-type scan to obtain Will Re-encode DPCM to get D s ; Use the interval factor α to determine the overflow threshold UF and DF, and then set D s The DC coefficients in each overflow critical interval OCI are scrambled using the first pseudo-random number sequence seq1 to obtain an encrypted DC coefficient set D α ; Using the new interval factor β, we can get the overflow threshold UF and DF again, and then convert the encrypted D α Divide it into several overflow critical intervals OCI, and then scramble and encrypt each overflow critical interval OCI again to obtain the DC coefficient set D β ; Among them, β>α.

5. The adaptive JPEG compressed image encryption method according to claim 4, characterized in that: The expressions of the overflow threshold UF and the overflow threshold DF determined by the interval factor α are as follows: Among them, α∈(0,1], Indicates rounding a number down.

6. The adaptive JPEG compressed image encryption method according to claim 1, characterized in that: The encrypting the AC coefficient according to the second pseudo-random number sequence seq2 includes: Given a frequency domain r, the AC coefficients of all blocks of an image are divided into two parts according to the given frequency domain r; The front fragment and the second half of the block whose AC coefficient is not 0 at frequency domain r are extracted and put into the front scrambling set FSS respectively. r and the back scrambling set BSS r ; Set the front scrambled set FSS r and the back scrambling set BSS r The internal coefficient fragments are scrambled respectively using the second pseudo-random number sequence seq2 and then put back into the corresponding blocks in sequence to achieve encryption of the AC coefficients.

7. The adaptive JPEG compressed image encryption method according to claim 6, characterized in that: The step of encrypting the AC coefficients according to the second pseudo-random number sequence seq2 further comprises the following steps: After the scrambled segments are put back into the corresponding blocks, block scrambling is performed according to the third pseudo-random number sequence seq3.

8. An adaptive JPEG compressed image encryption device, characterized in that: include: Image input module, used to obtain JPEG image and user key K init ; The key generation module is used to generate a key based on the JPEG image and the user key K init Adaptively generate the key K DC , key K AC and key K Blk ; The random sequence generation module is used to generate a random sequence according to the key K DC Generate a first pseudo-random number sequence seq1, according to the key K AC Generate a second pseudo-random number sequence seq2, according to the key K Blk Generate a third pseudo-random number sequence seq3; An image decoding module is used to decode a JPEG image to obtain a DC coefficient and an AC coefficient; A DC encryption module, used for encrypting a DC coefficient according to a first pseudo-random number sequence seq1; An AC encryption module, used for encrypting AC coefficients according to a second pseudo-random number sequence seq2; The image encoding module is used to encode the encrypted DC coefficient and AC coefficient to obtain an encrypted JPEG image.

9. 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 described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The storage medium 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 according to any one of claims 1 to 7.