CN112040086A - Image encryption and decryption method and device, equipment and readable storage medium - Google Patents

Image encryption and decryption method and device, equipment and readable storage medium Download PDF

Info

Publication number
CN112040086A
CN112040086A CN201910478538.6A CN201910478538A CN112040086A CN 112040086 A CN112040086 A CN 112040086A CN 201910478538 A CN201910478538 A CN 201910478538A CN 112040086 A CN112040086 A CN 112040086A
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.)
Granted
Application number
CN201910478538.6A
Other languages
Chinese (zh)
Other versions
CN112040086B (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

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 method, an image decryption method, an image encryption device, an image decryption device, image encryption equipment and a readable storage medium. The image encryption method comprises the following steps: generating a binary mark matrix according to image content needing to be encrypted in an original image; marking the original image by using the generated marking matrix; forming an encryption matrix by using a secret key at random, and performing AND operation on the encryption matrix and the mark matrix to obtain a mask matrix; and performing exclusive-or operation on the marked image through a mask matrix to form an encrypted image. When in decryption, firstly, the encrypted pixel mark matrix is restored on the corresponding bit plane by using the XOR operation, and the corresponding bit plane of all the encrypted pixels is subjected to the XOR operation again to restore the content of the encrypted pixels of the image. By the method and the device, the user can restrict the access authority of the part of people to the image part content. The user himself or an authorized party restores the original content via the protected image when conditions permit.

Description

Image encryption and decryption method and device, equipment and readable storage medium
Technical Field
The invention relates to an information transmission technology, in particular to an image encryption and decryption method, device, equipment and readable storage medium.
Background
With the development of digital media and internet technology, the phenomenon of individuals or organizations publishing or disseminating images over networks has become more and more common. In particular, rapid advances in cloud computing have allowed more and more image data to be uploaded to cloud storage. The access of multiple users in the big data environment greatly facilitates the work and life of people. However, the act of publishing or sending the raw picture without processing also risks revealing the privacy of the individual.
In order to solve the problem of privacy disclosure caused by image privacy content release, an effective and feasible method is to encrypt a sensitive portion in an image, for example, to perform mosaic addition on related protected content or directly delete the sensitive content. These processed images are often irreproducible and even so result in permanent loss of true information. The other method is to encrypt the whole image, and the method takes the whole image as a protected object and protects the whole image by a cryptographic method. But this will cause the hiding of other non-private information, affecting the distribution of non-private information.
Steganography is a technique that can embed secret information in digital media without creating visual anomalies. Common image-based steganography is mainly implemented by embedding on the lowest bits of pixels of a bitmap image or the lowest bits of quantized DCT coefficients of a JPEG image. During extraction, the user can obtain embedded bit information at the previous embedding position. For image content encryption, the technology can embed the information of the encryption position into the image without causing visual abnormality. The encryptor can extract the information to complete image decryption during restoration. Patent documents CN201710203809.8 (an image encryption method based on RC4 algorithm), CN201610856467.5 (an image encryption method and apparatus, a key stream generation method and a key stream generator), and CN201810067051.4 (an image encryption method based on hyper-chaotic system and multilevel scrambling) are all image content encryption inventions, but these image encryption methods are only suitable for image whole encryption, and are not suitable for image partial content encryption.
Disclosure of Invention
In view of the above drawbacks and needs of the prior art, the present invention provides an image encryption and decryption method, apparatus, device and readable storage medium, where the method is a spatial domain image content encryption algorithm based on steganography. By the method and the device, the user can restrict the access authority of the part of people to the image part content. The user himself or an authorized party restores the original content via the protected image when conditions permit. The invention can carry out local encryption protection on the image content, and the encryption position information is embedded into the image in a factor mode. The encryption algorithm has high running speed and high encryption safety.
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 needing to be encrypted from the content needing not to be encrypted in the original image;
randomly forming an encryption sequence by adopting an encryption key, and calculating the encryption sequence and the marking element to obtain an encryption element;
and encrypting the image to be encrypted by the encryption element to form an encrypted image.
Specifically, the marking element is a binary marking matrix, and if the spatial pixel matrix of the original image is Ih×w=(Ii,j)h×wThen the label matrix is mh×w=(mi,j)h×wWhen I isi,jM for pixels requiring encryptioni,j1, or vice versai,j=0;
Wherein I is 1,2,3, …, h and j is 1,2,3, …, w, Ii,jThe value of each pixel of the image 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 secret key, and are sequentially and respectively
Figure BDA0002083060790000031
Figure BDA0002083060790000032
Wherein the parameter N is a natural number which is selected according to a single pixel of the image and is greater than 0 and less than 8;
using mark matrix to encrypt the first N encryption matrixes
Figure BDA0002083060790000033
And clearing the elements corresponding to the positions of the non-encrypted pixels to obtain the encrypted elements.
Specifically, the first N encryption matrices and the mark matrix are respectively subjected to bit and operation to obtain first N mask matrices, the (N + 1) th encryption matrix is directly formed without processing to form an (N + 1) th mask matrix, and the (N + 1) th mask matrix is an encryption element.
Specifically, the method comprises the following steps: and embedding the mark elements into the original image to form an image to be encrypted.
Specifically, a mark matrix is adopted to replace a certain bit of a single pixel of the original image, and an image to be encrypted is formed. The bit is agreed in advance by the transmitting and receiving parties.
Specifically, the lowest bit of a single pixel of the original image is replaced with a marker matrix.
Specifically, the mark element is not embedded in 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 an encrypted image.
Specifically, the encryption element and the image to be encrypted are subjected to bit exclusive or operation to form an encrypted image.
Specifically, the xor operation is performed on the first N bit planes of the pixel matrix of the encrypted image except the bit plane in which the tag matrix is embedded and the first N mask matrices, and the xor operation is performed on the last mask matrix and the bit plane in which the tag matrix is embedded, so as to form the encrypted image.
Specifically, the first N bit planes of the pixel matrix of the encrypted image are subjected to exclusive-or operation with the first N mask matrices, and the last mask matrix is subjected to exclusive-or operation with the bit plane embedded by the mark matrix to form the encrypted image.
Specifically, the N +1 bit planes of the 1 st, 2 nd, … th, N,8 th bits of the pixel matrix of the image to be encrypted and the mask matrix are subjected to exclusive-or operation respectively, and if N is less than 7, the N +1 th to 7 th bits of the pixel of the image after encryption are the same as those before encryption, so that the pixel matrix of the encrypted image is obtained.
Specifically, the parameter N is preferably 3, 4, 5, 6, or 7. The encryption effect can be ensured.
Specifically, the three RGB color channels of the BMP image are respectively encrypted as three images.
The invention also provides an image decryption method, which comprises the following steps:
forming a decryption sequence by adopting a decryption key;
calculating by using a decryption sequence and a mark element to obtain a decryption element, wherein the mark element is a binary mark matrix used for distinguishing encrypted content from non-encrypted 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 composed of random 0 s and 1 s; wherein the parameter N is a natural number which is selected according to a single pixel of the image and is larger than 0 and smaller than 8 during encryption;
respectively carrying out bit AND operation on the first N decryption matrixes and the mark matrix to obtain first N mask matrixes adopted during encryption, wherein the N +1 th decryption matrix is not processed, namely the N +1 th mask matrix adopted during encryption;
the N +1 mask matrices form decryption elements.
Specifically, the encrypted image pixel matrix and the decryption elements formed by the mask matrix are subjected to bit plane exclusive or operation to obtain the decrypted image pixel matrix.
Specifically, the N +1 th matrix in the decryption matrix and the bit plane corresponding to the replacement of the mark matrix in the image encryption process are used for carrying out exclusive or operation to obtain the mark matrix.
The present invention also provides an image encryption apparatus, comprising:
a marking unit that generates a marking element for distinguishing a content that needs to be encrypted and a content that does not need to be encrypted;
an encryption key, said encryption key randomly forming an encryption sequence;
the computing unit is used for calculating the encryption sequence and the marking element to obtain an encryption element;
an encryption unit that encrypts an image to be encrypted by an encryption element, thereby forming an encrypted image.
Specifically, the encryption device further includes: the preprocessing unit marks the original image by using the marking elements to form an image to be encrypted.
The present invention also provides an image decryption apparatus, comprising:
a decryption key, the decryption key randomly forming a decryption sequence;
the computing unit is used for calculating the decryption sequence and the marking element to obtain a decryption element; the mark element is a binary mark matrix used for distinguishing encrypted content from non-encrypted content during encryption;
and the decryption unit decrypts the encrypted image by using the decryption element to obtain a decrypted image.
The present invention also provides an electronic device, including:
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 present 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 the local encryption of the image, and the user can restrict the access authority of part of people to the partial content of the image. The user himself or an authorized party restores the original content via the protected image when conditions permit. 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 encrypted position information into the image, and the decryptor can decrypt the image content only by obtaining the decryption key;
(3) the invention has the advantages of high encryption and decryption operation speed and high safety.
Drawings
FIG. 1 is a schematic diagram of an image encryption process according to the present invention.
FIG. 2 is a diagram illustrating an image decryption process 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 diagram illustrating a key generation random binary matrix according to the present invention.
FIG. 5 is a diagram illustrating a mask matrix generation according to the present invention.
Fig. 6 is a schematic diagram of an encrypted image of the present invention.
Fig. 7 is a schematic diagram of an image to be encrypted generated according to a second embodiment of the present invention.
Fig. 8 is a schematic diagram of an encrypted image generated by the second embodiment of the present 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 apparatus of the present invention.
Fig. 11 is a schematic structural diagram of an electronic device according to the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. In addition, the technical features involved in the embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
FIG. 1 is a schematic diagram of an image encryption process according to the present invention. The method comprises the following specific steps.
Setting the spatial pixel matrix of the original image to be encrypted as Ih×w=(Ii,j)h×wI ═ 1,2,3, …, h and j ═ 1,2,3, …, w, where I isi,jIs 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 select the value of the parameter N in advance, where N is any one of 1,2,3, …, and 7.
A matrix of markers is generated. In this step, a mark matrix m is generatedh×w=(mi,j)h×wI is 1,2,3, …, h and j is 1,2,3, …, w. When I isi,jOrder m for pixels that need to be encryptedi,j1, or vice versai,j=0。
The mark matrix is steganographically embedded in the original image. The embedding may be a bit replacement, i.e. replacing a bit in the image pixel value with a bit that needs to be embedded. In this step m isi,jReplacement Ii,jI.e. the position-marker matrix mh×wEmbedded image Ih×wAnd obtaining the image to be encrypted. The image before and after embedding is basically unchanged, and the image to be encrypted after embedding is recorded as I'h×w=(I′i,j)h×w
And generating N +1 mask matrixes by using the key K according to a parameter N selected in advance by the user. In the step, a secret key K is used for generating N +1 binary matrixes composed of random 0 and 1, and the binary matrixes are respectively recorded as
Figure BDA0002083060790000071
Further, the following N +1 mask matrices are obtained:
Figure BDA0002083060790000072
Figure BDA0002083060790000073
Figure BDA0002083060790000074
Figure BDA0002083060790000075
wherein Λ is the bit and operation, i.e. the operation in the above formula will
Figure BDA0002083060790000076
And clearing mask elements corresponding to the positions of the non-encrypted pixels to obtain a mask matrix, namely encrypted elements.
The image is encrypted using a mask matrix xor operation. In this step, for the pixel matrix I 'of the image to be encrypted'h×w=(I′i,j)h×wThe 1 st, 2 nd, … th, N,8 th bit planes from high to low are respectively connected with
Figure BDA0002083060790000077
Figure BDA0002083060790000078
Figure BDA0002083060790000079
Perform an XOR operation, i.e.
Figure BDA00020830607900000710
Here, the
Figure BDA00020830607900000711
And
Figure BDA00020830607900000712
respectively represent image pixels I 'before encryption of image to be encrypted'i,jAnd encrypted image pixel I ″)i,jThe kth bit from high to low, k ═ 1,2, ·, N, 8. If N is present<7,I″i,jN +1 to 7 th bit and l'i,jSame, remain unchanged. Finally obtaining Ih×w=(I″i,j)h×wIs an encrypted image pixel matrix. Will I ″)h×wAnd storing the image file to obtain a final encrypted image.
FIG. 2 is a diagram illustrating an image decryption process 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. In the step, a secret key K is used for generating N +1 binary matrixes composed of random 0 and 1, and the binary matrixes are respectively recorded as
Figure BDA0002083060790000081
Figure BDA0002083060790000082
The N +1 matrices are identical to the matrices generated during encryption. Due to therein
Figure BDA0002083060790000083
Thus using a mask matrix
Figure BDA0002083060790000084
And the encrypted image pixel matrix Ih×w=(I″i,j)h×wPerforming XOR on the lowest bit plane to obtain an encrypted pixel label matrix mh×w={mi,j}h×wI.e. by
Figure BDA0002083060790000085
A mask matrix of bit planes is then obtained, i.e. the decryption elements are as follows:
Figure BDA0002083060790000086
Figure BDA0002083060790000087
Figure BDA0002083060790000088
Figure BDA0002083060790000089
and decrypting the image by using mask matrix exclusive-or operation. In this step for the image pixel matrix Ih×w=(I″i,j)h×wThe 1 st, 2 nd, … th, N,8 th bit planes from high to low are respectively connected with
Figure BDA00020830607900000810
Figure BDA00020830607900000811
Figure BDA00020830607900000812
By performing an XOR operation, i.e. pixel
Figure BDA00020830607900000813
Herein, the
Figure BDA00020830607900000814
And
Figure BDA00020830607900000815
respectively represent encrypted Pre-pixel I'i,jAnd encrypted pixel I ″)i,jThe kth bit from high to low, k ═ 1,2, ·, N, 8. If N is present<7,I′i,jN +1 to 7 th bit and I ″)i,jThe same is true. Finally obtain I'h×w=(I′i,j)h×wTo decrypt the image pixel matrix. Is prepared from'h×wStored as an image file to obtain the final decrypted image.
In the step of embedding the mark matrix into the original image in a steganographic manner, the mark matrix of the encrypted pixel can be embedded into other bit planes to realize the marking of the original image. When the mark matrix is embedded into other bits, the first N bit planes are respectively subjected to XOR operation with the first N mask matrixes to realize content encryption, and the last mask matrix is subjected to XOR operation with the bit plane embedded into the mark matrix to encrypt the mark information. And obtaining an encrypted image after the XOR operation is completed. Other steps are varied accordingly.
In the step of embedding the mark matrix into the original image in a steganography manner, the mark matrix can be independently stored, and if the mark matrix is independently stored, the image to be encrypted is the original image Ih×w=(Ii,j)h×w. Since there is no need to embed the marker information into the image, the encryption method only needs to xor the first N encryption mask matrices with the first N bit planes. Other steps are varied accordingly.
In the step of encrypting the image by using the mask matrix exclusive-or operation, other bit planes of the pixel matrix of the image to be encrypted may be subjected to exclusive-or operation with the mask matrix, specifically, N bit planes of the pixel matrix of the encrypted image except for the bit plane in which the tag matrix is embedded are subjected to exclusive-or operation with the first N mask matrices, and the last mask matrix is subjected to exclusive-or operation with the bit plane in which the tag matrix is embedded, so as 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 position relationship thereof in actual operation. According to actual needs, the last mask matrix can be placed at the first, and the first N mask matrices are placed at the back, as long as corresponding operational relationships are maintained. For convenience, the embodiment of the present invention puts the mask matrix that is xored with the bit plane embedded with the tag matrix in the last one.
Example one
Taking an 8 × 8 color BMP image, taking N — 4 as an example, three RGB color channels of the BMP image are used, and an encryptor encrypts an original image as three images respectively, taking one of the three color channels as an example, the steps are as follows:
see fig. 3, which is a process of replacing the lowest bit of a single pixel of an original image with a matrix of marks.
Generating a mark matrix: the encryptor generates a tag matrix 3a composed of 0 s and 1 s from the pixels related to the contents to be encrypted in the BMP image.
Steganographically embedding the marking matrix into a color channel matrix 3b of the original image: the transmitting side and the receiving side agree in advance, and the encryptor embeds the mark matrix into the lowest bit (last bit) plane of the image to obtain the marked image, namely the image matrix 3c to be encrypted.
As in fig. 4 and 5, a mask matrix is generated: the encryptor uses the key to generate 5 random binary matrixes 4a-4e, the first 4 encryption matrixes 4a-4d are respectively subjected to AND operation with the mark matrix 3a to obtain the first 4 mask matrixes 5a-5d, and the last encryption matrix 4e is not processed to directly form the 5 th mask matrix 5 e.
Encrypting the image using a mask matrix xor operation: the encryptor uses the mask matrixes 5a-5e to perform exclusive-or operation with 5 bit planes of 1 st, 2 nd, 3 rd, 4 th and 8 th pixels 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 all encrypted, and the three component images are merged and stored as a BMP image as a final encrypted image.
After the above encryption process is completed, the encryptor can transmit the encrypted image and the key to the decryptor.
The decryption principle is based on the characteristic that any bit can obtain an original value before XOR after two times of XOR operation. The image decryption steps are as follows:
for the above-described BMP color image that has been encrypted, the decryptor uses a key at the time of encryption as a decryption key. And respectively decrypting the three channels of RGB as three images.
Firstly, generating a mask matrix: the decryptor uses the key to generate 5 decryption matrices as shown in fig. 4 (i.e. encryption matrices in encryption), then uses the lowest bit plane of the 5 th decryption matrix 4e directly exclusive-or with the encrypted image matrix (shown in fig. 6) or obtains the pixel mark matrix 3a in encryption, and further uses the mark matrix 3a exclusive-or with the first four random binary decryption matrices 4a-4d to obtain the decryption elements, i.e. mask matrix images 5a-5 d.
Decrypting the image using a mask matrix xor operation: and the decryptor uses the mask matrix to carry out exclusive OR operation with the highest four bit planes and the 8 th bit plane of the image, namely 5 bit planes of 1 st, 2 nd, 3 rd, 4 th and 8 th bits, so as to restore the image before encryption. The restored image is a marked image, and the marked image and the original image only have difference on the lowest bit. From the aspect of image content, the content difference between the two is not perceptible, and the content of the image is restored.
Example two
Taking an 8 × 8 color BMP image, taking N — 4 as an example, the RGB three color channels of the BMP image are used, the encryptor encrypts the original image (the same as in the first embodiment) as three images respectively, and taking one of the color channels as an example, the marking matrix is embedded into the 7 th bit plane from top to bottom of the image, so as to obtain a marked image, i.e., an image matrix to be encrypted (see fig. 7).
And respectively carrying out exclusive-or operation on 5 bit planes of 1 st, 2 nd, … th, 4 th and 7 th bit planes of the pixel matrix of the image to be encrypted and the mask matrix, wherein the three bit planes of the 5 th, 6 th and 8 th bit planes of the pixel matrix of the image after encryption are the same as those before encryption, and obtaining an encrypted image pixel matrix (as shown in figure 8). Correspondingly, when the mark matrix is extracted in the decryption step, the mark matrix is extracted from the 7 th bit plane, that is, the 5 th mask matrix and the bit plane embedded in the mark matrix, that is, the 7 th bit plane, are subjected to exclusive-or operation to obtain the mark matrix.
And the decryptor performs exclusive-or operation on 5 bit planes of the 1 st bit plane, the 2 nd bit plane, the 3 th bit plane, the 4 th bit plane and the 7 th bit plane of the image by using the mask matrix to restore the image before encryption. The other steps were the same as the example steps.
When the tag matrix is embedded into other bits (here, the 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 th, and 4 th mask matrices, respectively, to implement content encryption, and the 5 th mask matrix is exclusive-ored with the 7 th bit plane, which is the bit plane in which the tag matrix is embedded, to encrypt tag information.
EXAMPLE III
In this embodiment, the image to be encrypted is the original image, the original image 3b shown in fig. 3 and the mask matrix shown in fig. 5 are directly subjected to xor to obtain an encrypted image, and the encrypted image is sent to the decryptor separately after being encrypted. The decryptor does not need to extract the marking matrix, directly uses the marking matrix and the random matrix generated by the secret key and shown in fig. 4 to carry out operation to obtain the mask matrix, and obtains the decrypted image by using the XOR of the first 4 mask matrices and the first 4 bit planes of the encrypted image. The final decrypted image is the original image. By independently storing and storing the mark matrix, the decrypted image and the original image can be ensured to be completely consistent. Since there is no need to embed the tag information into the image, the encryption method only needs to xor the first 4 encryption mask matrices with the first 4 bit planes. By adopting the method, the secret key can be generated only by generating N binary encryption matrixes, and the N encryption matrixes are respectively subjected to AND operation with the mark matrix to obtain N mask matrixes.
According to the invention, the user can restrict the access right of the partial person to the image partial content. The user himself or an authorized party restores the original content via the protected image when conditions permit. Because the encrypted image is generated based on the data encryption of the partial area of the original image, the normal identification of the non-sensitive content at other positions of the image can be ensured on the premise of protecting partial sensitive information. In addition, the data volume of the terminal decryption image is small, the time required by the terminal decryption is short, the real-time performance of viewing the original image is improved, and the use experience of a user is further improved.
Fig. 9 is a schematic structural diagram of an image encryption device according to the present invention, the encryption device including:
a marking unit that generates a marking element for distinguishing content that needs to be encrypted from content that does not need to be encrypted.
The preprocessing unit marks the original image by using the marking elements to form an image to be encrypted.
An encryption key, the encryption key randomly forming an encryption sequence.
And the computing unit is used for computing the encryption sequence and the marking element to obtain the encryption element.
An encryption unit that encrypts an image to be encrypted by an encryption element, thereby forming an encrypted image.
The encryption device also has no preprocessing unit, namely, the marking matrix is independently stored and is not embedded into the image, and the original image is not required to be marked.
Fig. 10 is a schematic structural diagram of an image decryption apparatus according to the present invention, the decryption apparatus comprising:
a decryption key, the decryption key randomly forming a decryption sequence.
The computing unit is used for calculating the decryption sequence and the marking element to obtain a decryption element; the mark element is a binary mark matrix used for distinguishing encrypted content from non-encrypted content during encryption.
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 a server or a terminal. The electronic device comprises a processor 1000 and a memory 2000 storing processor-executable instructions, and the processor is in communication with the memory via a communication bus, and is capable of reading the instructions from the memory to implement the steps of the encryption and decryption method described above.
Embodiments of the present invention also provide a readable storage medium, on which computer instructions are stored, which when executed by a processor implement the steps of the above encryption and decryption methods. It should be noted that the readable storage medium may be applied to a terminal, and may also be applied to a server, and a technician may select the readable storage medium according to a specific scenario, which is not limited herein.
It will be understood by those skilled in the art that the foregoing is only a preferred embodiment of the present invention, and is not intended to limit the invention, and that any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (22)

1. An image encryption method, comprising:
forming a marking element, wherein the marking element is used for distinguishing the content needing to be encrypted from the content needing not to be encrypted in the original image;
randomly forming an encryption sequence by adopting an encryption key, and calculating the encryption sequence and the marking element to obtain an encryption element;
and encrypting the image to be encrypted by the encryption element to form an encrypted image.
2. The image encryption method according to claim 1, wherein the flag element is a binary flag matrix if the spatial pixel matrix of the original image is Ih×w=(Ii,j)h×wThen the label matrix is mh×w=(mi,j)h×wWhen I isi,jM for pixels requiring encryptioni,j1, or vice versai,j=0;
Wherein I is 1,2,3, …, h and j is 1,2,3, …, w, Ii,jThe value of each pixel of the image is between 0 and 255, and h and w are the height and width of the original image respectively.
3. The image encryption method according to claim 2, wherein the encryption sequence is an encryption matrix, and N +1 binary encryption matrices composed of random 0 and 1 are generated using the encryption key, in turn respectively
Figure FDA0002083060780000011
Figure FDA0002083060780000012
Wherein the parameter N is a natural number which is selected according to a single pixel of the image and is greater than 0 and less than 8;
using mark matrix to encrypt the first N encryption matrixes
Figure FDA0002083060780000013
And clearing the elements corresponding to the positions of the non-encrypted pixels to obtain the encrypted elements.
4. The image encryption method according to claim 3,
and respectively carrying out bit AND operation on the first N encryption matrixes and the mark matrix to obtain first N mask matrixes, directly forming an N +1 mask matrix without processing the N +1 encryption matrix, wherein the N +1 mask matrixes are encryption elements.
5. The image encryption method according to any one of claims 1 to 4, comprising:
and embedding the mark elements into the original image to form an image to be encrypted.
6. The image encryption method according to claim 5, wherein the image to be encrypted is formed by replacing a bit of a single pixel of the original image with a marker matrix.
7. The image encryption method according to claim 6, wherein the lowest bit of a single pixel of the original image is replaced with a marker matrix.
8. The image encryption method according to any one of claims 1 to 4, wherein the marker element is not embedded in an original image, and the image to be encrypted is the original image.
9. The image encryption method according to any one of claims 1 to 7, wherein the encryption element is subjected to bit exclusive OR operation with the image to be encrypted to form an encrypted image; specifically, the XOR operation is carried out on N bit planes of the pixel matrix of the encrypted image except the bit plane embedded by the mark matrix and the first N mask matrixes respectively, and the XOR operation is carried out on the last mask matrix and the bit plane embedded by the mark matrix to form the encrypted image; specifically, the first N bit planes of the pixel matrix of the encrypted image are subjected to exclusive-or operation with the first N mask matrices, and the last mask matrix is subjected to exclusive-or operation with the bit plane embedded by the mark matrix to form the encrypted image.
10. The image encryption method according to claim 7, wherein the N +1 bit planes of the 1 st, 2 nd, … th, N,8 th bits of the pixel matrix of the image to be encrypted are respectively subjected to exclusive-or operation with the mask matrix, and if N is less than 7, the N +1 th to 7 th bits of the pixel of the image after encryption are the same as those before encryption, thereby obtaining the pixel matrix of the encrypted image.
11. The image encryption method according to claim 3, wherein the parameter N is selected to be 3, 4, 5, 6 or 7.
12. The image encryption method according to claim 1, wherein the three RGB color channels of the BMP image are encrypted as three images, respectively.
13. An image decryption method, comprising:
forming a decryption sequence by adopting a decryption key;
calculating by using a decryption sequence and a mark element to obtain a decryption element, wherein the mark element is a binary mark matrix used for distinguishing encrypted content from non-encrypted content during encryption;
and decrypting the encrypted image by using the decryption element to obtain a decrypted image.
14. The image decryption method according to claim 13, wherein the decryption key is the same as the encryption key used in the encryption, and a decryption sequence is formed in the same manner as an encryption sequence formed in the encryption.
15. The image decryption method according to claim 14, wherein the decryption sequence is a decryption matrix, and the decryption key generates N +1 binary decryption matrices composed of random 0 s and 1 s; wherein the parameter N is a natural number which is selected according to a single pixel of the image and is larger than 0 and smaller than 8 during encryption;
respectively carrying out bit AND operation on the first N decryption matrixes and the mark matrix to obtain first N mask matrixes adopted during encryption, wherein the N +1 th decryption matrix is not processed, namely the N +1 th mask matrix adopted during encryption;
the N +1 mask matrices form decryption elements.
16. The image decryption method of claim 15, wherein the encrypted image pixel matrix is subjected to exclusive-or operation of the corresponding bit planes with the decryption elements formed by the mask matrix, respectively, to obtain the decrypted image pixel matrix.
17. The image decryption method according to claim 14 or 15, wherein the N +1 th matrix in the decryption matrix is exclusive-ored with the bit plane corresponding to the bit plane replaced by the tag matrix when the image is encrypted to obtain the tag matrix.
18. An image encryption apparatus, characterized in that the encryption apparatus comprises:
a marking unit that generates a marking element for distinguishing a content that needs to be encrypted and a content that does not need to be encrypted;
an encryption key, said encryption key randomly forming an encryption sequence;
the computing unit is used for calculating the encryption sequence and the marking element to obtain an encryption element;
an encryption unit that encrypts an image to be encrypted by an encryption element, thereby forming an encrypted image.
19. The image encryption apparatus according to claim 18, characterized in that the encryption apparatus further comprises: the preprocessing unit marks the original image by using the marking elements to form an image to be encrypted.
20. An image decryption apparatus, characterized in that the decryption apparatus comprises:
a decryption key, the decryption key randomly forming a decryption sequence;
the computing unit is used for calculating the decryption sequence and the marking element to obtain a decryption element; the mark element is a binary mark matrix used for distinguishing encrypted content from non-encrypted content during encryption;
and the decryption unit decrypts the encrypted image by using the decryption element to obtain a decrypted image.
21. An electronic device, characterized in that the electronic device comprises:
a processor;
a memory storing processor-executable instructions, wherein:
the processor reads instructions from the memory to implement the steps of the method of any of claims 1-17.
22. A readable storage medium having stored thereon computer instructions, which when executed by a processor, perform the steps of the method of any one of claims 1 to 17.
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 true CN112040086A (en) 2020-12-04
CN112040086B 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)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113194334A (en) * 2021-04-16 2021-07-30 厦门智瞳科技有限公司 Image processing method and device for protecting privacy, terminal and storage medium
CN113486377A (en) * 2021-07-22 2021-10-08 维沃移动通信(杭州)有限公司 Image encryption method and device, electronic equipment and readable storage medium
CN114036542A (en) * 2021-11-15 2022-02-11 阿里巴巴(中国)有限公司 Data encryption and decryption method and computer storage medium
CN115001666A (en) * 2022-08-04 2022-09-02 湖北微模式科技发展有限公司 Image local encryption algorithm based on bit plane template XOR
CN115203723A (en) * 2022-07-20 2022-10-18 浙江东昊信息工程有限公司 Information encryption processing system for temple
CN115834791A (en) * 2023-02-03 2023-03-21 徐工汉云技术股份有限公司 Image encryption and decryption transmission method using matrix key and electronic equipment
WO2024109211A1 (en) * 2022-11-23 2024-05-30 中兴通讯股份有限公司 Data processing method and system, electronic device, and computer readable storage medium

Citations (5)

* 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
US20160189325A1 (en) * 2014-12-30 2016-06-30 University Of Macau Method for reversible image data hiding
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

Patent Citations (5)

* 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
US20160189325A1 (en) * 2014-12-30 2016-06-30 University Of Macau Method for reversible image data hiding
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

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113194334A (en) * 2021-04-16 2021-07-30 厦门智瞳科技有限公司 Image processing method and device for protecting privacy, terminal and storage medium
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
CN114036542A (en) * 2021-11-15 2022-02-11 阿里巴巴(中国)有限公司 Data encryption and decryption method and computer storage medium
CN115203723A (en) * 2022-07-20 2022-10-18 浙江东昊信息工程有限公司 Information encryption processing system for temple
CN115001666A (en) * 2022-08-04 2022-09-02 湖北微模式科技发展有限公司 Image local encryption algorithm based on bit plane template XOR
WO2024109211A1 (en) * 2022-11-23 2024-05-30 中兴通讯股份有限公司 Data processing method and system, electronic device, and computer readable storage medium
CN115834791A (en) * 2023-02-03 2023-03-21 徐工汉云技术股份有限公司 Image encryption and decryption transmission method using matrix key and electronic equipment

Also Published As

Publication number Publication date
CN112040086B (en) 2023-06-06

Similar Documents

Publication Publication Date Title
CN112040086B (en) Image encryption and decryption methods and devices, equipment and readable storage medium
CN107103631B (en) Encrypted domain reversible information hidden method based on classification scramble and hiding information classification
CN107809644B (en) A kind of encryption area image reversible data concealing method of double-encryption
Abdel-Nabi et al. Medical imaging security using partial encryption and histogram shifting watermarking
Bhautmage et al. Advanced video steganography algorithm
CN112035847B (en) Image encryption and decryption methods and devices, electronic equipment and storage medium
AthishMon et al. Combined cryptography and digital watermarking for secure transmission of medical images in EHR systems
CN115001666A (en) Image local encryption algorithm based on bit plane template XOR
Rao et al. A novel information security scheme using cryptic steganography
CN113206926B (en) Method for balancing privacy and usability of image based on three-pixel-point encryption
QASSIM et al. Information Security with Image through Reversible Room by using Advanced Encryption Standard and Least Significant Bit Algorithm
Anumol et al. Enhanced security in medical image steganography-a hybrid approach using spatial and transform domain
CN107590369B (en) Homomorphic encrypted domain reversible information hiding method based on code division multiplexing and value expansion
Bandyopadhyay et al. A method for public key method of steganography
Audhi et al. Secure mechanism for communication using image steganography
Yadav et al. A hybrid approach to metamorphic cryptography using KIMLA and DNA concept
Babu et al. A reversible crypto-watermarking system for secure medical image transmission
Choudhary et al. Key based image steganography using Dwt and chaotic map
Phapale et al. Image Based Steganography Using Cryptography
Vigil et al. Secure binary image steganography using F5 algorithm based on data hiding and diffusion techniques
Blackledge et al. Application of stochastic diffusion for hiding high fidelity encrypted images
Faluyi et al. Secured Online Transcript Issuing and Processing Using Crypto-Steganography Technique
Bala et al. Security enhancement using a modified AES algorithm
Elmaghraby Watermarking 3D-Models
Revathi Security And Preservation For Video Data Transmission Using Blockchain Technology For Cloud Storage On Internet Of Things (Iot)

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