Information encryption method, device and equipment
By dividing the target image into color blocks and compressing its position, pixel-level data is generated for encryption, solving the problems of distortion and large file size in the existing image encryption process, and achieving efficient lossless compression and storage optimization.
Patent Information
- Application Number
- CN202511793968.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-02
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2045-12-02
AI Technical Summary
Existing image encryption technologies are prone to image distortion or low compression rates during the compression process, resulting in large file sizes and wasted storage space.
By dividing the target image into color blocks based on the color value of each pixel, an array of color values and an array of positions are generated. The position array is then compressed to form pixel-level data for encryption, which avoids image distortion and reduces file size.
It achieves lossless compression, which can avoid image distortion, improve compression ratio, reduce the size of encrypted files, and save storage space.
Smart Images

Figure CN121239796B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information security technology, particularly to the field of information security protection in the field of semiconductor technology, and specifically to an information encryption method, apparatus, and device. Background Technology
[0002] Information security is crucial across all industries, and encryption technology is generally used to enhance it. Image encryption is a key information encryption technology, applicable in many scenarios. For example, in the field of semiconductor testing technology, images are often included in troubleshooting methods for power modules, requiring encryption of those images.
[0003] Some image encryption solutions use lossy compression, which discards some detailed data during the compression process, resulting in image distortion and making it impossible to recover the original image. To solve this problem, some solutions propose lossless compression. While this method avoids image distortion, it has a lower compression ratio, resulting in a larger compressed file size and wasting more storage space. Summary of the Invention
[0004] Therefore, it is necessary to provide an information encryption method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can both avoid image distortion and reduce the size of encrypted files, addressing the aforementioned technical problems.
[0005] Firstly, this application provides an information encryption method, which includes:
[0006] The target image is divided into color blocks based on the color value of each pixel, resulting in solid color blocks; one or more color blocks correspond to the same color value.
[0007] A color value array and a first position array are generated based on the divided color blocks; wherein, the color value array includes each color value in the target image and the number of color blocks corresponding to each color value; the first position array includes the color block coordinates and color block size corresponding to each color block;
[0008] Compress the first position array to obtain compressed data of the color block positions;
[0009] Compress the data based on the pixel size, color value array, and color block position of the target image to form pixel-level data to be encrypted;
[0010] Pixel-level data is encrypted to obtain the image encryption information corresponding to the target image.
[0011] In one embodiment, color blocks are divided based on the color value corresponding to each pixel in the target image to obtain solid color blocks, including:
[0012] Generate a two-dimensional array of pixels; the two-dimensional array of pixels includes the original color value of each pixel in the target image;
[0013] Perform a difference calculation on the two-dimensional array of pixels to obtain a two-dimensional array of pixel differences; the color value corresponding to each pixel in the two-dimensional array of pixel differences is the color value after the difference calculation is performed on the original color value;
[0014] Divide pixels with consecutive equal color values in a two-dimensional pixel difference array into the same rectangular color block.
[0015] In one embodiment, generating a color value array and a first position array based on the divided color blocks includes:
[0016] A color block array is generated based on the divided color blocks; wherein, the color block array includes the color value corresponding to each pixel in the target image and the second position array corresponding to each color value; the second position array corresponding to each color value includes the color block coordinates and color block size corresponding to each color block with color value;
[0017] Determine the number of color blocks corresponding to each color value in the color block array, and generate a color value array based on each color value and the corresponding number of color blocks in the color block array;
[0018] The first position array is generated based on the second position array corresponding to each color value.
[0019] In one embodiment, the pixel-level data also includes a first color value, which is the color value corresponding to the largest number of color blocks;
[0020] Based on the color values and the corresponding number of color blocks in the color block array, generate a color value array, including:
[0021] A color value array is generated based on each second color value and the number of color blocks corresponding to the second color value; the second color value is the color value in the color block array other than the first color value.
[0022] Generate a first position array based on the second position array corresponding to each color value, including:
[0023] A first position array is generated based on the second position array corresponding to each second color value.
[0024] In one embodiment, the color block coordinates in the second position array are the original color block coordinates; each element in the second position array includes the original color block coordinates and the color block size; the original color block coordinates include the original horizontal coordinate value and the original vertical coordinate value of the color block; in the second position array, each element is sorted according to the size relationship of the original horizontal coordinate values, and elements corresponding to the same original horizontal coordinate are sorted according to the size relationship of the original vertical coordinate values.
[0025] Generate a first position array based on the second position array corresponding to each color value, including:
[0026] For each color value, the original x-coordinate value in the second position array is replaced with the x-coordinate difference, and the original y-coordinate value of the target element is replaced with the y-coordinate difference, to obtain the third position array corresponding to that color value; the target element is the element in the second position array excluding the first element; the x-coordinate difference is the difference between the original x-coordinate value of the target element and the previous element, and the y-coordinate difference is the difference between the original y-coordinate value of the target element and the previous element;
[0027] The first position array is generated based on the third position array corresponding to each color value.
[0028] In one embodiment, the coordinates of each color block in the first position array include the x-coordinate and y-coordinate values of the color block, and the size of the color block includes the length and height of the color block;
[0029] Compress the first position array to obtain compressed color block position data, including:
[0030] The first position array is split into an x-coordinate array, a y-coordinate array, a length array, and a height array; wherein, the x-coordinate array includes the x-coordinate value of each color block, the y-coordinate array includes the y-coordinate value of each color block, the length array includes the length of each color block, and the height array includes the height of each color block.
[0031] The horizontal coordinate array, the vertical coordinate array, the length array, and the height array are concatenated to obtain the concatenated array;
[0032] Compress the concatenated array to obtain compressed data of the color block positions.
[0033] In one embodiment, the color values in the color value array are sorted in a first order, which is either an order of decreasing or increasing number of color blocks; each element in the first position array corresponds to a color block, and each element corresponds to the color value of the corresponding color block; each element includes the color block coordinates and the color block size; the elements in the first position array are sorted sequentially according to the order of the corresponding color values in the color value array.
[0034] In one embodiment, the target image contains original information to be encrypted; the original information further includes first text information; the encryption information of the original information includes image encryption information and text encryption information; before dividing the target image into color blocks based on the color value corresponding to each pixel, the method further includes:
[0035] Replace the target image in the original information with the image identifier corresponding to the target image to obtain the second text information, and encrypt the second text information to obtain the encrypted text information;
[0036] After obtaining the image encryption information, the method also includes:
[0037] Store the encrypted information of the image along with the image identifier.
[0038] In one embodiment, the second text information is encrypted to obtain encrypted text information, including:
[0039] Convert the second text information into a one-dimensional first byte array;
[0040] Convert the first byte array into a one-dimensional boolean array;
[0041] The first preset number of elements in the one-dimensional Boolean array are moved to the end of the one-dimensional Boolean array to update the one-dimensional Boolean array;
[0042] The input variable of the inverted position generation function is continuously changed according to the preset rules, so that the inverted position generation function continuously generates new inverted positions. For each generated inverted position, the Boolean element corresponding to the inverted position in the current one-dimensional Boolean array is inverted until the generated inverted position is greater than or equal to the length of the one-dimensional Boolean array, at which point the inversion stops.
[0043] Convert the one-dimensional boolean array after stopping the inversion into a one-dimensional second-byte array;
[0044] The second byte array is converted into a string to obtain the encrypted text information.
[0045] Secondly, this application also provides an information encryption device, which includes:
[0046] The color block segmentation module is used to segment the target image into color blocks based on the color value corresponding to each pixel, resulting in solid color blocks; one or more color blocks may correspond to the same color value.
[0047] The array generation module is used to generate a color value array and a first position array based on the divided color blocks; wherein, the color value array includes each color value in the target image and the number of color blocks corresponding to each color value; the first position array includes the color block coordinates and the size of each color block;
[0048] The compression module is used to compress the first position array to obtain compressed data of the color block positions;
[0049] The encryption module is used to compress data based on the pixel size, color value array, and color block position of the target image to form pixel-level data to be encrypted; the pixel-level data is then encrypted to obtain the image encryption information corresponding to the target image.
[0050] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the method mentioned in the first aspect above.
[0051] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the method mentioned in the first aspect above.
[0052] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps of the method mentioned in the first aspect above.
[0053] The aforementioned information encryption method, apparatus, computer equipment, computer-readable storage medium, and computer program product divide the target image into color blocks based on the color value corresponding to each pixel, obtaining pure color blocks; one or more color blocks correspond to the same color value; a color value array and a first position array are generated based on the divided color blocks; wherein, the color value array includes each color value in the target image and the number of color blocks corresponding to each color value. That is, effective pixel-level compression is achieved from the color dimension. The first position array includes the color block coordinates and color block size corresponding to each color block; the first position array is compressed to obtain color block position compressed data. That is, pixel-level compression is achieved from the position dimension. By performing effective pixel-level compression from both color and position dimensions, a good compression ratio is achieved. Based on the pixel size of the target image, the color value array, and the color block position compressed data, pixel-level data to be encrypted is formed; the pixel-level data is encrypted to obtain the image encryption information corresponding to the target image. That is, the encrypted object is the compressed pixel-level data, thus ensuring the compression ratio during pixel-level encryption. Furthermore, because pixel-level data contains information about color and location, images can be restored losslessly during decryption. Therefore, it avoids or reduces image distortion, improves compression ratio, reduces the size of encrypted files, and thus saves storage space. Attached Figure Description
[0054] Figure 1This is a flowchart illustrating an information encryption method in one embodiment;
[0055] Figures 2 to 4 This is a schematic diagram illustrating the color block division principle in one embodiment;
[0056] Figure 5 This is a schematic diagram of a color block array in one embodiment;
[0057] Figure 6 This is a schematic diagram of a color block array in another embodiment;
[0058] Figure 7 This is a schematic diagram of the third position array in one embodiment;
[0059] Figure 8 This is a schematic diagram of the first position array in one embodiment;
[0060] Figure 9 This is a schematic diagram of array concatenation in one embodiment;
[0061] Figure 10 This is a flowchart illustrating the information encryption method in another embodiment;
[0062] Figure 11 This is a structural block diagram of an information encryption device in one embodiment;
[0063] Figure 12 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0064] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0065] Some image encryption techniques do not encrypt the image information (i.e., the actual image content), but rather encrypt the image's metadata. For example, using AES-256 to encrypt the EXIF information of a JPEG image file. This method has security issues. Some solutions directly apply chaotic encryption to the image, such as using the Lorenz system to generate chaotic sequences for pixel obfuscation. This can increase the size of the encrypted file by 200%-300%.
[0066] Therefore, some solutions compress the image before encrypting it.
[0067] Some compression schemes convert RGB images to a YCbCr model, separating luminance (Y) and chrominance (CbCr). Then, chrominance sampling is performed, commonly in a 4:2:0 mode: the chrominance channel resolution is reduced to 1 / 4 of the luminance (removing 75% of the chrominance data). Next, the image is cut into 8×8 blocks, converted into frequency signals, and then details insensitive to the human eye are discarded before being repackaged and stored to achieve image compression. Discarding details insensitive to the human eye during compression leads to image distortion, and each edit and resave further degrades quality, making it impossible to restore the original image.
[0068] Some compression schemes apply a predictor to each row of pixels in the image, calculating the difference (Delta value) between the current pixel and its left / top / top-left pixels, converting the original data into a more compressible difference form; then, the DEFLATE algorithm (a combination of LZ77 compression and Huffman coding) is used to eliminate redundant data. This scheme has a low compression ratio, as it only performs one-dimensional horizontal compression in the LZ77 compression stage, resulting in a large file size after compression and encryption.
[0069] Based on this, this application proposes a novel information encryption method that can both avoid image distortion and reduce the size of the encrypted file. In one embodiment, such as Figure 1 As shown, taking the application of this information encryption method to computer equipment as an example, the specific steps include:
[0070] S11, divide the target image into color blocks based on the color value of each pixel to obtain solid color blocks.
[0071] The color value corresponding to each pixel can be the original color value (i.e., the original color value of the pixel in the target image) or the color value after processing based on the original color value (such as the color value after difference calculation).
[0072] Specifically, the computer device can generate a two-dimensional array of pixels, which includes the original color value of each pixel in the target image. Then, based on the two-dimensional pixel array, color blocks are divided to obtain solid color blocks. A solid color block refers to a block where pixels have the same color value. It should be understood that a color value may be distributed in different areas of the entire image and may not necessarily be classified into a single color block; therefore, the same color value corresponds to one or more color blocks. For example, the divided color blocks can be rectangular color blocks.
[0073] In some examples, computer devices can directly divide pixels with consecutively equal color values (i.e., original color values) in a two-dimensional pixel array into the same rectangular solid color block. The specific method of dividing the color blocks is not limited; for example, one can first find pixels with consecutively equal color values by row and then by column, thus achieving color block division.
[0074] Now combined Figures 2 to 4 The principle of color block division is illustrated. Figure 2 It is a target image, which contains 3 colors. Figure 3 Used to illustrate a two-dimensional array of pixels. Figure 3 Each small square in the diagram corresponds to a pixel, and the value in the square is the original color value of that pixel. For ease of illustration, the original color values are represented by A, B, and C respectively. Figure 3 The diagram illustrates how a two-dimensional array of pixels is combined with the primary colors in the target image to provide a more intuitive understanding of the two-dimensional array of pixels. Figure 4 Color blocks used to indicate the division of rectangles. From Figure 4 It can be seen that the original color values of pixels in the same rectangular color block are the same.
[0075] In other examples, the computer device can perform differential calculations on the two-dimensional array of pixels to obtain a two-dimensional array of pixel differences; the color value corresponding to each pixel in the two-dimensional array of pixel differences is the color value obtained by differential calculation on the original color value. Furthermore, pixels with consecutively equal color values in the two-dimensional array of pixel differences can be grouped into the same rectangular color block.
[0076] For example, the steps to obtain a two-dimensional pixel difference array include: a computer device can automatically analyze the correlation between adjacent pixels; when performing differential encoding calculations on the original color values corresponding to each row of pixels, with the goal of minimizing prediction error, the optimal prediction mode corresponding to that row is selected from multiple preset candidate prediction modes for differential calculation, resulting in the differentially calculated color values corresponding to each pixel. The differentially calculated color values corresponding to each pixel form a two-dimensional pixel difference array. Differential processing of the two-dimensional pixel array to form a two-dimensional pixel difference array can reduce the dynamic range of data, eliminate spatial redundancy, and make subsequent compression more efficient.
[0077] In some examples, several preset candidate prediction patterns are as follows:
[0078] Sub Prediction Mode: Predicts the color value of the current pixel using the original color values of the left-adjacent pixels;
[0079] Up prediction mode: Predicts the color value of the current pixel using the original color values of the adjacent pixels above;
[0080] Average prediction mode: Takes the average of the original color values of the left-side adjacent pixel and the top-side adjacent pixel;
[0081] Paeth prediction mode: Prediction based on a linear function of the left, top, and top-left pixels.
[0082] Example formula for Paeth prediction mode: Prediction error Px = Current - Paeth(Left, Top, LeftTop), where Current is the original color value of the current pixel, and Paeth(Left, Top, LeftTop) represents the predicted value calculated based on the surrounding pixels (left, top, and top-left pixels). Left is the original color value of the left-adjacent pixel, Top is the original color value of the top-adjacent pixel, and LeftTop is the original color value of the top-left adjacent pixel (i.e., the left-adjacent pixel of the pixel directly above).
[0083] S12, Generate a color value array and a first position array based on the divided color blocks; wherein, the color value array includes each color value in the target image and the number of color blocks corresponding to each color value; the first position array includes the color block coordinates and color block size corresponding to each color block.
[0084] It should be understood that the color values in the color value array refer to the color values corresponding to the pixels in the target image. If the pixel corresponds to the original color value, then the color values in the color value array are the original color values; if the pixel corresponds to the color value after difference calculation, then the color values in the color value array are the color values after difference calculation.
[0085] In some embodiments, the color value array may include all color values corresponding to pixels in the target image (i.e., the color values corresponding to all pixels) and the number of color blocks corresponding to each pixel, or it may include a subset of color values corresponding to pixels in the target image and the number of color blocks corresponding to each pixel. For example, a subset of color values may be a second color value other than the first color value, where the first color value is the color value with the largest number of corresponding color blocks. It should be understood that if a difference calculation is performed on the original color values when dividing the color blocks, then the first color value may be the difference-calculated color value with the largest number of corresponding color blocks (hereinafter referred to as the difference color value). If no difference calculation is performed on the original color values, the first color value is the original color value with the largest number of corresponding color blocks.
[0086] The first position array matches the color value array. That is, if a color value exists in the color value array, then the coordinates and size of the color patch with that color value exist in the first position array. Conversely, if a color value does not exist in the color value array, then the coordinates and size of the color patch with that color value do not exist in the first position array. For example, if the first color value does not exist in the color value array, then the first position array will not include the coordinates and size of the color patch with that first color value.
[0087] In some embodiments, a computer device can directly count the number of color blocks corresponding to each color value in the target image and the position information of the color blocks (including color block coordinates and color block size) by traversing and counting, thereby generating a color value array and a first position array.
[0088] In other embodiments, the computer device can generate a comprehensive array based on the divided color blocks. The comprehensive array is an array that records both the color values and position information of the color blocks. Then, a color value array and a first position array are generated based on the comprehensive array. It should be understood that, based on the comprehensive array, a color value array statistically analyzed from the color value dimension, and a first position array statistically analyzed from the position information dimension, can be generated more accurately and with greater basis. Specific details of this embodiment are described below and will not be elaborated here.
[0089] S13, compress the first position array to obtain the compressed data of the color block positions.
[0090] Specifically, duplicate elements in the first position array can be detected, and these duplicate elements can be compressed (for example, by replacing duplicate elements with pointers based on distance and length) to obtain compressed data of the color block positions. For example, the LZ77 algorithm can be used for compression.
[0091] For example, the color values in the color value array are sorted in a first order, which is either an order of decreasing or increasing number of color blocks. Each element in the first position array corresponds to a color block, and each element corresponds to the color value of its corresponding color block; each element includes the color block coordinates and the color block size; the elements in the first position array are sorted sequentially according to the order of their corresponding color values in the color value array.
[0092] In some examples, the first position array is a two-dimensional array because it includes the coordinates and size of each color block. Each row in the first position array contains the coordinates and size of a single color block. Therefore, the two-dimensional first position array can be converted into a one-dimensional array. For example, the data in the first position array can be concatenated row by row or column by column to form a one-dimensional array. Then, the converted one-dimensional array can be compressed to obtain compressed color block position data. It should be understood that one-dimensional arrays have higher element repetition than two-dimensional arrays, thus improving the compression ratio.
[0093] In other examples, the color block coordinates and sizes in the first position array can be split into different arrays. These two arrays are then concatenated to obtain a two-dimensional concatenated array. This two-dimensional concatenated array is then compressed to obtain the compressed color block position data. Compared to the original first position array, the two-dimensional concatenated array has higher element redundancy, which can also improve the compression ratio to some extent.
[0094] S14: Compress the data based on the pixel size, color value array, and color block position of the target image to form pixel-level data to be encrypted.
[0095] It should be understood that the pixel-level data to be encrypted is the lossless compressed data of the target image at the pixel level. Decompressing based on this pixel-level data can accurately restore the target image.
[0096] In some embodiments, where the color value array includes all color values corresponding to a pixel, the pixel-level data to be encrypted may include the pixel size of the target image, the color value array, and compressed data of color block positions.
[0097] In other embodiments, where the color value array includes some color values (i.e., a second color value other than the first color value), the pixel-level data to be encrypted may include the pixel size of the target image, the first color value (i.e., the background color), the color value array, and compressed data of color block positions.
[0098] It should be understood that the first position array generated is different depending on whether the color value array includes the background color or not, and therefore the compressed data of the generated color block position is different. For details, please refer to the description above, which will not be repeated here.
[0099] S15, encrypt the pixel-level data to obtain the image encryption information corresponding to the target image.
[0100] Specifically, the pixel-level data to be encrypted can be converted into a binary file and then encrypted (e.g., cyclic shifting, inverting specified bits, etc.) to obtain the image encryption information corresponding to the target image.
[0101] In the above method, color blocks are divided based on the color value corresponding to each pixel in the target image to obtain solid color blocks; a color value array and a first position array are generated based on the divided color blocks. That is, effective pixel-level compression is achieved from the color dimension. The first position array is compressed to obtain color block position compressed data, that is, pixel-level compression is achieved from the position dimension. By performing effective pixel-level compression from both color and position dimensions, a good compression ratio is achieved. Based on the pixel size of the target image, the color value array, and the color block position compressed data, pixel-level data to be encrypted is formed; the pixel-level data is encrypted to obtain the image encryption information corresponding to the target image. That is, the encrypted object is the compressed pixel-level data, thus ensuring the compression ratio during pixel-level encryption. In addition, since the pixel-level data has information in terms of color and position dimensions, the image can be restored losslessly during decryption. Therefore, it can both avoid or reduce image distortion and improve the compression ratio, reduce the size of the encrypted file, and thus save storage space.
[0102] In some embodiments, a detailed description will be provided of how to generate an array of color values and a first position array based on a composite array.
[0103] Specifically, computer equipment can generate a color patch array based on the divided color patches. A color patch array is an array generated based on color patches and is a comprehensive array. This color patch array includes the color value corresponding to each pixel in the target image and a second position array corresponding to each color value. That is, each element in the color patch array contains a color value (original color value or color value after differential processing) and a second position array corresponding to that color value. The second position array corresponding to each color value includes the color patch coordinates and color patch size for each color patch with that color value; that is, each element in the second position array contains a color patch coordinate and a color patch size. The color patch coordinates can be the coordinates of the center position of the color patch or a specified corner point (such as the lower left corner), and the coordinate information includes the horizontal and vertical coordinates.
[0104] Figure 5 That is, based on Figure 4 An array of color blocks generated from the color blocks divided in the middle. From Figure 5 We know that there are three color values in the color block array: A, B, and C. Each color value has its own corresponding second position array. Taking color value C as an example, only one color block has this color value, so the second position array corresponding to color value C has only one element (19, 8, 3, 7). Here, 19 and 8 represent the x-coordinate (value on the X-axis) and y-coordinate (value on the Y-axis) of the color block with color value C in the target image, respectively, and 3 and 7 represent the length and height of the color block with color value C, respectively (combined with...). Figure 4It can be intuitively seen that the color block with color value C occupies 3 squares horizontally and 7 squares vertically, therefore its length and height are 3 and 7 respectively. For example, taking color value B, there are a total of 8 color blocks with this color value, and their corresponding second-position array has 8 elements (one row represents the data corresponding to one element). Taking one element (2,8,3,1) as an example, it represents the horizontal and vertical coordinates, as well as the length and height of the first color block with color value B.
[0105] For example, you can traverse a two-dimensional array of pixels or a two-dimensional array of pixel differences, record the color value of each color block, the index coordinates of the color block in the array, and the size of the color block, and merge the information of color blocks with the same color value to obtain a color block array.
[0106] Furthermore, the number of color blocks corresponding to each color value in the color block array can be determined. Based on each color value and its corresponding number of color blocks in the color block array, a color value array is generated. Additionally, a first position array is generated based on the second position array corresponding to each color value; for example, the second position arrays corresponding to each color value can be concatenated to form the first position array. In this scheme, the color block array is generated first, allowing for a more accurate and convenient splitting and generation of compressed arrays based on the color and position dimensions.
[0107] In some examples, a color value array can be generated based on all color values in the color swatch array and the number of swatches corresponding to each color value. In this case, the first position array is generated based on the second position array corresponding to each color value.
[0108] In other examples, a color value array can also be generated based on a subset of color values in the color swatch array and the number of corresponding color swatches. Specifically, the color value with the largest number of corresponding color swatches in the color swatch array can be determined and designated as the first color value (i.e., the background color). All other color values in the color swatch array besides the first color value can be designated as second color values. There can be one or more second color values. Furthermore, a color value array can be generated based on each second color value and the number of corresponding color swatches, and a first position array can be generated based on the second position array corresponding to each second color value.
[0109] Now combined Figure 5 and Figure 6 A diagram is provided for illustration. From Figure 5 It is known that color value A corresponds to the largest number of color blocks, so it can be recorded as the background color (i.e., the first color value). Then, the second position of the array corresponding to color value A is deleted from the color block array, and only the color value A as the background color is recorded, thus obtaining the result. Figure 6The updated color patch array is shown. This updated color patch array only includes the second position arrays corresponding to color values B and C, respectively. Furthermore, a color value array and a first position array can be generated based on the updated color patch array. By recording the background color, the amount of data can be further reduced, improving the compression ratio.
[0110] As mentioned above, the first position array includes the coordinates and size of each color block. The coordinates of the color blocks in the first position array can be the original coordinates or the coordinates after processing the original coordinates (such as performing interpolation). It should be understood that the coordinates of each color block after performing interpolation on the original coordinates are essentially coordinate differences, including differences in the horizontal and vertical coordinates.
[0111] In some examples, the color block coordinates in the second position array are the original color block coordinates; an element in the second position array includes the original color block coordinates and the color block size; the original color block coordinates include the original x-coordinate value and the original y-coordinate value of the color block.
[0112] For each color value in the color value array, corresponding to a second position array, when the second position array contains multiple elements, the computer device can perform difference calculations on the original color block coordinates in the second position array. Specifically, the original x-coordinate value of each target element in the second position array is replaced with the x-coordinate difference, and the original y-coordinate value of the target element is replaced with the y-coordinate difference, resulting in a third position array corresponding to that color value. The target element is any element in the second position array except the first element. The x-coordinate difference is the difference between the original x-coordinate value of the target element and the previous element, and the y-coordinate difference is the difference between the original y-coordinate value of the target element and the previous element. It should be understood that the coordinate value of the first element in the third position array remains unchanged and still uses the original coordinate value. By performing difference calculations on the color block coordinates, the amount of data can be reduced, further improving the compression ratio.
[0113] Furthermore, a first position array is generated based on the third position arrays corresponding to each color value. For example, the third position arrays corresponding to multiple color values are concatenated to generate the first position array. If the second position array corresponding to a color value has only one element, then the second position array corresponding to that color value is used as the third position array and concatenated with the third position arrays corresponding to other color values to form the first position array.
[0114] For example, before performing the difference calculation on the original color block coordinates in the second position array, the elements in the second position array are sorted according to the magnitude of their original x-coordinate values (e.g., arranged in ascending or descending order). Elements with the same original x-coordinate (i.e., the original X-coordinate value) are sorted according to the magnitude of their original y-coordinate values (i.e., arranged in ascending or descending order). It should be understood that performing the difference calculation on the original color block coordinates in the second position array after sorting them in order makes the differences of the same x-coordinate and y-coordinate more concentrated, which helps to improve the repetition of adjacent data in the first position array, thereby improving the subsequent compression rate to some extent.
[0115] To facilitate understanding of the third position array, combined with Figure 6 and Figure 7 Provide a illustrative explanation. Figure 6 The second position array corresponding to the color value B has multiple elements, so we can perform a difference calculation on it. Specifically, starting from the second row (i.e., the second element) of this second position array, subtract the x-coordinate / y-coordinate value of the previous row from the x-coordinate / y-coordinate value of the next row, and replace the original x-coordinate and y-coordinate values with the difference as the updated x-coordinate and y-coordinate values. After performing the difference calculation row by row, we obtain... Figure 7 The third position array corresponding to color value B is shown. Since the second position array corresponding to color value C has only one element, its corresponding third position array is simply the second position array itself. It should be understood that... Figure 7 The size of the color block in the second position array (i.e., the length and height of the color block) is not calculated by difference. In other examples, the size of the color block can also be calculated by difference, and there is no limitation on this.
[0116] Furthermore, it can be Figure 7 The arrays corresponding to the third positions of the color values B and C are concatenated to form Figure 8 The first position array is shown.
[0117] like Figure 8 As shown, after removing color value A, which has the most color blocks, the color value array includes the number of color blocks corresponding to color values B and C respectively. That is, color value B corresponds to 8 color blocks, and color value C corresponds to 1 color block. The first position array contains 9 rows of data. Among them, the first 8 rows of data are the data in the third position array corresponding to color value B, including the coordinates of the 8 color blocks after difference calculation (including the x and y coordinates) and the size of the 8 color blocks (i.e., the length and height of the color blocks). The last row of data is the third position array corresponding to color value C. It is equivalent to concatenating and combining the third position arrays corresponding to the two color values to form the first position array.
[0118] In some embodiments, the coordinates of each color block in the first position array include the x-coordinate and y-coordinate values of the color block, and the size of the color block includes the length and height of the color block. Therefore, the first position array can be split into a one-dimensional x-coordinate array, y-coordinate array, length array, and height array; wherein the x-coordinate array includes the x-coordinate values of each color block, the y-coordinate array includes the y-coordinate values of each color block, the length array includes the length of each color block, and the height array includes the height of each color block; the x-coordinate array, y-coordinate array, length array, and height array are concatenated to obtain a one-dimensional concatenated array. Further, the concatenated array can be compressed, for example, by detecting duplicate elements in the concatenated array and compressing the duplicate elements to obtain compressed color block position data. It should be understood that by splitting and concatenating the four columns of data in the two-dimensional array (i.e., the first position array) into a one-dimensional array (i.e., the concatenated array), data redundancy can be improved, thereby increasing the compression rate.
[0119] Now combined Figure 8 and Figure 9 A diagram illustrating the concatenation of arrays is provided. For example... Figure 8 As shown, each column in the first position array can form a one-dimensional array. Specifically, the x-coordinate values in column 1 form an x-coordinate array, the y-coordinate values in column 2 form a y-coordinate array, the color block lengths in column 3 form a length array, and the color block heights in column 4 form a height array. Then, by sequentially concatenating the arrays corresponding to each column to form a one-dimensional array, we obtain... Figure 9 The concatenated array is shown below. For example, the first 9 elements of the concatenated array are the values in the x-coordinate array (not fully shown in the diagram, simplified with ellipses), the next 9 elements are the y-coordinate array, and so on, with the last 9 elements being the values in the height array. It should be noted that... Figure 9 This is just a simple illustration of array concatenation and does not impose any restrictions on the concatenation order of the arrays corresponding to each column.
[0120] like Figure 9 As shown, with Figure 2 Taking the target image as an example, the target image has a pixel size of 20×20, the background color value is A, and the color value array includes the number of color blocks corresponding to color values B and C (8 and 1 respectively). Figure 9 After compressing the concatenated array, the compressed data of the color block positions can be obtained (not shown in the figure). Combining the compressed data of the color block positions with the pixel size, background color, and color value array of the target image constitutes the pixel-level data to be encrypted.
[0121] In some embodiments, such as Figure 10 As shown, another method for encrypting information is provided, including the following steps:
[0122] S1001, Generate a two-dimensional array of pixels corresponding to the target image; the array elements in the two-dimensional array of pixels are the original color values of each pixel in the target image; perform difference calculation on the two-dimensional array of pixels to obtain a two-dimensional array of pixel differences; each pixel in the two-dimensional array of pixel differences corresponds to a difference color value, which is the color value after difference calculation on the original color value.
[0123] It should be understood that during differential calculation, the differential color value of some of the original color values is itself. For example, in Sub prediction mode, the original color value of the leftmost pixel has no left adjacent pixels, so its differential color value is the original color value itself.
[0124] S1002, divide the pixels with consecutive equal difference color values in the pixel difference two-dimensional array into the same rectangular color block, and generate a color block array based on the divided color blocks; wherein, the color block array includes the difference color value corresponding to each pixel in the target image and the second position array corresponding to each difference color value; the second position array corresponding to each difference color value includes the original color block coordinates and color block size corresponding to each color block with that difference color value.
[0125] It should be understood that each element in the second position array includes the original coordinates and size of a color block; the original coordinates include the original x-coordinate and the original y-coordinate of the color block; in the second position array, each element is sorted according to the size of its original x-coordinate, and elements with the same original x-coordinate are sorted according to the size of their original y-coordinate.
[0126] S1003, delete the first color value and its corresponding second position array from the color block array, and record the first color value as the background color; the first color value is the differential color value with the largest number of corresponding color blocks.
[0127] S1004, Generate a color value array based on each second color value and the number of color blocks corresponding to the second color value; the second color value is the differential color value in the color block array excluding the first color value; the second color values in the color value array are sorted according to a first order, which is either the order of the number of color blocks from largest to smallest or the order of the number of color blocks from smallest to largest.
[0128] S1005, for each second position array corresponding to the second color value, replace the original horizontal coordinate value of each target element in the second position array with the horizontal coordinate difference, and replace the original vertical coordinate value of the target element with the vertical coordinate difference, to obtain the third position array corresponding to the second color value; the target element is the element in the second position array excluding the first element; the horizontal coordinate difference is the difference between the original horizontal coordinate value of the target element and the previous element, and the vertical coordinate difference is the difference between the original vertical coordinate value of the target element and the previous element.
[0129] S1006, the third position arrays corresponding to each second color value are concatenated according to the first order of each second color value in the color value array to generate a first position array; wherein, each element of the first position array corresponds to a color block, and each element corresponds to the second color value of the corresponding color block; each element includes the color block coordinates and color block size, and the color block size includes the color block length and color block height; the color block coordinates of the first element corresponding to each second color value are the original color block coordinates (including the original horizontal coordinate value and the original vertical coordinate value), and the color block coordinates of the non-first elements are the coordinate differences (including the horizontal coordinate difference and the vertical coordinate difference).
[0130] S1007, split the first position array into an x-coordinate array, a y-coordinate array, a length array, and a height array; wherein, the x-coordinate array includes the x-coordinate difference of each color block, the y-coordinate array includes the y-coordinate difference of each color block, the length array includes the length of each color block, and the height array includes the height of each color block.
[0131] S1008 concatenates the horizontal coordinate array, vertical coordinate array, length array, and height array to obtain a concatenated array; then compresses the concatenated array to obtain compressed data of the color block positions.
[0132] S1009: Compress data based on the pixel size, color value array, and color block position of the target image to form pixel-level data to be encrypted; encrypt the pixel-level data to obtain the image encryption information corresponding to the target image.
[0133] In some embodiments, the target image is contained within the original information to be encrypted; the original information also includes first text information. In this embodiment, before step S11 performs color block division based on the color value corresponding to each pixel in the target image, the computer device can replace the target image in the original information with an image identifier (i.e., image number, used to uniquely identify the target image) corresponding to the target image, thus obtaining second text information. That is, the second text information includes the first text information and the image identifier. Furthermore, the second text information can be encrypted to obtain encrypted text information.
[0134] It should be understood that the original information may include one or more target images, and the encryption process described in this embodiment can be performed on each target image. After encrypting the target image according to the method described in this embodiment to obtain the corresponding image encryption information, the image encryption information can be stored in correspondence with its image identifier.
[0135] In this way, the original information is encrypted, including both image encryption and text encryption.
[0136] In some embodiments, encrypting the second text information to obtain encrypted text information includes the following steps:
[0137] (1) Convert the second text information (i.e. the string) into a one-dimensional first byte array.
[0138] (2) Convert the first byte array into a one-dimensional boolean array.
[0139] Specifically, each byte element in the first byte array can be converted into a two-dimensional boolean array with a column width of 8, and then the two-dimensional boolean array can be converted into a one-dimensional boolean array.
[0140] (3) Adjust the first preset number of elements in the one-dimensional Boolean array to the end of the one-dimensional Boolean array to update the one-dimensional Boolean array.
[0141] For example, you can delete the first two elements from a one-dimensional Boolean array and insert the deleted two elements at the end of the array. This achieves bit-level obfuscation, and this operation is specifically called a circular shift.
[0142] (4) Change the value of the input variable of the inverted position generation function continuously according to the preset rules, so that the inverted position generation function continuously generates new inverted positions. For each generated inverted position, invert the Boolean element corresponding to the inverted position in the current one-dimensional Boolean array until the generated inverted position is greater than or equal to the length of the one-dimensional Boolean array and then stop inverting.
[0143] It should be understood that the iterative inversion in step (4) can encrypt the data.
[0144] For example, step (4) includes the following sub-steps:
[0145] (4.1) Invert the y-th bit of the current one-dimensional Boolean array, where y = f(x) and the initial value of x is 0.
[0146] It should be understood that f(x) is the inverted position generator function, where x is the input variable and y is the inverted position. For example, if the y-th element in the current one-dimensional Boolean array is True, its inversion will result in False.
[0147] (4.2) The x value is incremented, and step (4.1) is repeated to invert the value until the y value is greater than or equal to the length of the one-dimensional Boolean array, at which point the inversion stops. It should be understood that the incrementing of the x value is the preset rule. The one-dimensional Boolean array changes after each inversion, and each inversion is performed on the latest one-dimensional Boolean array.
[0148] (5) Convert the one-dimensional Boolean array after stopping the inversion into a one-dimensional second byte array.
[0149] Specifically, a one-dimensional Boolean array after stopping the inversion can be converted into a two-dimensional Boolean array with a column width of 8. Then, the 8 Boolean elements of the two-dimensional Boolean array are converted into 1 U8 integer row by row, thereby converting the two-dimensional Boolean array into a one-dimensional second byte array.
[0150] (6) Convert the second byte array into a string to obtain the encrypted text information.
[0151] In some embodiments, the original information may include fault diagnosis method description information, used to describe the fault diagnosis method of the power module. For ease of description, the fault diagnosis method description information will be referred to as the fault diagnosis method below. This fault diagnosis method includes a target image and first text information, which is equivalent to describing the fault diagnosis method by combining the image and the text. The encrypted information obtained by encrypting the fault diagnosis method using the method in the embodiments of this application includes image encryption information of the target image and text encryption information of the first text information in the fault diagnosis method.
[0152] For example, the power module may have one or more faults. Therefore, each fault category can be assigned a fault identifier (i.e., fault number), and the troubleshooting methods corresponding to each fault category can be named and saved to obtain the fault name. Then, the correspondence table between fault names and fault identifiers is encrypted and saved. In addition, each fault identifier is associated with the encrypted information of the corresponding troubleshooting method and saved accordingly.
[0153] Therefore, when searching for troubleshooting methods for the power module, the corresponding fault identifier can be found based on the aforementioned correspondence table. Then, based on this fault identifier, the encrypted information of the corresponding troubleshooting method can be found. Next, the text encryption information within this encrypted information is decrypted to obtain the first text information, and the image encryption information within the encrypted information is also decrypted to obtain the pixel-level data corresponding to the target image. Furthermore, this pixel-level data is decompressed to accurately reconstruct the complete target image. Thus, the complete troubleshooting method is accurately obtained.
[0154] In some embodiments, where the pixel-level data includes the pixel size of the target image, a color value array, and compressed data of color block positions, the compressed data of color block positions can be decompressed to obtain a first position array. Then, the target image is generated based on the pixel size of the target image, the first position array, and the color value array.
[0155] It should be understood that the first position array represents the position information of each color block in the target image, which is equivalent to information in the position dimension. The color value array represents the color value and the number of color blocks in the target image, which is equivalent to information in the color dimension. By combining the two with the pixel size of the target image, the complete target image can be accurately reconstructed.
[0156] In some examples, an initial two-dimensional pixel array can be generated based on the pixel size of the target image. Each element in the initial pixel array corresponds to a pixel, but not every element records the actual color value; for example, it might record a default color value or an empty value. Therefore, based on the position information (coordinates and size of the color patch) recorded in the first position array and the color value information (color value and the number of corresponding color patches) recorded in the color value array, the corresponding color value at each element in the initial pixel array can be updated, thus obtaining the target pixel array. In this target pixel array, each element is filled with the corresponding color value, effectively determining the actual color value of each pixel directly or indirectly. By performing image conversion processing on the target pixel array, a complete and undistorted target image can be restored.
[0157] For example, if the pixel-level data also includes a first color value, then the color value (i.e., element value) recorded at each element position in the initial pixel two-dimensional array is the first color value. Subsequently, the color value recorded at the corresponding element position in the initial pixel two-dimensional array can be updated based on the first position array and the color value array. That is, the first position array records the position information of color blocks that do not have the first color value. Therefore, based on the first position array and the color value array, it is only necessary to update the color value of the element position corresponding to this part of the color blocks (i.e., color blocks that do not have the first color value) in the initial pixel two-dimensional array to obtain the aforementioned target pixel two-dimensional array, thereby enabling faster and more convenient reconstruction of the target image. This can improve decompression efficiency to a certain extent.
[0158] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0159] Based on the same inventive concept, this application also provides an information encryption device for implementing the information encryption method described above. The solution provided by this device is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more information encryption device embodiments provided below can be found in the limitations of the information encryption method described above, and will not be repeated here.
[0160] In one embodiment, such as Figure 11 As shown, an information encryption device is provided, comprising:
[0161] The color block division module 1102 is used to divide the target image into color blocks based on the color value corresponding to each pixel to obtain pure color blocks; there are one or more color blocks corresponding to the same color value.
[0162] The array generation module 1104 is used to generate a color value array and a first position array based on the divided color blocks; wherein, the color value array includes each color value in the target image and the number of color blocks corresponding to each color value; the first position array includes the color block coordinates and color block size corresponding to each color block.
[0163] Compression module 1106 is used to compress the first position array to obtain compressed data of color block positions.
[0164] The encryption module 1108 is used to compress data based on the pixel size of the target image, the color value array, and the color block position to form pixel-level data to be encrypted; and to encrypt the pixel-level data to obtain image encryption information corresponding to the target image.
[0165] Each module in the aforementioned information encryption device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of the computer device within the probe station device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0166] In one embodiment, a computer device is provided. Its internal structure diagram can be as follows: Figure 12As shown, this computer device may include a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements an information encryption method.
[0167] Those skilled in the art will understand that Figure 12 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0168] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the embodiments of the present application.
[0169] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the embodiments of this application.
[0170] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the embodiments of this application.
[0171] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0172] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0173] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0174] The above embodiments merely illustrate several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. An information encryption method, characterized in that, The method includes: The target image is divided into color blocks based on the color value corresponding to each pixel, resulting in solid color blocks; one or more color blocks correspond to the same color value. A color value array and a first position array are generated based on the divided color blocks; wherein, the color value array includes each color value in the target image and the number of color blocks corresponding to each color value; the first position array includes the color block coordinates and color block size corresponding to each color block; Compress the first position array to obtain compressed data of color block positions; Based on the pixel size of the target image, the color value array, and the compressed data of the color block positions, pixel-level data to be encrypted is formed; The pixel-level data is encrypted to obtain the image encryption information corresponding to the target image.
2. The method according to claim 1, characterized in that, The process of dividing the target image into color blocks based on the color value corresponding to each pixel to obtain pure color blocks includes: Generate a two-dimensional array of pixels; the two-dimensional array of pixels includes the original color value of each pixel in the target image; Perform a difference calculation on the pixel two-dimensional array to obtain a pixel difference two-dimensional array; the color value corresponding to each pixel in the pixel difference two-dimensional array is the color value after performing a difference calculation on the original color value; Pixels with consecutively equal color values in the pixel difference two-dimensional array are divided into the same rectangular color block.
3. The method according to claim 1, characterized in that, The generation of the color value array and the first position array based on the divided color blocks includes: A color block array is generated based on the divided color blocks; wherein, the color block array includes the color value corresponding to each pixel in the target image and a second position array corresponding to each color value; the second position array corresponding to each color value includes the color block coordinates and color block size corresponding to each color block with the color value; Determine the number of color blocks corresponding to each color value in the color block array, and generate a color value array based on each color value and the corresponding number of color blocks in the color block array; The first position array is generated based on the second position array corresponding to each of the color values.
4. The method according to claim 3, characterized in that, The pixel-level data also includes a first color value, which is the color value corresponding to the largest number of color blocks; The step of generating a color value array based on each color value in the color block array and the corresponding number of color blocks includes: A color value array is generated based on each second color value and the number of color blocks corresponding to the second color value; the second color value is a color value in the color block array other than the first color value. The step of generating the first position array based on the second position array corresponding to each of the color values includes: The first position array is generated based on the second position array corresponding to each of the second color values.
5. The method according to claim 3, characterized in that, The color block coordinates in the second position array are the original color block coordinates; each element in the second position array includes the original color block coordinates and the color block size; the original color block coordinates include the original horizontal coordinate value and the original vertical coordinate value of the color block; in the second position array, each element is sorted according to the size relationship of the original horizontal coordinate values, and elements corresponding to the same original horizontal coordinate are sorted according to the size relationship of the original vertical coordinate values. The step of generating the first position array based on the second position array corresponding to each of the color values includes: For each color value corresponding to the second position array, the original horizontal coordinate value in each target element of the second position array is replaced with the horizontal coordinate difference, and the original vertical coordinate value of the target element is replaced with the vertical coordinate difference, to obtain the third position array corresponding to the color value; the target element is the element in the second position array excluding the first element; the horizontal coordinate difference is the difference between the original horizontal coordinate value of the target element and the previous element, and the vertical coordinate difference is the difference between the original vertical coordinate value of the target element and the previous element; The first position array is generated based on the third position array corresponding to each of the color values.
6. The method according to claim 1, characterized in that, The coordinates of each color block in the first position array include the x-coordinate and y-coordinate values of the color block, and the size of the color block includes the length and height of the color block; The step of compressing the first position array to obtain compressed color block position data includes: The first position array is split into an x-coordinate array, a y-coordinate array, a length array, and a height array; wherein, the x-coordinate array includes the x-coordinate value of each color block, the y-coordinate array includes the y-coordinate value of each color block, the length array includes the length of each color block, and the height array includes the height of each color block. The horizontal coordinate array, the vertical coordinate array, the length array, and the height array are concatenated to obtain a concatenated array; The spliced array is compressed to obtain the compressed data of the color block positions.
7. The method according to claim 1, characterized in that, The color values in the color value array are sorted in a first order, which is either an order of decreasing or increasing number of color blocks. Each element in the first position array corresponds to a color block, and each element corresponds to the color value of the corresponding color block; each element includes the color block coordinates and the color block size; the elements in the first position array are sorted sequentially according to the order of their corresponding color values in the color value array.
8. The method according to any one of claims 1 to 7, characterized in that, The target image contains the original information to be encrypted; the original information also includes first text information; the encryption information of the original information includes the image encryption information and the text encryption information. Before dividing the image into color blocks based on the color value corresponding to each pixel in the target image, the method further includes: The target image in the original information is replaced with the image identifier corresponding to the target image to obtain the second text information, and the second text information is encrypted to obtain the encrypted text information; After obtaining the image encryption information, the method further includes: The image encryption information is stored in correspondence with the image identifier.
9. The method according to claim 8, characterized in that, The step of encrypting the second text information to obtain the encrypted text information includes: Convert the second text information into a one-dimensional first byte array; Convert the first byte array into a one-dimensional boolean array; The first preset number of elements in the one-dimensional Boolean array are moved to the end of the one-dimensional Boolean array to update the one-dimensional Boolean array; The input variable of the inverted position generation function is continuously changed according to the preset rules, so that the inverted position generation function continuously generates new inverted positions. For each generated inverted position, the Boolean element corresponding to the inverted position in the current one-dimensional Boolean array is inverted until the generated inverted position is greater than or equal to the length of the one-dimensional Boolean array, and then the inversion stops. Convert the one-dimensional boolean array after stopping the inversion into a one-dimensional second-byte array; The second byte array is converted into a string to obtain the encrypted text information.
10. An information encryption device, characterized in that, The device includes: The color block segmentation module is used to segment the target image into color blocks based on the color value corresponding to each pixel, thereby obtaining solid color blocks; the same color value corresponds to one or more color blocks. An array generation module is used to generate a color value array and a first position array based on the divided color blocks; wherein, the color value array includes each color value in the target image and the number of color blocks corresponding to each color value; the first position array includes the color block coordinates and the color block size corresponding to each color block; A compression module is used to compress the first position array to obtain compressed data of the color block positions; An encryption module is used to compress data based on the pixel size of the target image, the color value array, and the color block position to form pixel-level data to be encrypted; and to encrypt the pixel-level data to obtain image encryption information corresponding to the target image.
11. A computer device, characterized in that, The method includes a memory and a processor, the memory storing a computer program, characterized in that the processor executes the computer program to implement the steps of the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Image processing method and device, computer equipment and storage medium
CN112541868A
Validation using key pairs and interprocess communications
US20200134598A1