CN112040086B - Image encryption and decryption methods and devices, equipment and readable storage medium - Google Patents
Image encryption and decryption methods and devices, equipment and readable storage medium Download PDFInfo
- Publication number
- CN112040086B CN112040086B CN201910478538.6A CN201910478538A CN112040086B CN 112040086 B CN112040086 B CN 112040086B CN 201910478538 A CN201910478538 A CN 201910478538A CN 112040086 B CN112040086 B CN 112040086B
- Authority
- CN
- China
- Prior art keywords
- image
- encryption
- matrix
- encrypted
- decryption
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N1/00—Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
- H04N1/32—Circuits or arrangements for control or supervision between transmitter and receiver or between image input and image output device, e.g. between a still-image camera and its memory or between a still-image camera and a printer device
- H04N1/32101—Display, printing, storage or transmission of additional information, e.g. ID code, date and time or title
- H04N1/32144—Display, printing, storage or transmission of additional information, e.g. ID code, date and time or title embedded in the image data, i.e. enclosed or integrated in the image, e.g. watermark, super-imposed logo or stamp
- H04N1/32149—Methods relating to embedding, encoding, decoding, detection or retrieval operations
- H04N1/32267—Methods relating to embedding, encoding, decoding, detection or retrieval operations combined with processing of the image
- H04N1/32272—Encryption or ciphering
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/602—Providing cryptographic facilities or services
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/62—Protecting access to data via a platform, e.g. using keys or access control rules
- G06F21/6218—Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
- G06F21/6245—Protecting personal data, e.g. for financial or medical purposes
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/08—Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
- H04L9/0861—Generation of secret information including derivation or calculation of cryptographic keys or passwords
- H04L9/0863—Generation of secret information including derivation or calculation of cryptographic keys or passwords involving passwords or one-time passwords
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/08—Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
- H04L9/0861—Generation of secret information including derivation or calculation of cryptographic keys or passwords
- H04L9/0869—Generation of secret information including derivation or calculation of cryptographic keys or passwords involving random numbers or seeds
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Theoretical Computer Science (AREA)
- Bioethics (AREA)
- General Health & Medical Sciences (AREA)
- Signal Processing (AREA)
- Health & Medical Sciences (AREA)
- Software Systems (AREA)
- Computer Hardware Design (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Networks & Wireless Communication (AREA)
- Databases & Information Systems (AREA)
- Medical Informatics (AREA)
- Multimedia (AREA)
- Editing Of Facsimile Originals (AREA)
- Image Processing (AREA)
- Facsimile Transmission Control (AREA)
Abstract
The invention discloses an image encryption and decryption method and device, equipment and a readable storage medium. The image encryption method comprises the following steps: generating a binary mark matrix according to the image content to be encrypted in the original image; marking the original image by using the generated marking matrix; the encryption matrix is formed randomly by adopting the secret key, and the encryption matrix and the marking matrix are subjected to AND operation to obtain a mask matrix; and performing exclusive OR operation on the marked image through a mask matrix to form an encrypted image. When decrypting, firstly, the encryption pixel marking matrix is restored on the corresponding bit plane by exclusive OR operation, and the corresponding bit planes of all the encrypted pixels are subjected to exclusive OR operation again to restore the image encryption pixel content. By the invention, the user can restrict the access right of partial people to the image partial content. The user himself or an authorized party restores the original content by means of the protected image when the conditions allow.
Description
Technical Field
The present invention relates to information transmission technologies, and in particular, to an image encryption method, an image decryption method, an image encryption device, an image decryption device, and a readable storage medium.
Background
With the development of digital media and internet technology, the phenomenon of individuals or organizations publishing or disseminating images on networks has become increasingly common. In particular, rapid progress in cloud computing has led to more and more image data being uploaded to cloud storage. The multi-user access under the big data environment greatly facilitates the work and life of people. However, the act of disclosing or sending the raw picture that is not processed also risks revealing personal privacy.
In order to solve the problem of privacy disclosure caused by the release of image privacy content, an effective and feasible method is to encrypt sensitive parts in an image, for example, to perform mosaic addition on related protection content or to directly delete the sensitive content. These processed images tend to be irrecoverable and even result in permanent loss of real information. Another method is to encrypt the whole image, and the whole image is used as a protection object and protected by a cryptography method. However, this may cause coverage of other non-private information, which affects release of the non-private information.
Steganography is a technique by which secret information can be embedded in digital media without causing visual anomalies. Common image-based steganography is mostly implemented embedded on the pixel least significant bits of a bitmap image or the quantized DCT coefficients least significant bits of a JPEG image. At the time of extraction, the user can get embedded bit information at the previous embedding location. For image content encryption, the technology can embed information of encryption positions into an image itself without causing visual anomalies. The encryptor can extract this information upon restoration to complete image decryption. Patent documents CN201710203809.8 (an image encryption method based on RC4 algorithm), CN201610856467.5 (an image encryption method and device, a key stream generation method and a key stream generator), CN201810067051.4 (an image encryption method based on hyperchaotic system and multilevel scrambling) are all image content encryption inventions, but the existing image encryption methods are only suitable for image overall encryption and are not suitable for image local content encryption.
Disclosure of Invention
In order to meet the above defects or improvement demands of the prior art, the invention provides an image encryption and decryption method, an image encryption and decryption device and a readable storage medium, wherein the image encryption and decryption method is a steganography-based airspace image content encryption algorithm. By the invention, the user can restrict the access right of partial people to the image partial content. The user himself or an authorized party restores the original content by means of the protected image when the conditions allow. The invention can carry out local encryption protection on the image content, and the encryption position information is embedded into the image itself in a way of attack. The encryption algorithm has high running speed and high encryption security.
The technical scheme adopted by the invention for solving the technical problems is as follows:
an image encryption method, comprising:
forming a marking element, wherein the marking element is used for distinguishing the content to be encrypted from the content not to be encrypted in the original image;
an encryption key is adopted to randomly form an encryption sequence, and the encryption sequence and the marking element are operated to obtain an encryption element;
and encrypting the image to be encrypted through the encryption element to form an encrypted image.
Specifically, the marking element is a binary marking matrix, if the spatial pixel matrix of the original image is I h×w =(I i,j ) h×w The marking matrix is m h×w =(m i,j ) h×w When I i,j For pixels requiring encryption m i,j =1, otherwise m i,j =0;
Where i=1, 2,3, …, h and j=1, 2,3, …, w, I i,j For a single pixel of the image, the value is between 0 and 255, and h and w are the height and width of the original image respectively.
Specifically, the encryption sequence is an encryption matrix, and n+1 binary encryption matrices composed of random 0 and 1 are generated by using a key, which are respectively in turn Wherein the parameter N is a natural number greater than 0 and less than 8 selected according to individual pixels of the image;
employing a marking matrix to encrypt the first N encryption matricesAnd clearing the element corresponding to the non-encrypted pixel position to obtain an encrypted element.
Specifically, bits and operations are respectively adopted on the first N encryption matrixes and the marking matrix to obtain first N mask matrixes, the (n+1) th encryption matrix is not processed to directly form the (n+1) th mask matrix, and the (n+1) th mask matrix is an encryption element.
Specifically, the method comprises the following steps: the marking element is embedded into the original image to form the image to be encrypted.
Specifically, a marking matrix is used to replace a bit of a single pixel of the original image, so as to form the image to be encrypted. The bit of the phase is agreed in advance by both sides.
In particular, the marking matrix is used to replace the lowest bit of a single pixel of the original image.
Specifically, the marking element is not embedded into the original image, and the image to be encrypted is the original image. Specifically, during encryption, the first N bit planes of the pixel matrix of the encrypted image and the first N encryption mask matrices are subjected to exclusive OR operation to form the encrypted image.
Specifically, the encryption element performs bit exclusive OR operation with the image to be encrypted to form an encrypted image.
Specifically, the N bit planes of the pixel matrix of the encrypted image except the bit plane embedded by the marking matrix are respectively xored with the first N mask matrices, and the last mask matrix is xored with the bit plane embedded by the marking matrix to form the encrypted image.
Specifically, the first N bitplanes of the pixel matrix of the encrypted image are respectively xored with the first N mask matrices, and the last mask matrix is xored with the bitplanes embedded by the mark matrix to form the encrypted image.
Specifically, for the 1 st, 2 nd, … nd, N,8 th n+1 bit plane of the image pixel matrix to be encrypted from high to low, exclusive-or operation is performed with the mask matrix respectively, if N is smaller than 7, the n+1 th to 7 th bit of the image pixel after encryption is the same as before encryption, and an encrypted image pixel matrix is obtained.
In particular, the parameter N is preferably 3, 4, 5, 6 or 7. The encryption effect can be ensured.
Specifically, three color channels of RGB of the BMP image are encrypted as three images, respectively.
The invention also provides an image decryption method, which comprises the following steps:
forming a decryption sequence by using the decryption key;
the decryption sequence and the marking element are used for operation to obtain a decryption element, and the marking element is a binary marking matrix used for distinguishing encrypted content from unencrypted content during encryption;
and decrypting the encrypted image by using the decryption element to obtain a decrypted image.
Specifically, the decryption key is the same as the encryption key used in encryption, and the formed decryption sequence is the same as the encryption sequence formed in encryption.
Specifically, the decryption sequence is a decryption matrix, and the decryption key generates n+1 binary decryption matrices consisting of random 0 and random 1; wherein the parameter N is a natural number which is more than 0 and less than 8 and is selected according to single pixels of the image when in encryption;
bit and operation are respectively adopted for the first N decryption matrixes and the marking matrix, so that the first N mask matrixes adopted during encryption are obtained, and the (n+1) th decryption matrix is the (n+1) th mask matrix adopted during encryption without processing;
the n+1 mask matrices form decryption elements.
Specifically, the exclusive or operation of the bit plane is performed on the encrypted image pixel matrix and the decryption element formed by the mask matrix, so as to obtain the decrypted image pixel matrix.
Specifically, the marking matrix is obtained by performing exclusive OR operation on the (n+1) th matrix in the decryption matrix and the corresponding bit plane replaced by the marking matrix in the encrypted image.
The present invention also provides an image encryption apparatus including:
the marking unit is used for generating marking elements which are used for distinguishing the content needing to be encrypted from the content needing to be encrypted;
an encryption key, the encryption key randomly forming an encryption sequence;
the computing unit is used for carrying out operation on the encryption sequence and the marking element to obtain an encryption element;
and an encryption unit that encrypts the image to be encrypted by the encryption element, thereby forming an encrypted image.
Specifically, the encryption device further includes: and the preprocessing unit marks the original image by using the marking element to form an image to be encrypted.
The present invention also provides an image decryption apparatus including:
a decryption key, the decryption key randomly forming a decryption sequence;
the calculating unit is used for calculating the decryption sequence and the marking element to obtain a decryption element; the marking element is a binary marking matrix used for distinguishing encrypted content from unencrypted content in encryption;
and the decryption unit decrypts the encrypted image by using the decryption element to obtain a decrypted image.
The invention also provides an electronic device comprising:
a processor;
a memory storing processor-executable instructions, wherein:
the processor reads instructions from the memory to implement the steps of the method as described above.
The invention also provides a readable storage medium having stored thereon computer instructions, characterized in that the instructions when executed by a processor implement the steps of the method as described above.
The invention can realize local encryption of the image, and the user can restrict the access right of partial people to the partial content of the image. The user himself or an authorized party restores the original content by means of the protected image when the conditions allow. Compared with the prior art, the invention has at least the following advantages:
(1) The invention can realize the encryption protection of the local content of the image without integral encryption;
(2) The invention can embed the encryption position information into the image itself, and the decryptor can decrypt the image content only by obtaining the decryption key;
(3) The invention has fast encryption and decryption operation speed and high security.
Drawings
Fig. 1 is a schematic diagram of an image encryption step according to the present invention.
Fig. 2 is a schematic diagram of an image decryption step according to the present invention.
Fig. 3 is a schematic diagram of the process of marking an original image according to the present invention.
FIG. 4 is a schematic diagram of a key generation random binary matrix according to the present invention.
Fig. 5 is a schematic diagram of a mask matrix generated in accordance with the present invention.
Fig. 6 is a schematic diagram of an encrypted image of the present invention.
Fig. 7 is a schematic diagram of a generated image to be encrypted according to a second embodiment of the present invention.
Fig. 8 is a schematic view of a generated encrypted image according to a second embodiment of the invention.
Fig. 9 is a schematic diagram of the structure of the encryption device of the present invention.
Fig. 10 is a schematic diagram of the structure of the decryption device of the present invention.
Fig. 11 is a schematic structural view of an electronic device according to the present invention.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention. In addition, the technical features of the embodiments of the present invention described below may be combined with each other as long as they do not collide with each other.
Fig. 1 is a schematic diagram of an image encryption step according to the present invention. The specific steps are as follows.
Let the spatial pixel matrix of the original image to be encrypted be I h×w =(I i,j ) h×w I=1, 2,3, …, h and j=1, 2,3, …, w, wherein I i,j Is a single pixel of the image, and the value is between 0 and 255; h and w are the height and width of the image, respectively. The user needs to choose the value of the parameter N in advance, where n=any one of 1,2,3, …, 7.
A marking matrix is generated. In this step a marking matrix m is generated h×w =(m i,j ) h×w I=1, 2,3, …, h and j=1, 2,3, …, w. When I i,j Let m for pixels that need encryption i,j =1, otherwise m i,j =0。
The marker matrix is steganographically embedded in the original image. The embedding may be bit substitution, i.e. substitution of bits in the image pixel value with bits that need to be embedded. In this step m will be i,j Replacement I i,j I.e. the position-marker matrix m h×w Embedding image I h×w And obtaining the image to be encrypted. The images before and after embedding basically have no change, and the embedded image to be encrypted is marked as I' h×w =(I′ i,j ) h×w 。
And generating N+1 mask matrixes by using the key K according to the parameter N selected in advance by the user. This step uses the key K to generate N+1 binary matrices consisting of random 0 and 1, respectively denoted as
Further, n+1 mask matrices are obtained as follows:
…
wherein ∈A is the bit and operation, i.e., the operation will beAnd (3) clearing mask elements corresponding to the non-encrypted pixel positions to obtain a mask matrix, namely the encrypted elements.
The image is encrypted using a mask matrix exclusive-or operation. In this step, for the image pixel matrix I 'to be encrypted' h×w =(I′ i,j ) h×w From high to low numbers 1,2, …, N,8 these n+1 bit planes are respectively associated with Performing exclusive OR operation, i.e.)>Here->And->Respectively representing the pixels I 'of the image before the encryption of the image to be encrypted' i,j And an encrypted image pixel I i,j From the high to the low number of kth bits, k=1, 2, ··, N,8. If N<7,I″ i,j N+1 to 7 bits and I' i,j The same holds true. Finally obtain I h×w =(I″ i,j ) h×w Is an encrypted image pixel matrix. Will I' h×w And storing the image file to obtain a final encrypted image.
Fig. 2 is a schematic diagram of an image decryption step according to the present invention. The image decryption step is opposite to the encryption step, and the specific steps are as follows.
N+1 mask matrices are generated using the key K. This step uses the key K to generate N+1 binary matrices consisting of random 0 and 1, respectively denoted as The n+1 matrices are identical to the matrix generated at the time of encryption. Due to the fact that thereinThus use mask matrix->And the encrypted image pixel matrix I h ″ ×w =(I″ i,j ) h×w The lowest bit plane is exclusive-ored to obtain an encrypted pixel marking matrix m h×w ={m i,j } h×w I.e.
The mask matrix of the bit-planes is then obtained, i.e. the decryption elements are as follows:
…
the image is decrypted using a mask matrix exclusive-or operation. In this step for a matrix I of image pixels h ″ ×w =(I″ i,j ) h×w 1,2, …, N,8 N+1 bit levels from high to lowFaces respectively Performing exclusive OR operation, i.e. pixel->Here->And->Respectively represent pixels I 'before encryption' i,j And an encrypted pixel I' i,j From the high to the low number of kth bits, k=1, 2, ··, N,8. If N<7,I′ i,j N+1 to 7 th bits and I' i,j The same applies. Finally obtain I' h×w =(I′ i,j ) h×w To decrypt the image pixel matrix. Will I' h×w And storing the image file to obtain a final decrypted image.
In the step of embedding the marking matrix into the original image, the marking of the original image can be realized by embedding the encrypted pixel marking matrix into other bit planes. When the marking matrix is embedded into other bits, the first N bit planes are respectively exclusive-ored with the first N mask matrices to realize content encryption, and the last mask matrix is exclusive-ored with the bit planes embedded by the marking matrix to encrypt marking information. And after the exclusive OR operation is completed, obtaining the encrypted image. Other steps are changed correspondingly.
In the step of embedding the marking matrix into the original image by steganography, the marking matrix can also be independently stored, and if the marking matrix is independently stored, the image to be encrypted is the original image I h×w =(I i,j ) h×w . Since the marking information does not need to be embedded in the imageTherefore, the encryption method only needs to exclusive-or the first N encryption mask matrixes and the first N bit planes. Other steps are changed correspondingly.
In the step of encrypting the image by using the mask matrix exclusive-or operation, exclusive-or operation can be performed on other bit planes of the pixel matrix of the image to be encrypted and the mask matrix respectively, specifically, exclusive-or operation is performed on N bit planes of the pixel matrix of the encrypted image except for the bit plane embedded by the mark matrix and the first N mask matrices respectively, and exclusive-or operation is performed on the last mask matrix and the bit plane embedded by the mark matrix to form the encrypted image. The first N mask matrices and the last mask matrix of the present invention are only for convenience of description, and do not represent the positional relationship thereof in actual operation. According to practical needs, the last mask matrix can be placed at the first, and the first N mask matrices are placed at the back, so long as the corresponding operation relation is maintained. For convenience, the mask matrix that performs exclusive-or operation with the bit plane in which the tag matrix is embedded is placed at the last.
Example 1
Taking an 8 x 8 color BMP image, selecting n=4 as an example, encrypting three RGB color channels of the BMP image, and using the original image as three images by an encryptor, wherein one color channel is used as an example, the steps are as follows:
referring to fig. 3, it is a process of replacing the lowest bit of a single pixel of an original image with a marking matrix.
Generating a marking matrix: the encryptor generates a marker matrix 3a consisting of 0 and 1 from the pixels involved in the content to be encrypted of the BMP image.
Steganographically embedding the marking matrix into one color channel matrix 3b of the original image: the two parties agree in advance that the encryptor embeds the marking matrix in the lowest (last) bit plane of the image to obtain a marked image, i.e. the image matrix 3c to be encrypted.
As in fig. 4 and 5, a mask matrix is generated: the encryptor generates 5 random binary matrices 4a-4e by using the key, performs an and operation on the first 4 encryption matrices 4a-4d and the marking matrix 3a to obtain first 4 mask matrices 5a-5d, and the last encryption matrix 4e directly forms a 5 th mask matrix 5e without processing.
Encrypting the image using a mask matrix exclusive-or operation: the encryptor uses the mask matrices 5a-5e to exclusive-or with the 1 st, 2 nd, 3 rd, 4 th, 8 th bit planes of the single pixel of the image 3c to be encrypted, respectively, to obtain an encrypted image spatial matrix (as shown in fig. 6).
After the above steps, the RGB three color component images are encrypted, and the three component images are combined and stored as BMP images as the final encrypted image.
After the above encryption process is completed, the encryptor may send the encrypted image and the key to the decryptor.
The decryption principle is based on the feature that the original value before the exclusive or is obtained after two exclusive or operations are performed on any bit. The image decryption steps are as follows:
for the BMP color image that has been encrypted as described above, the decryptor uses the key at the time of encryption as the decryption key. The three channels of RGB are decrypted as three images, respectively.
First a mask matrix is generated: the decryptor generates 5 decryption matrices as in fig. 4 (i.e. encryption matrices at encryption) using the key, then uses the pixel marking matrix 3a where the 5 th decryption matrix 4e is directly different from the lowest bit plane of the encrypted image matrix (shown in fig. 6) or may obtain the encryption, and further uses the marking matrix 3a to exclusive-or with the first four random binary decryption matrices 4a-4d to obtain decryption elements, i.e. mask matrices fig. 5a-5d.
Decrypting the image using a mask matrix exclusive-or operation: the decryptor uses the mask matrix to exclusive-or the top four and 8 th bit planes of the image, i.e. the 1 st, 2 nd, 3 rd, 4 th and 8 th bit planes, to restore the image before encryption. The restored image is a marked image, and the marked image is only different from the original image in the least significant bit. From the view of the image content, the content difference of the two is not perceived, and the content of the image is restored.
Example two
Taking an 8 x 8 color BMP image as an example, selecting n=4, taking an RGB three color channels of the BMP image as three images for encryption, taking one color channel as an example, embedding a mark matrix into a 7 th bit plane from high to low of the image to obtain a marked image, namely an image matrix to be encrypted (as shown in fig. 7).
For the 5 th bit plane of the 1 st, 2 nd, … th, 4 th and 7 th bit planes of the image pixel matrix to be encrypted from high to low, exclusive OR operation is respectively carried out with the mask matrix, and the 5 th, 6 th and 8 th bits of the image pixels after encryption are the same as those before encryption, so as to obtain an encrypted image pixel matrix (as shown in figure 8). Correspondingly, when the marking matrix is extracted in the decryption step, the marking matrix is extracted from the 7 th bit plane, namely, the 5 th mask matrix and the bit plane embedded by the marking matrix, namely, the 7 th bit plane are subjected to exclusive OR operation to obtain the marking matrix.
The decryptor uses the mask matrix to exclusive-or the 5 th bit plane of the 1 st, 2 nd, 3 rd, 4 th and 7 th bit planes of the image, and restores the image before encryption. The other steps are the same as example one.
When the tag matrix is embedded in other bits (here, 7 th bit), the 1 st, 2 nd, 3 rd and 4 th bit planes are exclusive-ored with the 1 st, 2 nd, 3 rd and 4 th mask matrices to realize content encryption, and the 5 th mask matrix is exclusive-ored with the bit plane in which the tag matrix is embedded, namely, the 7 th bit plane to encrypt tag information.
Example III
In this embodiment, the image to be encrypted is the original image, and the original image 3b shown in fig. 3 and the mask matrix shown in fig. 5 are directly xored to obtain an encrypted image, and the encrypted image is sent to the decryptor separately after encryption. The decryptor does not need to perform the extraction operation of the mark matrix, directly uses the random matrix generated by the mark matrix and the secret key as shown in fig. 4 to perform operation to obtain the mask matrix, and uses the exclusive or of the first 4 mask matrices and the first 4 bit planes of the encrypted image to obtain the decrypted image. The final decrypted image is the original image. By independently storing the storage flag matrix, it is possible to ensure that the decrypted image is completely identical to the original image. Since the tag information does not need to be embedded in the image, the encryption method only needs to exclusive-or the first 4 encryption mask matrices with the first 4 bit planes. By adopting the method, the secret key can only be used for generating N binary encryption matrixes, and the N encryption matrixes are respectively subjected to AND operation with the marking matrixes to obtain N mask matrixes.
According to the invention, the user can restrict the access rights of partial persons to the image partial content. The user himself or an authorized party restores the original content by means of the protected image when the conditions allow. Because the encrypted image is generated based on the data encryption of the partial area of the original image, the normal identifiable of the non-sensitive content of other positions of the image can be ensured on the premise of protecting the partial sensitive information. In addition, the data volume of the decrypted image of the terminal is also less, the time required by the decryption of the terminal is shorter, the real-time performance of the ornamental original image is improved, and the use experience of a user is further improved.
Fig. 9 is a schematic structural view of an image encryption device according to the present invention, the encryption device comprising:
and the marking unit is used for generating marking elements which are used for distinguishing the content needing to be encrypted from the content needing to be encrypted.
And the preprocessing unit marks the original image by using the marking element to form an image to be encrypted.
An encryption key, the encryption key randomly forming an encryption sequence.
And the calculating unit is used for calculating the encryption sequence and the marking element to obtain the encryption element.
And an encryption unit that encrypts the image to be encrypted by the encryption element, thereby forming an encrypted image.
The encryption device may also be provided without a preprocessing unit, i.e. the marking matrix is stored independently without being embedded in the image, without marking the original image.
Fig. 10 is a schematic structural view of an image decryption apparatus according to the present invention, the decryption apparatus comprising:
decryption keys that randomly form a decryption sequence.
The calculating unit is used for calculating the decryption sequence and the marking element to obtain a decryption element; the marking element is a binary marking matrix for distinguishing encrypted content from unencrypted content when encrypted.
And the decryption unit decrypts the encrypted image by using the decryption element to obtain a decrypted image.
Fig. 11 is a block diagram of an electronic device, shown in an embodiment of the invention. Referring to fig. 10, the electronic device may be an encryption device or a decryption device. The encryption device and the decryption device may be servers or terminals. The electronic device comprises a processor 1000 and a memory 2000 in which processor-executable instructions are stored, and the processor is in communication with the memory via a communication bus, from which the instructions can be read to implement the steps of the encryption and decryption methods described above.
The embodiments of the present invention also provide a readable storage medium having stored thereon computer instructions which, when executed by a processor, perform the steps of the encryption and decryption methods described above. The readable storage medium may be applied to a terminal, or may be applied to a server, and a technician may select according to a specific scenario, which is not limited herein.
It will be readily appreciated by those skilled in the art that the foregoing description is merely a preferred embodiment of the invention and is not intended to limit the invention, but any modifications, equivalents, improvements or alternatives falling within the spirit and principles of the invention are intended to be included within the scope of the invention.
Claims (13)
1. An image encryption method, comprising:
forming a marking element, wherein the marking element is used for distinguishing the content to be encrypted from the content not to be encrypted in the original image;
an encryption key is adopted to randomly form an encryption sequence, and the encryption sequence and the marking element are operated to obtain an encryption element;
encrypting the image to be encrypted through the encryption element to form an encrypted image;
the marking element is a binary marking matrix, if the spatial pixel matrix of the original image is I h×w =(I i,j ) h×w The marking matrix is m h×w =(m i,j ) h×w When I i,j For pixels requiring encryption m i,j =1, otherwise m i,j =0;
Where i=1, 2,3, …, h and j=1, 2,3, …, w, I i,j Taking a value between 0 and 255 as a single pixel of the image, wherein h and w are the height and width of the original image respectively;
the encryption sequence is an encryption matrix, and the encryption matrix is generated by using a secret key, wherein n+1 binary encryption matrices consisting of random 0 and 1 are sequentially respectively Wherein the parameter N is a natural number greater than 0 and less than 8 selected according to individual pixels of the image;
employing a marking matrix to encrypt the first N encryption matricesClearing elements corresponding to the non-encrypted pixel positions to obtain encrypted elements;
bit and operation are respectively adopted on the first N encryption matrixes and the marking matrix to obtain first N mask matrixes, the (n+1) th encryption matrix is not processed to directly form the (n+1) th mask matrix, and the (n+1) th mask matrix is an encryption element;
embedding the marking element into the original image to form an image to be encrypted;
the encryption element performs bit exclusive OR operation with the image to be encrypted to form an encrypted image;
forming the encrypted image includes: performing exclusive-or operation on N bit planes of the pixel matrix of the encrypted image except for the bit plane embedded by the marking matrix and the first N mask matrixes respectively, and performing exclusive-or operation on the last mask matrix and the bit plane embedded by the marking matrix to form the encrypted image; or the first N bit planes of the pixel matrix of the encrypted image are respectively exclusive-ored with the first N mask matrixes, and the last mask matrix is exclusive-ored with the bit plane embedded by the marking matrix to form the encrypted image.
2. The image encryption method according to claim 1, wherein a marking matrix is used to replace a bit of a single pixel of the original image to form the image to be encrypted.
3. The image encryption method according to claim 2, wherein the lowest bit of a single pixel of the original image is replaced with a marking matrix.
4. A method of encrypting an image according to any one of claims 1 to 3, wherein said marker element is not embedded in an original image, and said image to be encrypted is the original image.
5. An image encryption method according to claim 3, wherein the n+1 bit planes of 1,2, …, N,8 are exclusive-ored with the mask matrix for the image pixel matrix to be encrypted, respectively, and if N is smaller than 7, the n+1 to 7 bits of the image pixels after encryption are the same as before encryption, resulting in an encrypted image pixel matrix.
6. The image encryption method according to claim 1, wherein the parameter N is selected to be 3, 4, 5, 6 or 7.
7. The image encryption method according to claim 1, wherein RGB three color channels of the BMP image are encrypted as three images, respectively.
8. An image decryption method, comprising:
forming a decryption sequence by using the decryption key;
the decryption sequence and the marking element are used for operation to obtain a decryption element, and the marking element is a binary marking matrix used for distinguishing encrypted content from unencrypted content during encryption;
decrypting the encrypted image by using the decryption element to obtain a decrypted image;
the decryption key is the same as the encryption key used in encryption, and the formed decryption sequence is the same as the encryption sequence formed in encryption;
the decryption sequence is a decryption matrix, and the decryption key generates N+1 binary decryption matrices consisting of random 0 and random 1; wherein the parameter N is a natural number which is more than 0 and less than 8 and is selected according to single pixels of the image when in encryption;
bit and operation are respectively adopted for the first N decryption matrixes and the marking matrix, so that the first N mask matrixes adopted during encryption are obtained, and the (n+1) th decryption matrix is the (n+1) th mask matrix adopted during encryption without processing;
the n+1 mask matrices form decryption elements;
and performing exclusive OR operation on the corresponding bit planes of the encrypted image pixel matrix and decryption elements formed by the mask matrix respectively to obtain the decrypted image pixel matrix.
9. The image decryption method according to claim 8, wherein the marking matrix is obtained by exclusive-or-ing the n+1th matrix of the decryption matrices with the corresponding bit plane replaced by the marking matrix of the encrypted image.
10. An image encryption apparatus, characterized in that the encryption apparatus comprises:
the marking unit is used for generating marking elements which are used for distinguishing the content needing to be encrypted from the content needing to be encrypted; the marking element is a binary marking matrix, if the spatial pixel matrix of the original image is I h×w =(I i,j ) h×w The marking matrix is m h×w =(m i,j ) h×w When I i,j For pixels requiring encryption m i,j =1, otherwise m i,j =0;
Where i=1, 2,3, …, h and j=1, 2,3, …, w, I i,j Taking a value between 0 and 255 as a single pixel of the image, wherein h and w are the height and width of the original image respectively;
an encryption key, the encryption key randomly forming an encryption sequence; the encryption sequence is an encryption matrix, and the encryption matrix is generated by using a secret key, wherein n+1 binary encryption matrices consisting of random 0 and 1 are sequentially respectively Wherein the parameter N is a natural number greater than 0 and less than 8 selected according to individual pixels of the image;
employing a marking matrix to encrypt the first N encryption matricesClearing elements corresponding to the non-encrypted pixel positions to obtain encrypted elements;
the computing unit is used for carrying out operation on the encryption sequence and the marking element to obtain an encryption element; bit and operation are respectively adopted on the first N encryption matrixes and the marking matrix to obtain first N mask matrixes, the (n+1) th encryption matrix is not processed to directly form the (n+1) th mask matrix, and the (n+1) th mask matrix is an encryption element;
the preprocessing unit marks the original image by using marking elements to form an image to be encrypted;
an encryption unit that encrypts an image to be encrypted by an encryption element, thereby forming an encrypted image; the encryption element performs bit exclusive OR operation with the image to be encrypted to form an encrypted image;
forming the encrypted image includes: performing exclusive-or operation on N bit planes of the pixel matrix of the encrypted image except for the bit plane embedded by the marking matrix and the first N mask matrixes respectively, and performing exclusive-or operation on the last mask matrix and the bit plane embedded by the marking matrix to form the encrypted image; or the first N bit planes of the pixel matrix of the encrypted image are respectively exclusive-ored with the first N mask matrixes, and the last mask matrix is exclusive-ored with the bit plane embedded by the marking matrix to form the encrypted image.
11. An image decryption apparatus, characterized in that the decryption apparatus comprises:
a decryption key, the decryption key randomly forming a decryption sequence; the decryption key is the same as the encryption key used in encryption, and the formed decryption sequence is the same as the encryption sequence formed in encryption;
the decryption sequence is a decryption matrix, and the decryption key generates N+1 binary decryption matrices consisting of random 0 and random 1; wherein the parameter N is a natural number which is more than 0 and less than 8 and is selected according to single pixels of the image when in encryption;
bit and operation are respectively adopted for the first N decryption matrixes and the marking matrix, so that the first N mask matrixes adopted during encryption are obtained, and the (n+1) th decryption matrix is the (n+1) th mask matrix adopted during encryption without processing;
the n+1 mask matrices form decryption elements;
the calculating unit is used for calculating the decryption sequence and the marking element to obtain a decryption element; the marking element is a binary marking matrix used for distinguishing encrypted content from unencrypted content in encryption;
the decryption unit decrypts the encrypted image by using the decryption element to obtain a decrypted image; and performing exclusive OR operation on the corresponding bit planes of the encrypted image pixel matrix and decryption elements formed by the mask matrix respectively to obtain the decrypted image pixel matrix.
12. An electronic device, the electronic device comprising:
a processor;
a memory storing processor-executable instructions, wherein:
a processor reads instructions from a memory to implement the steps of the method according to any of claims 1-9.
13. A readable storage medium having stored thereon computer instructions, which when executed by a processor, implement the steps of the method of any of claims 1-9.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910478538.6A CN112040086B (en) | 2019-06-03 | 2019-06-03 | Image encryption and decryption methods and devices, equipment and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910478538.6A CN112040086B (en) | 2019-06-03 | 2019-06-03 | Image encryption and decryption methods and devices, equipment and readable storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112040086A CN112040086A (en) | 2020-12-04 |
CN112040086B true CN112040086B (en) | 2023-06-06 |
Family
ID=73576397
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910478538.6A Active CN112040086B (en) | 2019-06-03 | 2019-06-03 | Image encryption and decryption methods and devices, equipment and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112040086B (en) |
Families Citing this family (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113194334B (en) * | 2021-04-16 | 2023-06-06 | 厦门智瞳科技有限公司 | Privacy-protecting image processing method, privacy-protecting image processing device, terminal and storage medium |
CN113486377B (en) * | 2021-07-22 | 2025-01-10 | 维沃移动通信(杭州)有限公司 | Image encryption method, device, electronic device and readable storage medium |
CN114065144A (en) * | 2021-11-11 | 2022-02-18 | 北京达佳互联信息技术有限公司 | Image area transformation method, device, electronic device and storage medium |
CN114036542B (en) * | 2021-11-15 | 2025-03-14 | 阿里巴巴(中国)有限公司 | Data encryption and decryption method and computer storage medium |
CN115203723B (en) * | 2022-07-20 | 2023-06-09 | 浙江东昊信息工程有限公司 | Information encryption processing system for temple |
CN115001666A (en) * | 2022-08-04 | 2022-09-02 | 湖北微模式科技发展有限公司 | Image local encryption algorithm based on bit plane template XOR |
CN118070296A (en) * | 2022-11-23 | 2024-05-24 | 中兴通讯股份有限公司 | Data processing method, system, electronic device and storage medium |
CN115834791B (en) * | 2023-02-03 | 2023-04-25 | 徐工汉云技术股份有限公司 | Image encryption and decryption transmission method using matrix key and electronic equipment |
CN119172267A (en) * | 2024-08-27 | 2024-12-20 | 重庆贝特计算机系统工程有限公司 | A traffic security analysis system with intelligent operation and maintenance |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102349288A (en) * | 2009-03-19 | 2012-02-08 | 富士通株式会社 | Marker generation program, restoration program, marker generation device, restoration device, and marker generation method |
CN108242041A (en) * | 2016-12-26 | 2018-07-03 | 天津职业技术师范大学 | A random-bit non-blind watermarking method based on chaos |
CN108566500A (en) * | 2018-03-02 | 2018-09-21 | 西南交通大学 | The reversible hidden method of adapting to image encrypted domain based on Hybrid Encryption mechanism |
CN109791517A (en) * | 2016-12-21 | 2019-05-21 | 密码研究公司 | Parallel multiplication operation is protected to attack from external monitoring |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9639912B2 (en) * | 2014-12-30 | 2017-05-02 | University Of Macau | Method for reversible image data hiding |
-
2019
- 2019-06-03 CN CN201910478538.6A patent/CN112040086B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102349288A (en) * | 2009-03-19 | 2012-02-08 | 富士通株式会社 | Marker generation program, restoration program, marker generation device, restoration device, and marker generation method |
CN109791517A (en) * | 2016-12-21 | 2019-05-21 | 密码研究公司 | Parallel multiplication operation is protected to attack from external monitoring |
CN108242041A (en) * | 2016-12-26 | 2018-07-03 | 天津职业技术师范大学 | A random-bit non-blind watermarking method based on chaos |
CN108566500A (en) * | 2018-03-02 | 2018-09-21 | 西南交通大学 | The reversible hidden method of adapting to image encrypted domain based on Hybrid Encryption mechanism |
Also Published As
Publication number | Publication date |
---|---|
CN112040086A (en) | 2020-12-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112040086B (en) | Image encryption and decryption methods and devices, equipment and readable storage medium | |
CN112035847B (en) | Image encryption and decryption methods and devices, electronic equipment and storage medium | |
Abdel-Nabi et al. | Medical imaging security using partial encryption and histogram shifting watermarking | |
Najih et al. | An improved secure image hiding technique using PN-sequence based on DCT-OTP | |
CN110211018B (en) | Chaos encryption reversible information hiding method based on odd-even discrimination strategy | |
CN105812816A (en) | Compression encryption authentication joint coding method | |
Mehndiratta | Data hiding system using cryptography & steganography: a comprehensive modern investigation | |
CN105554344A (en) | Multi-image encryption method based on mixed graphics primitives | |
Bhardwaj et al. | Enhanced the security of image steganography through image encryption | |
CN111915474A (en) | Reversible encryption domain information hiding method based on integer transformation | |
CN115001666A (en) | Image local encryption algorithm based on bit plane template XOR | |
Ariyanto et al. | Performance analysis of LSB image steganography combined with blowfish-RC4 encryption in various file extensions | |
CN114465779A (en) | A reversible and separable ciphertext domain information hiding method and system | |
CN113206926A (en) | Method for balancing privacy and usability of image based on three-pixel-point encryption | |
Stalin et al. | Payback of image encryption techniques: a quantitative investigation | |
Rao et al. | A novel information security scheme using cryptic steganography | |
Aarthi et al. | Image encryption using binary bit plane and rotation method for an image security | |
Yadav et al. | A hybrid approach to metamorphic cryptography using KIMLA and DNA concept | |
John K et al. | A Secure Method to Hide Confidential Data Using Cryptography and Steganography | |
Sunar et al. | A fast approach to encrypt and decrypt of video streams for secure channel transmission | |
Nehra et al. | Review Paper On Image Based Steganography | |
Phapale et al. | Image Based Steganography Using Cryptography | |
Choudhary et al. | Key based image steganography using Dwt and chaotic map | |
Radhi et al. | Combining A Cryptography and Steganography Techniques–Based Securing Transmitted Video Through Unsecure Channel | |
Atown | Hide and Encryption Fingerprint Image by using LSB and Transposition pixel by Spiral Method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
PE01 | Entry into force of the registration of the contract for pledge of patent right | ||
PE01 | Entry into force of the registration of the contract for pledge of patent right |
Denomination of invention: Image encryption and decryption method, device, and readable storage medium Effective date of registration: 20231009 Granted publication date: 20230606 Pledgee: Bank of China Limited Wuhan Economic and Technological Development Zone sub branch Pledgor: HUBEI MICROPATTERN TECHNOLOGY DEVELOPMENT CO.,LTD. Registration number: Y2022420000271 |