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 PDF

Info

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
Application number
CN201910478538.6A
Other languages
Chinese (zh)
Other versions
CN112040086A (en
Inventor
陈友斌
徐一波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hubei Micropattern Technology Development Co ltd
Original Assignee
Hubei Micropattern Technology Development Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Hubei Micropattern Technology Development Co ltd filed Critical Hubei Micropattern Technology Development Co ltd
Priority to CN201910478538.6A priority Critical patent/CN112040086B/en
Publication of CN112040086A publication Critical patent/CN112040086A/en
Application granted granted Critical
Publication of CN112040086B publication Critical patent/CN112040086B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N1/00Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
    • H04N1/32Circuits 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/32101Display, printing, storage or transmission of additional information, e.g. ID code, date and time or title
    • H04N1/32144Display, 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/32149Methods relating to embedding, encoding, decoding, detection or retrieval operations
    • H04N1/32267Methods relating to embedding, encoding, decoding, detection or retrieval operations combined with processing of the image
    • H04N1/32272Encryption or ciphering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting 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/6245Protecting personal data, e.g. for financial or medical purposes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords
    • H04L9/0863Generation of secret information including derivation or calculation of cryptographic keys or passwords involving passwords or one-time passwords
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords
    • H04L9/0869Generation of secret information including derivation or calculation of cryptographic keys or passwords involving random numbers or seeds

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

Image encryption and decryption methods and devices, equipment and readable storage medium
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
Figure BDA0002083060790000031
Figure BDA0002083060790000032
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 matrices
Figure BDA0002083060790000033
And 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
Figure BDA0002083060790000071
Further, n+1 mask matrices are obtained as follows:
Figure BDA0002083060790000072
Figure BDA0002083060790000073
Figure BDA0002083060790000074
Figure BDA0002083060790000075
wherein ∈A is the bit and operation, i.e., the operation will be
Figure BDA0002083060790000076
And (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
Figure BDA0002083060790000077
Figure BDA0002083060790000078
Figure BDA0002083060790000079
Performing exclusive OR operation, i.e.)>
Figure BDA00020830607900000710
Here->
Figure BDA00020830607900000711
And->
Figure BDA00020830607900000712
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
Figure BDA0002083060790000081
Figure BDA0002083060790000082
The n+1 matrices are identical to the matrix generated at the time of encryption. Due to the fact that therein
Figure BDA0002083060790000083
Thus use mask matrix->
Figure BDA0002083060790000084
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.
Figure BDA0002083060790000085
The mask matrix of the bit-planes is then obtained, i.e. the decryption elements are as follows:
Figure BDA0002083060790000086
Figure BDA0002083060790000087
Figure BDA0002083060790000088
Figure BDA0002083060790000089
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
Figure BDA00020830607900000810
Figure BDA00020830607900000811
Figure BDA00020830607900000812
Performing exclusive OR operation, i.e. pixel->
Figure BDA00020830607900000813
Here->
Figure BDA00020830607900000814
And->
Figure BDA00020830607900000815
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
Figure FDA0004205959830000011
Figure FDA0004205959830000012
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 matrices
Figure FDA0004205959830000013
Clearing 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
Figure FDA0004205959830000031
Figure FDA0004205959830000032
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 matrices
Figure FDA0004205959830000033
Clearing 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.
CN201910478538.6A 2019-06-03 2019-06-03 Image encryption and decryption methods and devices, equipment and readable storage medium Active CN112040086B (en)

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 (5)

* Cited by examiner, † Cited by third party
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
CN113486377A (en) * 2021-07-22 2021-10-08 维沃移动通信(杭州)有限公司 Image encryption method and device, electronic equipment and readable 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
CN115834791B (en) * 2023-02-03 2023-04-25 徐工汉云技术股份有限公司 Image encryption and decryption transmission method using matrix key and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
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 kind of non-blind watermark implementing method of random order 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)

* Cited by examiner, † Cited by third party
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

Patent Citations (4)

* Cited by examiner, † Cited by third party
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 kind of non-blind watermark implementing method of random order 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
Yi et al. Parametric reversible data hiding in encrypted images using adaptive bit-level data embedding and checkerboard based prediction
Najih et al. An improved secure image hiding technique using PN-sequence based on DCT-OTP
Abdel-Nabi et al. Medical imaging security using partial encryption and histogram shifting watermarking
CN112035847B (en) Image encryption and decryption methods and devices, electronic equipment and storage medium
Maiti et al. Data hiding in images using some efficient steganography techniques
Mehndiratta Data hiding system using cryptography & steganography: a comprehensive modern investigation
Bhardwaj et al. Enhanced the security of image steganography through image encryption
CN111915474A (en) Reversible encryption domain information hiding method based on integer transformation
Al-Kadei Robust video data security using hybrid cryptography-steganography technique
Sunar et al. A fast approach to encrypt and decrypt of video streams for secure channel transmission
CN115001666A (en) Image local encryption algorithm based on bit plane template XOR
Rao et al. A novel information security scheme using cryptic steganography
Ariyanto et al. Performance Analysis of LSB Image Steganography Combined with Blowfish-RC4 Encryption in Various File Extensions
CN107590369B (en) Homomorphic encrypted domain reversible information hiding method based on code division multiplexing and value expansion
Yadav et al. A hybrid approach to metamorphic cryptography using KIMLA and DNA concept
Stalin et al. Payback of image encryption techniques: a quantitative investigation
Choudhary et al. Key based image steganography using Dwt and chaotic map
Nehra et al. Review Paper On Image Based Steganography
Alhassan et al. A Secure Method to Hide Confidential Data Using Cryptography and Steganography
Jawad Combining A Cryptography and Steganography Techniques–Based Securing Transmitted Video Through Unsecure Channel
Naidu et al. Cryptography based medical image security with LSB blowfish algorithms
Lukose et al. Combining Cryptography and Steganography for Data Hiding in Videos
Sen et al. A contemplator on reversible data hiding in encrypted domain
Swain et al. Better steganography using the six square cipher algorithm

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