Image Encryption Processing Method, Device, Equipment and Storage Medium
By transforming and inserting the two-dimensional matrix data of grayscale images, a target matrix group is generated, and combining optical disk storage and encryption check value, the problem of difficulty in balancing complexity and efficiency of image encryption methods in the prior art is solved, and safe and efficient image encryption is achieved.
Patent Information
- Application Number
- CN202411931774.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2044-12-26
AI Technical Summary
Existing image encryption methods are difficult to balance the encryption complexity and processing efficiency. When the password setting is complex, the decoding process is complex and inefficient, and when it is simple, it is easy to be deciphered.
By transforming the two-dimensional matrix data of the grayscale image, a transform sub-matrix including a transpose matrix, a diagonal matrix and a product matrix are generated, and inserted between the two-dimensional sub-matrixes according to preset rules to form a target matrix group, and combining the optical disk storage and the generation of encryption check values to achieve encryption and decryption.
It realizes that the encryption of grayscale images is both regular and difficult to decipher, effectively balances the encryption complexity and processing efficiency, and is suitable for the secure transmission and storage of confidential files.
Smart Images

Figure CN119835371B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the technical field of image processing, and in particular, to an image encryption processing method, an image decryption processing method, a device, and a computer-readable storage medium. Background Art
[0002] With the development of informatization, more and more information is carried by images, and more and more information is stored and transmitted in the form of images. However, since images are relatively easy to copy and spread, while enjoying the convenience of information transmission, the security requirements for the process of image storage and transmission are also getting higher and higher.
[0003] In order to improve the security of image transmission, the image is generally encrypted first and then decrypted at the receiving end. However, the existing encryption or decryption methods have relatively weak security. When the password is set complex, the deciphering difficulty is high, but this makes the decoding process more complex and the decoding efficiency low. When the password is set simply, the decoding speed is fast but it is relatively easy to be deciphered.
[0004] Therefore, in the related art, no effective solution has been proposed for how to balance the encryption complexity and the processing efficiency in the image encryption and decryption methods. Summary of the Invention
[0005] In view of the above problems, embodiments of the present invention provide an image encryption processing method, apparatus, device, and system for solving the problem of being unable to balance the encryption complexity and the processing efficiency in the prior art.
[0006] According to one aspect of the embodiments of the present invention, an image encryption processing method is provided, and the method includes:
[0007] Obtain two-dimensional matrix data of a grayscale image to be encrypted; in the two-dimensional matrix data, each two-dimensional matrix element is the grayscale value of the pixel at the corresponding position;
[0008] Perform a first transformation process on the two-dimensional matrix data to obtain a first transformation matrix group; the first transformation matrix group includes N layers of two-dimensional sub-matrices; wherein, a two-dimensional sub-matrix element of the Nth two-dimensional sub-matrix is the grayscale value of the pixel at the Nth position, and the remaining two-dimensional sub-matrix elements are 0, and N is an integer greater than 0;
[0009] Perform a transformation on the two-dimensional matrix data according to at least one transformation rule to obtain at least one transformation sub-matrix; the at least one transformation rule includes at least one of calculating a transpose matrix, calculating a diagonal matrix, and calculating the product of a transpose matrix and a diagonal matrix;
[0010] Add the at least one transformation sub - matrix to the first transformation matrix group according to a preset addition rule to obtain the target matrix group of the grayscale image to be encrypted, so as to complete the encryption of the grayscale image to be encrypted; the preset addition rule includes circularly inserting the at least one transformation sub - matrix between each two - dimensional sub - matrix.
[0011] In an embodiment of the present invention, the transformation rule includes calculating the transpose matrix of two - dimensional matrix data, calculating the diagonal matrix of two - dimensional matrix data, and calculating the product matrix of the transpose matrix and the diagonal matrix; the preset addition rule is to circularly insert the transpose matrix, the diagonal matrix, and the product matrix between each two - dimensional sub - matrix.
[0012] In an embodiment of the present invention, transforming the two - dimensional matrix data according to at least one transformation rule to obtain at least one transformation sub - matrix includes:
[0013] Calculate the transpose matrix of the two - dimensional matrix data to obtain the transpose matrix;
[0014] Calculate the diagonal matrix of the two - dimensional matrix data to obtain the diagonal matrix;
[0015] Calculate the product of the transpose matrix and the diagonal matrix of the two - dimensional matrix data to obtain the product matrix;
[0016] The step of adding the at least one transformation sub - matrix to the first transformation matrix group according to a preset addition rule to obtain the target matrix group of the grayscale image to be encrypted includes:
[0017] Group the N - layer two - dimensional sub - matrices in the first transformation matrix group in order, with three in a group, to obtain multiple groups of matrix subgroups;
[0018] For each group of matrix subgroups, add the transpose matrix after the first two - dimensional sub - matrix, add the diagonal matrix after the second two - dimensional sub - matrix, and add the product matrix after the third two - dimensional sub - matrix to obtain the target matrix group; where the first two - dimensional sub - matrix, the second two - dimensional sub - matrix, and the third two - dimensional sub - matrix are different two - dimensional sub - matrices in each group of matrix subgroups respectively.
[0019] In an embodiment of the present invention, for each group of matrix subgroups, adding the transpose matrix after the first two - dimensional sub - matrix, adding the diagonal matrix after the second two - dimensional sub - matrix, and adding the product matrix after the third two - dimensional sub - matrix to obtain the target matrix group includes:
[0020] Use the division algorithm with remainder to solve for the multiple positions in the first transformation matrix group where the transpose matrix, the diagonal matrix, and the product matrix are respectively added;
[0021] Add the transpose matrix, the diagonal matrix, and the product matrix between the N - layer two - dimensional sub - matrices according to the multiple added positions.
[0022] In an embodiment of the present invention, the obtaining of the two - dimensional matrix data of the grayscale image to be encrypted further includes: obtaining the binary storage data of the grayscale image to be encrypted; converting the binary storage data into the two - dimensional matrix data.
[0023] In an embodiment of the present invention, after storing the digitized values in sequence on the optical disc, the method further includes: obtaining the content identification information of the optical disc; generating an encrypted check value after encrypting according to the content identification information of the optical disc using a preset encryption algorithm; storing the encrypted check value in the optical disc check storage area of the host.
[0024] In an embodiment of the present invention, after adding the at least one transformation sub - matrix into the first transformation matrix group according to a preset addition rule to obtain the target matrix group of the grayscale image to be encrypted, the method further includes:
[0025] Digitally encoding each target matrix in the target matrix group to obtain digitized values; the target matrix is each matrix in the target matrix group;
[0026] Storing the digitized values in sequence on the optical disc.
[0027] In an embodiment of the present invention, the obtaining of the two - dimensional matrix data of the grayscale image to be encrypted further includes: obtaining the binary storage data of the grayscale image to be encrypted; converting the binary storage data into the two - dimensional matrix data.
[0028] An embodiment of the present application also proposes an image decryption processing method, including:
[0029] Reading the target matrix group of the grayscale image to be decrypted; the target matrix group is obtained by adding the N - layer two - dimensional sub - matrices of the first transformation matrix group into the first transformation matrix group according to a preset addition rule; the transformation sub - matrix group is obtained by transforming the two - dimensional matrix data of the grayscale image to be encrypted according to at least one transformation rule; the first transformation matrix group includes N - layer two - dimensional sub - matrices; the at least one transformation rule includes at least one of calculating the transpose matrix, calculating the diagonal matrix, and calculating the product of the transpose matrix and the diagonal matrix; the preset addition rule includes circularly inserting the at least one transformation sub - matrix between each two - dimensional sub - matrix;
[0030] Delete the transformation sub - matrices in the target matrix group according to a preset deletion rule to obtain a first transformation matrix group; the preset deletion rule is a rule inverse to the preset addition rule;
[0031] Perform a first inverse transformation process on the first transformation matrix group to obtain two - dimensional matrix data, thereby completing the decryption of the to - be - decrypted grayscale image; among them, in the two - dimensional matrix data, each two - dimensional matrix element is the grayscale value of the pixel at the corresponding position; the grayscale value of the pixel at the Nth position in the two - dimensional matrix data is a two - dimensional matrix element of the Nth two - dimensional sub - matrix, where N is an integer greater than 0.
[0032] In an embodiment of the present invention, the reading of the target matrix group of the to - be - decrypted grayscale image includes:
[0033] Read the data in the optical disc through a laser probe to obtain digitized values;
[0034] Decode the digitized values to obtain a target matrix group.
[0035] An embodiment of the present application also provides a computer device, including: a processor, a memory, a communication interface, and a communication bus. The processor, the memory, and the communication interface complete mutual communication through the communication bus;
[0036] The memory is used to store at least one executable instruction, and the executable instruction causes the processor to execute the above - mentioned image encryption processing method or image decryption method.
[0037] An embodiment of the present application also provides a computer - readable storage medium. At least one executable instruction is stored in the storage medium. When the executable instruction runs on a computer device, the computer device is caused to execute the above - mentioned image encryption processing method or image decryption method.
[0038] In an embodiment of the present invention, by obtaining the two - dimensional matrix data of the grayscale image to be encrypted, performing a first transformation process on the two - dimensional matrix data to obtain a first transformation matrix group; performing transformations on the two - dimensional matrix data according to at least one transformation rule to obtain at least one transformation sub - matrix, and adding the at least one transformation sub - matrix into the first transformation matrix group according to a preset addition rule to obtain the target matrix group of the to - be - encrypted grayscale image, so as to complete the encryption of the to - be - encrypted grayscale image. This makes the data storage of the grayscale image change from planar to three - dimensional, inserts a data interlayer in the middle, and the data interlayer generates different planar square matrices according to the characteristics of the given grayscale image, and these generated square matrices are arranged in the order of three in a group, three in a group, and the password is set regularly; because the generated square matrices of different images are different, the password is difficult to decipher. This makes the encryption of the grayscale image regular and difficult to decipher, and can effectively balance the encryption complexity and processing efficiency.
[0039] The above description is only an overview of the technical solution of the embodiment of the present invention. In order to be able to more clearly understand the technical means of the embodiment of the present invention, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the embodiment of the present invention more obvious and understandable, the following specifically describes the specific embodiments of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The drawings are only used to illustrate the embodiments and are not considered as a limitation to the present invention. Moreover, throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:
[0041] Figure 1 shows a schematic flowchart of an image encryption processing method provided by an embodiment of the present invention;
[0042] Figure 2 shows a schematic diagram of a grayscale image of an image encryption processing method provided by an embodiment of the present invention;
[0043] Figure 3 shows a schematic flowchart of an image decryption processing method provided by another embodiment of the present invention;
[0044] Figure 4 shows a structural diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0045] Hereinafter, exemplary embodiments of the present invention will be described in more detail with reference to the drawings. Although the exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein.
[0046] As Figure 1 shown, it shows a schematic flowchart of an image encryption processing method provided by an embodiment of the present invention. This method is executed by a computer device, such as a desktop computer, a tablet computer, a personal computer, etc., and the embodiments of the present invention do not make specific limitations. As Figure 1 shown, the method includes the following steps:
[0047] Step 110: Obtain two-dimensional matrix data of a grayscale image to be encrypted. Among them, in the two-dimensional matrix data, each two-dimensional matrix element is the grayscale value of the pixel at the corresponding position.
[0048] Among them, the grayscale image can be a black-and-white image, such as an exam paper of a black-and-white image or a confidential image file, etc. The grayscale image is stored in binary in a computer. In the embodiments of the present invention, the binary storage data of the grayscale image to be encrypted is obtained; the binary storage data is converted into the two-dimensional matrix data. For the two-dimensional matrix data of the grayscale image, each element in the two-dimensional matrix data represents the grayscale value of a pixel. The two-dimensional matrix representation of the grayscale image matrix is as follows:
[0049] For a grayscale image, its grayscale value is 0 to 255. For example, a 3×3 grayscale image can be represented as follows: The grayscale value of the grayscale image is 0 to 255. For example, for a 2×2 grayscale image, the two-dimensional matrix data is a "1-layer" matrix in a two-dimensional space, and the two-dimensional matrix A' can be represented as: Among them, the matrix in represents the grayscale value of the first pixel in the first row, represents the grayscale value of the second pixel in the first row, represents the grayscale value of the first pixel in the second row, represents the grayscale value of the second pixel in the second row.
[0050] Step 120: Perform a first transformation process on the two-dimensional matrix data to obtain a first transformation matrix group; the first transformation matrix group includes N layers of two-dimensional sub-matrices.
[0051] Among them, as Figure 3 shown, one two-dimensional sub-matrix element of the Nth two-dimensional sub-matrix is the grayscale value of the pixel at the Nth position, and the remaining two-dimensional sub-matrix elements are 0, where N is an integer greater than 0.
[0052] In the embodiments of the present invention, the two-dimensional matrix A is dimensionally transformed to obtain N layers of two-dimensional sub-matrices. The first two-dimensional sub-matrix element of the Nth two-dimensional sub-matrix is the grayscale value of the pixel at the Nth position, and the remaining two-dimensional sub-matrix elements are 0. Continuing with the above example, for the two-dimensional matrix A, after dimensional transformation, N two-dimensional sub-matrices are obtained, which are represented as: , where, except that the element in the first row and the first column is , are the respective elements in the two-dimensional matrix A, and the remaining elements are all 0. That is, for the first two-dimensional sub-matrix, = ; for the second two-dimensional sub-matrix, = , until all the elements in the two-dimensional matrix A are traversed to obtain N two-dimensional sub-matrices, where N is .
[0053] Among them, for a 2×2 matrix , it is split into four two-dimensional sub-matrices: .
[0054] Step 130: Transform the two-dimensional matrix data according to at least one transformation rule to obtain at least one transformed sub-matrix.
[0055] Among them, at least one transformation rule includes at least one of calculating a transpose matrix, calculating a diagonal matrix, and calculating a product matrix of a transpose matrix and a diagonal matrix.
[0056] In one embodiment of the present invention, three transformation rules are adopted, namely calculating a transpose matrix, calculating a diagonal matrix, and calculating a product of a transpose matrix and a diagonal matrix. Among them, calculate the transpose matrix of the two-dimensional matrix data to obtain a transpose matrix; calculate the diagonal matrix of the two-dimensional matrix data to obtain a diagonal matrix; calculate the product of the transpose matrix and the diagonal matrix of the two-dimensional matrix data to obtain a product matrix. Specifically, the transpose matrix B = , the diagonal matrix C only retains the values of the elements on the diagonal of the two-dimensional matrix data A, and the values of other positions are all 0; calculate the product matrix D = BC of the transpose matrix and the diagonal matrix.
[0057] Step 140: Add the at least one transformed sub-matrix to the first transformation matrix group according to a preset addition rule to obtain the target matrix group of the grayscale image to be encrypted, so as to complete the encryption of the grayscale image to be encrypted.
[0058] Among them, the preset addition rule includes cyclically inserting the at least one transformed sub-matrix between each two-dimensional sub-matrix. In a specific implementation of the present invention, the transpose matrix, the diagonal matrix, and the product matrix are cyclically inserted between each two-dimensional sub-matrix. In one embodiment of the present invention, the N layers of two-dimensional sub-matrices in the first transformation matrix group are grouped, three in a group, to obtain multiple groups of matrix subgroups; for each group of matrix subgroups, add the transpose matrix after the first two-dimensional sub-matrix, add the diagonal matrix after the second two-dimensional sub-matrix, and add the product matrix after the third two-dimensional sub-matrix to obtain the target matrix group; among them, the first two-dimensional sub-matrix, the second two-dimensional sub-matrix, and the third two-dimensional sub-matrix are different two-dimensional sub-matrices in each group of matrix subgroups. That is to say, the transpose matrix, the diagonal matrix, and the product matrix are cyclically inserted between each two-dimensional sub-matrix in turn.
[0059] For example, among them, for a 2×2 matrix , it is split into four two-dimensional sub-matrices: , after adding the transpose matrix, the diagonal matrix, and the product matrix in turn, it becomes: .
[0060] Among them, in order to improve the efficiency during encryption, the embodiments of the present invention use the division algorithm with remainder to solve for the multiple positions respectively added by the transpose matrix, the diagonal matrix, and the product matrix in the first transformation matrix group; according to the multiple added positions, the transpose matrix, the diagonal matrix, and the product matrix are added between the N - layer two - dimensional sub - matrices. Specifically, for N two - dimensional sub - matrices, there is , where the transpose matrix is inserted into the first interlayer = The diagonal matrix is inserted into the second interlayer , and the product matrix is inserted into the third interlayer . The matrix in the fourth interlayer is the same as the matrix in the first interlayer, the matrix in the fifth interlayer is the same as the matrix in the second interlayer, the matrix in the sixth interlayer is the same as the matrix in the third interlayer, and so on. Use the division algorithm with remainder to find out which interlayer among the first, second, and third interlayers the matrix inserted into the th interlayer is the same as: = 3 + r, where ∈ r∈ and 0 ≤r 3.
[0061] Among them, is the number of interlayers, is the quotient, and r is the remainder. When r = 0, = 3 , indicating that the matrix inserted into the current interlayer should be the same as the matrix corresponding to the third interlayer, that is, the product matrix . When r = 1, = 3 , indicating that the matrix inserted into the current interlayer should be the same as the matrix corresponding to the first interlayer, that is, the transpose matrix . When r = 2, = 3 , indicating that the matrix inserted into the current interlayer should be the same as the matrix corresponding to the second interlayer, that is, the diagonal matrix . Through the division algorithm with remainder, the matrix inserted into the interlayer between each two - dimensional sub - matrix can be quickly determined, thus effectively improving the encryption efficiency.
[0062] After step 140, embodiments of the present invention further digitally encode each target matrix in the target matrix group to obtain a digitized value; the target matrix is each matrix in the target matrix group; and the digitized values are sequentially stored in an optical disc in order. Specifically, in a specific implementation of the present invention, lossless encoding can be used to digitally encode each target matrix to obtain a digitized value, and the lossless encoding method can be run-length encoding or Huffman encoding. Arrange the digitized values in the order after encoding, and add file header information in front of the encoded data. The file header information includes basic attributes of the image, such as the width and height of the image (in pixels), color mode (grayscale, RGB, CMYK, etc.), encoding method, etc. Through the optical disc writing interface, the formatted image data is sent to the optical disc drive, and the laser head in the optical disc drive forms physical marks on the recording layer of the optical disc according to the binary encoding of the data to store the data. Among them, the optical disc drive modulates the intensity of the output beam of the laser source by the host optical modulator to represent data 1 and 0; then the modulated laser beam is focused by the objective lens through the optical path writing system, so that the beam becomes a light spot of size 1 and is projected onto the recording medium, with a pit representing 1 and no pit representing 0. Among them, after storing the data of the encrypted grayscale image in the optical disc, content identification information corresponding to the optical disc is generated in the optical disc. To further enhance the security of the stored image, after embodiments of the present invention sequentially store the digitized values in the optical disc in order, they also obtain the content identification information of the optical disc; after encrypting according to the content identification information of the optical disc using a preset encryption algorithm, a first encrypted verification value is generated; the encrypted verification value is stored in the optical disc verification storage area of the cloud platform, and the first transformation processing algorithm, transformation rules, and preset addition rules are stored in the rule storage area, so that when the image decryption processing device reads the optical disc, it needs to first read the content identification information of the optical disc, encrypt it using a preset encryption algorithm, generate a second encrypted verification value, and then verify it with the first encrypted verification value of the cloud platform. When the verification passes, the cloud platform sends the first transformation processing algorithm, transformation rules, and preset addition rules in the rule storage area to the image decryption processing device. In this way, the intensity of image data encryption is further enhanced.
[0063] In an embodiment of the present invention, by obtaining two-dimensional matrix data of a grayscale image to be encrypted, performing a first transformation process on the two-dimensional matrix data to obtain a first transformation matrix group; performing a transformation on the two-dimensional matrix data according to at least one transformation rule to obtain at least one transformation sub-matrix, and adding the at least one transformation sub-matrix to the first transformation matrix group according to a preset addition rule to obtain a target matrix group of the grayscale image to be encrypted, so as to complete the encryption of the grayscale image to be encrypted. This makes the data storage of the grayscale image change from planar to three-dimensional, inserts a data interlayer in the middle, and the data interlayer generates different planar square matrices according to the characteristics of the given grayscale image, and these generated square matrices are arranged in the order of three in a group, three in a group, and the password is set regularly; since the generated square matrices of different images are different, the password is difficult to decipher, which makes the encryption of the grayscale image regular and difficult to decipher, and effectively balances the encryption complexity and processing efficiency. In an embodiment of the present invention, in this way, in practical applications, confidential documents such as exam papers can be effectively protected. For example, when the black and white image of an exam paper is transmitted from a computer to a printer, encryption transmission is performed through the encryption method of the embodiment of the present invention, realizing the encrypted printing of the exam paper.
[0064] As Figure 2 shown, a schematic flowchart of an image decryption processing method provided by an embodiment of the present invention is shown. This method is executed by a computer device, and the computer device can be an image reading device, such as a smart printing device, a special computer device for exams, etc., and the embodiment of the present invention does not make specific limitations. As Figure 2 shown, the method includes the following steps:
[0065] Step 210: Read the target matrix group of the grayscale image to be decrypted.
[0066] Among them, data in an optical disc is read through a laser probe to obtain a digitized value. Among them, when reading information, the power of the laser beam is one-tenth of the power when writing. The read beam is an unmodulated continuous wave, and after passing through the optical path system, it is focused into a small light spot on the recording medium. Where there is no depression, most of the incident light returns; in the depression, due to the pit depth, the reflected light cancels out the incident light and does not return. In this way, the "1" and "0" information recorded on the medium is read according to the difference in the beam reflection ability. In an embodiment of the present invention, after obtaining the digitized value, the digitized value is decoded to obtain a target matrix group.
[0067] In the embodiment of the present invention, the content identification information of the optical disc is first read, encrypted by a preset encryption algorithm, and a second encrypted verification value is generated and verified with the first encrypted verification value of the cloud platform. When the verification is passed, the cloud platform sends the first transformation processing algorithm, transformation rules, and preset addition rules of the rule storage area to the image decryption processing device, so that the image decryption processing device can process the target matrix group according to the transformation inverse to the first transformation processing algorithm, transformation rules, and preset addition rules.
[0068] Among them, the target matrix group is obtained by adding the N-layer two-dimensional sub-matrices of the first transformation matrix group to the first transformation matrix group according to a preset addition rule; the transformation sub-matrix group is obtained by transforming the two-dimensional matrix data of the grayscale image to be encrypted according to at least one transformation rule; the first transformation matrix group includes N-layer two-dimensional sub-matrices; the at least one transformation rule includes at least one of calculating the transpose matrix, calculating the diagonal matrix, and calculating the product of the transpose matrix and the diagonal matrix; the preset addition rule includes cyclically inserting the at least one transformation sub-matrix between each two-dimensional sub-matrix.
[0069] Step 220: Delete the transformation sub-matrices in the target matrix group according to a preset deletion rule to obtain the first transformation matrix group.
[0070] Among them, the transformation sub-matrix is obtained by transforming two-dimensional matrix data according to at least one transformation rule; the at least one transformation rule includes at least one of calculating the transpose matrix, calculating the diagonal matrix, and calculating the product of the transpose matrix and the diagonal matrix; the first transformation matrix group includes N-layer two-dimensional sub-matrices.
[0071] Among them, the preset deletion rule is the rule inverse to the preset addition rule. According to the foregoing embodiments, when encrypting the original grayscale image, the positions where the transpose matrix, the diagonal matrix, and the product matrix are respectively added in the first transformation matrix group are obtained by using the division algorithm with remainder; according to the obtained positions, the transpose matrix, the diagonal matrix, and the product matrix are added between the N-layer two-dimensional sub-matrices to obtain the target matrix group. Among them, for two-dimensional sub-matrices, there are where the transpose matrix is inserted into the first interlayer = the diagonal matrix is inserted into the second interlayer and the product matrix is inserted into the third interlayer 。The matrix in the 4th interlayer is the same as the matrix in the 1st interlayer, the matrix in the 5th interlayer is the same as the matrix in the 2nd interlayer, the matrix in the 6th interlayer is the same as the matrix in the 3rd interlayer, and so on. Therefore, when the embodiment of the present invention deletes the transformation sub-matrices in the target matrix group according to the preset deletion rule to obtain the first transformation matrix group, the preset deletion rule can be to delete the matrices in the target matrix group at intervals.
[0072] Step 230: Perform a first inverse transformation process on the first transformation matrix group to obtain the two-dimensional matrix data of the grayscale image to be decrypted, thereby completing the decryption of the grayscale image to be decrypted.
[0073] Among them, in the two-dimensional matrix data, each two-dimensional matrix element is the grayscale value of the pixel at the corresponding position of the original grayscale image; the grayscale value of the pixel at the Nth position in the two-dimensional matrix data is a two-dimensional matrix element of the Nth two-dimensional sub-matrix, where N is an integer greater than 0. The first two-dimensional matrix element of the Nth two-dimensional sub-matrix is the grayscale value of the Nth position pixel, and the remaining two-dimensional matrix elements are 0, where N is an integer greater than 0. Therefore, the first inverse transformation process is: taking the first two-dimensional matrix element of the Nth two-dimensional sub-matrix as the Nth two-dimensional matrix element in the two-dimensional matrix data. Through the first inverse transformation process, the two-dimensional matrix data of the grayscale image to be decrypted is obtained, and the decryption of the grayscale image to be decrypted is completed.
[0074] After completing the decryption of the grayscale image to be decrypted, the embodiment of the present invention also reads each two-dimensional matrix element in the two-dimensional matrix data; maps each two-dimensional matrix element to the grayscale value of the pixel at the corresponding position on the screen, thereby generating an image.
[0075] In the embodiment of the present invention, by obtaining the two-dimensional matrix data of the grayscale image to be encrypted, performing a first transformation process on the two-dimensional matrix data to obtain a first transformation matrix group; performing a transformation on the two-dimensional matrix data according to at least one transformation rule to obtain at least one transformation sub-matrix, and adding the at least one transformation sub-matrix to the first transformation matrix group according to a preset addition rule to obtain the target matrix group of the grayscale image to be encrypted, so as to complete the encryption of the grayscale image to be encrypted. This makes the data storage of the grayscale image change from planar to three-dimensional, inserts data interlayers in the middle, and the data interlayers generate different planar square matrices according to the characteristics of the given grayscale image, and these generated square matrices are arranged in groups of three, groups of three, and the password setting is regular; since the generated square matrices of different images are different, the password is difficult to decipher. This makes the encryption of the grayscale image both regular and difficult to decipher, so that the encryption complexity and processing efficiency can be effectively balanced.
[0076] The embodiment of the present application also proposes a computer device, such as Figure 4As shown in the figure. The computer device may include: a processor 302, a communications interface 304, a memory 306, and a communication bus 308.
[0077] Among them: The processor 302, the communications interface 304, and the memory 306 communicate with each other through the communication bus 308. The communications interface 304 is used to communicate with network elements of other devices such as clients or other servers. The processor 302 is used to execute the program 310, and specifically can execute the relevant steps in the above embodiments of the method for image encryption processing or image decryption processing.
[0078] Specifically, the program 310 may include program code, and the program code includes computer-executable instructions.
[0079] The processor 302 may be a central processing unit CPU, or a specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present invention. One or more processors included in the visualization network terminal may be of the same type of processor, such as one or more CPUs; or may be of different types of processors, such as one or more CPUs and one or more ASICs.
[0080] The memory 306 is used to store the program 310. The memory 306 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk memory.
[0081] The program 310 can specifically be called by the processor 302 to cause the computer device to perform the following operations:
[0082] Obtain two-dimensional matrix data of the grayscale image to be encrypted; in the two-dimensional matrix data, each two-dimensional matrix element is the grayscale value of the pixel at the corresponding position; perform a first transformation process on the two-dimensional matrix data to obtain a first transformation matrix group; the first transformation matrix group includes N layers of two-dimensional sub-matrices; wherein, one two-dimensional sub-matrix element of the Nth two-dimensional sub-matrix is the grayscale value of the pixel at the Nth position, and the remaining two-dimensional sub-matrix elements are 0, and N is an integer greater than 0;
[0083] Perform a transformation on the two-dimensional matrix data according to at least one transformation rule to obtain at least one transformation sub-matrix; the at least one transformation rule includes at least one of calculating a transpose matrix, calculating a diagonal matrix, and calculating the product of a transpose matrix and a diagonal matrix;
[0084] Add the at least one transformation sub - matrix into the first transformation matrix group according to a preset addition rule to obtain the target matrix group of the grayscale image to be encrypted, so as to complete the encryption of the grayscale image to be encrypted; or, read the target matrix group of the grayscale image to be decrypted;
[0085] Delete the transformation sub - matrix in the target matrix group according to a preset deletion rule to obtain the first transformation matrix group; the transformation sub - matrix is obtained by transforming two - dimensional matrix data or N - layer two - dimensional sub - matrices in the first transformation matrix group according to at least one transformation rule; the at least one transformation rule includes at least one of calculating the transpose matrix, calculating the diagonal matrix, and calculating the product of the transpose matrix and the diagonal matrix; the first transformation matrix group includes N - layer two - dimensional sub - matrices;
[0086] Perform a first inverse transformation process on the first transformation matrix group to obtain the two - dimensional matrix data of the decrypted grayscale image; wherein, the grayscale value of the pixel at the Nth position in the two - dimensional matrix data is an element of a two - dimensional sub - matrix of the Nth two - dimensional sub - matrix, and N is an integer greater than 0.
[0087] In an embodiment of the present invention, the transformation rules include calculating the transpose matrix of two - dimensional matrix data, calculating the diagonal matrix of two - dimensional matrix data, and calculating the product matrix of the transpose matrix and the diagonal matrix; the preset addition rule is to circularly insert the transpose matrix, the diagonal matrix, and the product matrix between each two - dimensional sub - matrix.
[0088] In an embodiment of the present invention, transforming the two - dimensional matrix data according to at least one transformation rule to obtain at least one transformation sub - matrix includes:
[0089] Calculate the transpose matrix of the two - dimensional matrix data to obtain the transpose matrix;
[0090] Calculate the diagonal matrix of the two - dimensional matrix data to obtain the diagonal matrix;
[0091] Calculate the product of the transpose matrix and the diagonal matrix of the two - dimensional matrix data to obtain the product matrix;
[0092] The step of adding the at least one transformation sub - matrix into the first transformation matrix group according to a preset addition rule to obtain the target matrix group of the grayscale image to be encrypted includes:
[0093] Group the N - layer two - dimensional sub - matrices in the first transformation matrix group in order, with three in a group, to obtain multiple groups of matrix subgroups;
[0094] For each group of matrix subgroups, add the transposed matrix after the first two-dimensional submatrix, add the diagonal matrix after the second two-dimensional submatrix, and add the product matrix after the third two-dimensional submatrix to obtain the target matrix group; wherein, the first two-dimensional submatrix, the second two-dimensional submatrix, and the third two-dimensional submatrix are different two-dimensional submatrices in each group of matrix subgroups respectively.
[0095] In an embodiment of the present invention, for each group of matrix subgroups, adding the transposed matrix after the first two-dimensional submatrix, adding the diagonal matrix after the second two-dimensional submatrix, and adding the product matrix after the third two-dimensional submatrix to obtain the target matrix group includes:
[0096] Use the division algorithm to solve for the multiple positions where the transposed matrix, the diagonal matrix, and the product matrix are respectively added in the first transformation matrix group;
[0097] According to the multiple added positions, add the transposed matrix, the diagonal matrix, and the product matrix between the N-layer two-dimensional submatrices.
[0098] In an embodiment of the present invention, the obtaining the two-dimensional matrix data of the grayscale image to be encrypted further includes: obtaining the binary storage data of the grayscale image to be encrypted; converting the binary storage data into the two-dimensional matrix data.
[0099] In an embodiment of the present invention, after adding the at least one transformation submatrix into the first transformation matrix group according to a preset addition rule to obtain the target matrix group of the grayscale image to be encrypted, the method further includes:
[0100] Digitally encode each target matrix in the target matrix group to obtain a digitized value; the target matrix is each matrix in the target matrix group;
[0101] Store the digitized values sequentially in a compact disc in order.
[0102] In an embodiment of the present invention, the obtaining the two-dimensional matrix data of the grayscale image to be encrypted further includes: obtaining the binary storage data of the grayscale image to be encrypted; converting the binary storage data into the two-dimensional matrix data.
[0103] In an embodiment of the present invention, by obtaining two-dimensional matrix data of a grayscale image to be encrypted, performing a first transformation process on the two-dimensional matrix data to obtain a first transformation matrix group; performing a transformation on the two-dimensional matrix data according to at least one transformation rule to obtain at least one transformation sub-matrix, and adding the at least one transformation sub-matrix to the first transformation matrix group according to a preset addition rule to obtain a target matrix group of the grayscale image to be encrypted, so as to complete the encryption of the grayscale image to be encrypted. This makes the data storage of the grayscale image change from planar to three-dimensional, inserts a data interlayer in the middle, and the data interlayer generates different planar square matrices according to the characteristics of the given grayscale image, and these generated square matrices are arranged in the order of three in a group, three in a group, and the password is set regularly; since the generated square matrices of different images are different, the password is difficult to decipher. This makes the encryption of the grayscale image regular and difficult to decipher, and can effectively balance the encryption complexity and processing efficiency.
[0104] An embodiment of the present invention provides a computer-readable storage medium, and the storage medium stores at least one executable instruction. When the executable instruction runs on a computer device, the computer device is caused to execute the image encryption processing method or the image decryption processing method in any of the above method embodiments.
[0105] The executable instruction can specifically be used to cause the computer device to perform the following operations:
[0106] Obtain two-dimensional matrix data of a grayscale image to be encrypted; in the two-dimensional matrix data, each two-dimensional matrix element is the grayscale value of the pixel at the corresponding position;
[0107] Perform a first transformation process on the two-dimensional matrix data to obtain a first transformation matrix group; the first transformation matrix group includes N layers of two-dimensional sub-matrices; wherein, one two-dimensional sub-matrix element of the Nth two-dimensional sub-matrix is the grayscale value of the Nth position pixel, and the remaining two-dimensional sub-matrix elements are 0, and N is an integer greater than 0;
[0108] Perform a transformation on the two-dimensional matrix data according to at least one transformation rule to obtain at least one transformation sub-matrix; the at least one transformation rule includes at least one of calculating a transpose matrix, calculating a diagonal matrix, and calculating the product of a transpose matrix and a diagonal matrix;
[0109] Add the at least one transformation sub-matrix to the first transformation matrix group according to a preset addition rule to obtain a target matrix group of the grayscale image to be encrypted, so as to complete the encryption of the grayscale image to be encrypted; or, read the target matrix group of the grayscale image to be decrypted;
[0110] Delete the transformation sub - matrices in the target matrix group according to a preset deletion rule to obtain a first transformation matrix group; the transformation sub - matrices are obtained by transforming two - dimensional matrix data or N - layer two - dimensional sub - matrices in the first transformation matrix group according to at least one transformation rule; the at least one transformation rule includes at least one of calculating a transpose matrix, calculating a diagonal matrix, and calculating the product of a transpose matrix and a diagonal matrix; the first transformation matrix group includes N - layer two - dimensional sub - matrices.
[0111] Perform a first inverse transformation process on the first transformation matrix group to obtain the two - dimensional matrix data of the decrypted grayscale image; wherein, the grayscale value of the pixel at the Nth position in the two - dimensional matrix data is an element of a two - dimensional sub - matrix of the Nth two - dimensional sub - matrix, and N is an integer greater than 0.
[0112] In an embodiment of the present invention, the transformation rule includes calculating the transpose matrix of two - dimensional matrix data, calculating the diagonal matrix of two - dimensional matrix data, and calculating the product matrix of the transpose matrix and the diagonal matrix; the preset addition rule is to cyclically insert the transpose matrix, the diagonal matrix, and the product matrix between each two - dimensional sub - matrix.
[0113] In an embodiment of the present invention, transforming the two - dimensional matrix data according to at least one transformation rule to obtain at least one transformation sub - matrix includes:
[0114] Calculate the transpose matrix of the two - dimensional matrix data to obtain a transpose matrix;
[0115] Calculate the diagonal matrix of the two - dimensional matrix data to obtain a diagonal matrix;
[0116] Calculate the product of the transpose matrix and the diagonal matrix of the two - dimensional matrix data to obtain a product matrix;
[0117] Adding the at least one transformation sub - matrix to the first transformation matrix group according to a preset addition rule to obtain the target matrix group of the grayscale image to be encrypted includes:
[0118] Group the N - layer two - dimensional sub - matrices in the first transformation matrix group in order, three in a group, to obtain multiple groups of matrix subgroups;
[0119] For each group of matrix subgroups, add the transpose matrix after the first two - dimensional sub - matrix, add the diagonal matrix after the second two - dimensional sub - matrix, and add the product matrix after the third two - dimensional sub - matrix to obtain the target matrix group; wherein, the first two - dimensional sub - matrix, the second two - dimensional sub - matrix, and the third two - dimensional sub - matrix are different two - dimensional sub - matrices in each group of matrix subgroups respectively.
[0120] In an embodiment of the present invention, for each group of matrix subgroups, after adding the transposed matrix to the first two-dimensional sub-matrix, adding the diagonal matrix to the second two-dimensional sub-matrix, and adding the product matrix to the third two-dimensional sub-matrix, obtaining the target matrix group includes:
[0121] Using the division algorithm to solve for the multiple positions in the first transformation matrix group where the transposed matrix, the diagonal matrix, and the product matrix are respectively added;
[0122] According to the multiple added positions, adding the transposed matrix, the diagonal matrix, and the product matrix between the N-layer two-dimensional sub-matrices.
[0123] In an embodiment of the present invention, the obtaining the two-dimensional matrix data of the grayscale image to be encrypted further includes: obtaining the binary storage data of the grayscale image to be encrypted; converting the binary storage data into the two-dimensional matrix data.
[0124] In an embodiment of the present invention, after adding the at least one transformation sub-matrix to the first transformation matrix group according to a preset addition rule to obtain the target matrix group of the grayscale image to be encrypted, the method further includes:
[0125] Digitally encoding each target matrix in the target matrix group to obtain a digitized value; the target matrix is each matrix in the target matrix group;
[0126] Sequentially storing the digitized values in an optical disc in order.
[0127] In an embodiment of the present invention, the obtaining the two-dimensional matrix data of the grayscale image to be encrypted further includes: obtaining the binary storage data of the grayscale image to be encrypted; converting the binary storage data into the two-dimensional matrix data.
[0128] In the embodiments of the present invention, by obtaining the two-dimensional matrix data of the grayscale image to be encrypted, performing a first transformation process on the two-dimensional matrix data to obtain a first transformation matrix group; performing transformation on the two-dimensional matrix data according to at least one transformation rule to obtain at least one transformation sub-matrix, and adding the at least one transformation sub-matrix into the first transformation matrix group according to a preset addition rule to obtain the target matrix group of the grayscale image to be encrypted, so as to complete the encryption of the grayscale image to be encrypted. This makes the data storage of the grayscale image change from planar to three-dimensional, inserts a data interlayer in the middle, and the data interlayer generates different planar square matrices according to the characteristics of the given grayscale image, and these generated square matrices are arranged in the order of three in a group, three in a group, and the password is set regularly; since the generated square matrices of different images are different, the password is difficult to decipher. This makes the encryption of the grayscale image both regular and difficult to decipher, so that the encryption complexity and processing efficiency can be effectively balanced.
[0129] The algorithms or displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings based herein. The structure required to construct such systems will be apparent from the above description. In addition, the embodiments of the present invention are not directed to any particular programming language. It should be understood that the content of the present invention described herein can be implemented using various programming languages, and the description of the specific language above is to disclose the best mode of the present invention.
[0130] In the specification provided herein, a large number of specific details are set forth. However, it can be understood that the embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures, and technologies have not been shown in detail so as not to obscure the understanding of this specification.
[0131] Similarly, it should be understood that, in order to streamline the present invention and assist in understanding one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present invention, the various features of the embodiments of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, the disclosed method should not be construed as reflecting the intention that the claimed invention requires more features than are expressly recited in each claim.
[0132] Those skilled in the art can understand that the modules in the devices in the embodiments can be adaptively changed and arranged in one or more devices different from those of the embodiments. The modules or units or components in the embodiments can be combined into one module or unit or component, and they can also be divided into multiple sub-modules or sub-units or sub-components. Except that at least some of such features and / or processes or units are mutually exclusive, any combination can be adopted to combine all the features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all the processes or units of any method or device so disclosed. Unless otherwise clearly stated, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) can be replaced by an alternative feature that provides the same, equivalent, or similar purpose.
[0133] It should be noted that the above embodiments illustrate the present invention rather than limit the present invention, and those skilled in the art can design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention can be implemented by means of hardware including several different elements and by means of a suitably programmed computer. In the unit claims listing several devices, several of these devices can be embodied by the same item of hardware. The use of the words first, second, and third, etc. does not denote any order. These words can be interpreted as names. The steps in the above embodiments, unless otherwise specifically stated, should not be construed as limiting the order of execution.
Claims
1. An image encryption processing method, characterized in that, The method includes: Obtaining two-dimensional matrix data of a grayscale image to be encrypted; in the two-dimensional matrix data, each two-dimensional matrix element is the grayscale value of the pixel at the corresponding position of the grayscale image to be encrypted; Performing a first transformation process on the two-dimensional matrix data to obtain a first transformation matrix group; the first transformation matrix group includes N layers of two-dimensional sub-matrices; wherein, one two-dimensional sub-matrix element of the Nth two-dimensional sub-matrix is the grayscale value of the pixel at the Nth position, and the remaining two-dimensional sub-matrix elements are 0, and N is an integer greater than 0; Performing a transformation on the two-dimensional matrix data according to at least one transformation rule to obtain at least one transformation sub-matrix; the at least one transformation rule includes at least one of calculating a transpose matrix, calculating a diagonal matrix, and calculating the product of a transpose matrix and a diagonal matrix; Adding the at least one transformation sub-matrix to the first transformation matrix group according to a preset addition rule to obtain a target matrix group of the grayscale image to be encrypted, so as to complete the encryption of the grayscale image to be encrypted; the preset addition rule includes cyclically inserting the at least one transformation sub-matrix between each two-dimensional sub-matrix.
2. The method according to claim 1, characterized in that The transformation rule includes calculating the transpose matrix of the two-dimensional matrix data, calculating the diagonal matrix of the two-dimensional matrix data, and calculating the product matrix of the transpose matrix and the diagonal matrix; the preset addition rule is to cyclically insert the transpose matrix, the diagonal matrix, and the product matrix between each two-dimensional sub-matrix.
3. The method according to claim 2, characterized in that, The performing a transformation on the two-dimensional matrix data according to at least one transformation rule to obtain at least one transformation sub-matrix includes: Calculating the transpose matrix of the two-dimensional matrix data to obtain a transpose matrix; Calculating the diagonal matrix of the two-dimensional matrix data to obtain a diagonal matrix; Calculating the product of the transpose matrix and the diagonal matrix of the two-dimensional matrix data to obtain a product matrix; The adding the at least one transformation sub-matrix to the first transformation matrix group according to a preset addition rule to obtain a target matrix group of the grayscale image to be encrypted includes: Grouping the N layers of two-dimensional sub-matrices in the first transformation matrix group, with three in a group, to obtain multiple groups of matrix subgroups; For each group of matrix subgroups, adding the transpose matrix after the first two-dimensional sub-matrix, adding the diagonal matrix after the second two-dimensional sub-matrix, and adding the product matrix after the third two-dimensional sub-matrix to obtain the target matrix group; wherein, the first two-dimensional sub-matrix, the second two-dimensional sub-matrix, and the third two-dimensional sub-matrix are different two-dimensional sub-matrices in each group of matrix subgroups respectively.
4. The method according to claim 3, wherein For each group of matrix subgroups, adding the transpose matrix after the first two-dimensional sub-matrix, adding the diagonal matrix after the second two-dimensional sub-matrix, and adding the product matrix after the third two-dimensional sub-matrix to obtain the target matrix group further includes: Using the division algorithm to solve for the multiple positions where the transpose matrix, the diagonal matrix, and the product matrix are respectively added in the first transformation matrix group; Adding the transpose matrix, the diagonal matrix, and the product matrix between the N layers of two-dimensional sub-matrices according to the added multiple positions.
5. The method according to any one of claims 1 to 4, characterized in that, After adding the at least one transformation sub - matrix to the first transformation matrix group according to a preset addition rule to obtain the target matrix group of the grayscale image to be encrypted, the method further includes: Digitally encoding each target matrix in the target matrix group to obtain a digitized value; the target matrix is each matrix in the target matrix group; Sequentially storing the digitized values in an optical disc in order.
6. The method according to claim 5, wherein After sequentially storing the digitized values in the optical disc, the method further includes: Obtaining content identification information of the optical disc; Generating an encrypted check value after encrypting according to the content identification information of the optical disc using a preset encryption algorithm; Storing the encrypted check value in the optical disc check storage area of the host.
7. An image decryption processing method, characterized in that: Reading a target matrix group of a grayscale image to be decrypted; the target matrix group is obtained by adding at least one transformation sub - matrix to a first transformation matrix group according to a preset addition rule; the transformation sub - matrix is obtained by transforming two - dimensional matrix data of the grayscale image to be encrypted according to at least one transformation rule; the first transformation matrix group includes N layers of two - dimensional sub - matrices; the at least one transformation rule includes at least one of calculating a transpose matrix, calculating a diagonal matrix, and calculating the product of a transpose matrix and a diagonal matrix; the preset addition rule includes cyclically inserting the at least one transformation sub - matrix between each two - dimensional sub - matrix; Deleting the transformation sub - matrices in the target matrix group according to a preset deletion rule to obtain a first transformation matrix group; The preset deletion rule is a rule inverse to the preset addition rule; Performing a first inverse transformation process on the first transformation matrix group to obtain two - dimensional matrix data, thereby completing the decryption of the grayscale image to be decrypted; wherein, in the two - dimensional matrix data, each two - dimensional matrix element is the grayscale value of the pixel at the corresponding position; the grayscale value of the pixel at the Nth position in the two - dimensional matrix data is a two - dimensional matrix element of the Nth two - dimensional sub - matrix, and the remaining two - dimensional matrix elements are 0, where N is an integer greater than 0.
8. The method according to claim 7, wherein The step of reading the target matrix group of the grayscale image to be decrypted includes: Reading the data in the optical disc through a laser probe to obtain digitized values; Decoding the digitized values to obtain a target matrix group.
9. A computer device, characterized in that, Including: A processor, a memory, a communication interface, and a communication bus, where the processor, the memory, and the communication interface complete mutual communication through the communication bus; The memory is used to store at least one executable instruction, and the executable instruction causes the processor to execute the image encryption processing method according to any one of claims 1 - 6 or the image decryption processing method according to any one of claims 7 - 8.
10. A computer-readable storage medium, characterized in that, The storage medium stores at least one executable instruction, and when the executable instruction runs on a computer device, it causes the computer device to execute the image encryption processing method according to any one of claims 1 - 6 or the image decryption processing method according to any one of claims 7 - 8.
Citation Information
Patent Citations
Mobile platform image encryption method
CN105488426A
Image encryption method and device
CN107770405A