CN111651775A - Image encryption and decryption method and device, electronic equipment and storage medium - Google Patents

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

Info

Publication number
CN111651775A
CN111651775A CN202010356164.3A CN202010356164A CN111651775A CN 111651775 A CN111651775 A CN 111651775A CN 202010356164 A CN202010356164 A CN 202010356164A CN 111651775 A CN111651775 A CN 111651775A
Authority
CN
China
Prior art keywords
channel data
image
data
channel
key
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.)
Pending
Application number
CN202010356164.3A
Other languages
Chinese (zh)
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.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology 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 Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN202010356164.3A priority Critical patent/CN111651775A/en
Publication of CN111651775A publication Critical patent/CN111651775A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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

Abstract

The invention relates to an image encryption and decryption method, device, electronic equipment and storage medium, wherein the image encryption method comprises the following steps: the method comprises the steps of carrying out image channel separation on image data of an original image to obtain three channel data, encrypting first channel data and/or second channel data in the three channel data by using a preset secret key, storing the preset secret key in third channel data, and carrying out image channel combination on the first channel data, the second channel data and the third channel data after preset secret key storage and channel data encryption are completed to obtain an encrypted image. The embodiment of the invention can store the preset secret key into the encrypted image, thereby avoiding the preset secret key from being transmitted independently, further avoiding the preset secret key from being leaked in the independent transmission process, avoiding the condition that once one secret key is leaked, the image contents of other subsequent encrypted images can be easily cracked, avoiding the image contents of the original image from being leaked, and ensuring the safety of the original image.

Description

Image encryption and decryption method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to an image encryption method and apparatus, an image decryption method and apparatus, an electronic device, and a storage medium.
Background
The application of images in daily life is very wide, along with the development of computer technology, the digital era comes, the safety problem of image content comes with the image, and as the image carries more and more important information, such as scientific research information, crime evidence information, personal sensitive information and the like; moreover, for copyright protection reasons, some images which are not disclosed for the time exist in a confidential mode, and once the image information is leaked, the related personnel can be troubled.
However, when image content needing to be kept secret is transmitted, a sender encrypts an original image by using a key and separately informs a receiver of the key in other ways, and in order to reduce the communication frequency with the receiver, a plurality of original images may use the same key, so that the receiver can decrypt the received encrypted image by using the key after receiving the encrypted image to obtain the original image.
Disclosure of Invention
In order to solve the technical problems or at least partially solve the technical problems, the application provides an image encryption and decryption method, an image encryption and decryption device, an electronic device and a storage medium.
In a first aspect, the present application provides an image encryption method, applied to a sender, the method including:
carrying out image channel separation on image data of an original image to obtain three channel data;
encrypting first channel data and/or second channel data in the three channel data by using a preset key;
storing the preset key in third channel data;
and after the preset key storage and the channel data encryption are finished, carrying out image channel combination on the first channel data, the second channel data and the third channel data to obtain an encrypted image.
Optionally, the step of storing the preset key in the third channel data includes:
performing two-dimensional frequency domain transformation on the third channel data to obtain frequency domain data;
storing the preset key into the frequency domain data to obtain key frequency domain data;
and performing two-dimensional frequency domain inverse transformation on the key frequency domain data to obtain third channel data in which the preset key is stored.
Optionally, the step of storing the preset key in the frequency domain data to obtain key frequency domain data includes:
determining the position of a preset key to be stored in the frequency domain data;
modifying the original data at the position by using the preset key;
and determining the data which is not modified into the preset key and the data which is modified into the preset key in the frequency domain data as key frequency domain data.
In a second aspect, the present application provides an image decryption method, which is applied to a receiving party, and the method includes:
carrying out image channel separation on image data of the encrypted image to obtain first channel data, second channel data and third channel data;
extracting a preset key from the third channel data;
decrypting the first channel data and/or the second channel data by using the preset key;
and after the preset key extraction and the channel data decryption are finished, carrying out image channel combination on the first channel data, the second channel data and the third channel data to obtain a decrypted image.
Optionally, the step of extracting a preset key from the third channel data includes:
performing two-dimensional frequency domain transformation on the third channel data to obtain key frequency domain data;
and extracting the preset key from the key frequency domain data.
Optionally, the step of extracting the preset key from the key frequency domain data to obtain frequency domain data includes:
determining the position of a stored preset key in the key frequency domain data;
a pre-set key is extracted at the location.
In a third aspect, the present application provides an image encryption apparatus applied to a sender, the apparatus comprising:
the first channel separation module is used for carrying out image channel separation on the image data of the original image to obtain three channel data;
the encryption module is used for encrypting first channel data and/or second channel data in the three channel data by using a preset key;
the storage module is used for storing the preset key in third channel data;
and the first channel merging module is used for carrying out image channel merging on the first channel data, the second channel data and the third channel data after finishing the storage of the preset key and the encryption of the channel data so as to obtain an encrypted image.
Optionally, the storage module comprises:
the first transformation submodule is used for carrying out two-dimensional frequency domain transformation on the third channel data to obtain frequency domain data;
the first storage submodule is used for storing the preset secret key into the frequency domain data to obtain secret key frequency domain data;
and the inverse transformation submodule is used for performing two-dimensional frequency domain inverse transformation on the key frequency domain data to obtain third channel data in which the preset key is stored.
Optionally, the first storage submodule includes:
a first determining unit, configured to determine, in the frequency domain data, a position where a preset key is to be stored;
a modification unit for modifying the original data at the location using the preset key;
and a second determining unit, configured to determine, as key frequency domain data, data that has not been modified to a preset key and data that has been modified to the preset key in the frequency domain data.
In a fourth aspect, the present application provides an image decryption apparatus, which is applied to a receiving side, the apparatus comprising:
the second channel separation module is used for carrying out image channel separation on the image data of the encrypted image to obtain first channel data, second channel data and third channel data;
the extraction module is used for extracting a preset key from the third channel data;
the decryption module is used for decrypting the first channel data and/or the second channel data by using the preset key to obtain first channel data;
and the second channel merging module is used for carrying out image channel merging on the first channel data, the second channel data and the third channel data after finishing preset key extraction and channel data decryption to obtain a decrypted image.
Optionally, the extraction module comprises:
the second transformation submodule is used for carrying out two-dimensional frequency domain transformation on the third channel data to obtain key frequency domain data;
and the extraction submodule is used for extracting the preset key from the key frequency domain data.
Optionally, the extracting sub-module includes:
a third determining unit configured to determine a location where a preset key has been stored in the key frequency domain data;
an extraction unit for extracting a preset key at the location.
In a fifth aspect, the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor, configured to implement the image encryption method according to the first aspect or the image decryption method according to the second aspect when executing the program stored in the memory.
In a sixth aspect, the present application provides a computer-readable storage medium having stored thereon a program of an image encryption method or a program of an image decryption method, the program of the image encryption method realizing the image encryption method of the first aspect or realizing the steps of the image decryption method of the second aspect when executed by a processor.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages:
the method comprises the steps of carrying out image channel separation on image data of an original image to obtain three channel data, encrypting first channel data and/or second channel data in the three channel data by using a preset secret key, storing the preset secret key in third channel data, and carrying out image channel combination on the first channel data, the second channel data and the third channel data after preset secret key storage and channel data encryption are completed to obtain an encrypted image.
The embodiment of the invention can store the preset secret key into the third channel data, namely, the preset secret key into the encrypted image, so that the preset secret key is prevented from being transmitted independently, and further the preset secret key is prevented from being leaked in the independent transmission process; moreover, because the preset key is stored in the encrypted image, different keys can be set for different original images respectively, so that the situation that once one key is leaked, the image contents of other subsequent encrypted images can be easily cracked can be avoided, the image contents of the original images are prevented from being leaked, and the safety of the original images is ensured.
The embodiment of the invention obtains first channel data, second channel data and third channel data by carrying out image channel separation on image data of an encrypted image, extracts a preset secret key in the third channel data, decrypts the first channel data and/or the second channel data by using the preset secret key, and carries out image channel combination on the first channel data, the second channel data and the third channel data after finishing the extraction of the preset secret key and the decryption of the channel data to obtain a decrypted image.
The embodiment of the invention can extract the preset secret key from the encrypted image, so that the preset secret key is prevented from being transmitted independently, and further the preset secret key is prevented from being leaked in the independent transmission process; moreover, because the preset key is stored in the encrypted image, different keys can be set for different original images respectively, so that the situation that once one key is leaked, the image contents of other subsequent encrypted images can be easily cracked can be avoided, the image contents of the original images are prevented from being leaked, and the safety of the original images is ensured.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a flowchart of an image encryption method according to an embodiment of the present application;
FIG. 2 is a flowchart of step S103 in FIG. 1;
FIG. 3 is a flowchart of step S202 in FIG. 2;
fig. 4 is a flowchart of an image decryption method according to an embodiment of the present application;
FIG. 5 is a flowchart of step S402 in FIG. 4;
FIG. 6 is a flowchart of step S502 in FIG. 5;
fig. 7 is a structural diagram of an image encryption apparatus according to an embodiment of the present application;
fig. 8 is a block diagram of an image decryption apparatus according to an embodiment of the present application;
fig. 9 is a block diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
When image content needing to be kept secret is transmitted at present, a sender encrypts an original image by using a secret key and independently informs a receiver of the secret key in other modes, and in order to reduce communication frequency with the receiver, a plurality of original images may use the same secret key, so that the receiver can decrypt the received encrypted image by using the secret key after receiving the encrypted image to obtain the original image. To this end, an embodiment of the present invention provides an image encryption method and decryption method, an apparatus, an electronic device, and a storage medium, where the image encryption method may be applied to a sender, and fig. 1 is an image encryption method provided in an embodiment of the present application, and the method may include the following steps:
s101, carrying out image channel separation on image data of an original image to obtain three channel data;
in the embodiment of the present invention, the original image may refer to an image in RGB format or an image in YUV format, and the image in RGB format includes three channels: r channel, G channel and B channel, the image of YUV format includes three channels: y-channel, U-channel, and V-channel, in practical applications, an original image may also refer to images of other formats, and images of other formats may also include other channels, and any particular value should be construed as merely exemplary, rather than limiting, in all of the examples shown and described herein, and thus other examples of example embodiments may have different values.
In this step, the image data of the original image includes channel data of three channels, so that the data of each channel included in the image data of the original image can be subjected to channel separation using some channel separation tools/functions to obtain three channel data.
Step S102, encrypting first channel data and/or second channel data in the three channel data by using a preset key;
in the embodiment of the present invention, the preset key may refer to a preset key for encrypting an original image, since a pixel value is generally 8 bits, the preset key may be exemplarily set to 127, and the like.
In this step, the first channel data and/or the second channel data encrypted by the preset key may be arbitrarily selected from the three channel data, and the first channel data and/or the second channel data are encrypted by using the preset key according to an encryption rule negotiated in advance with the receiving party, for example, the encryption rule may be that the first channel data and/or the second channel data are subjected to an xor operation with the preset key, a character string composed of the first channel data and/or the second channel data and the preset key is circularly moved by N bits, and the like, when the first channel data and the second channel data are simultaneously encrypted, the same or different preset keys may be used for encryption, which is only exemplified herein, in practical applications, the first channel data and/or the second channel data may be encrypted by using other encryption rules, the examples herein are not intended to limit the scope of the invention.
Step S103, storing the preset key in third channel data;
in this step, since the third channel data includes pixel values of a plurality of pixel points of the original image, the third channel data itself is a numerical value, and the preset key can be stored in the positions of some pixel points by modifying the original numerical value and the like.
And step S104, after the preset key storage and the channel data encryption are finished, carrying out image channel combination on the first channel data, the second channel data and the third channel data to obtain an encrypted image.
In this step, since the first channel data and/or the second channel data are/is encrypted by using the preset key and the preset key is stored in the third channel data, the first channel data, the second channel data and the third channel data may be subjected to image channel merging at this time to obtain an encrypted image. Because the pixel value of each pixel point is changed after the first channel data and/or the second channel data are encrypted by the preset key, the image channel combination is performed based on the first channel data, the second channel data and the third channel data, the obtained encrypted image is different from the original image necessarily, and the effect of keeping the image content of the original image secret is achieved.
The method comprises the steps of carrying out image channel separation on image data of an original image to obtain three channel data, encrypting first channel data and/or second channel data in the three channel data by using a preset secret key, storing the preset secret key in third channel data, and carrying out image channel combination on the first channel data, the second channel data and the third channel data after preset secret key storage and channel data encryption are completed to obtain an encrypted image.
The embodiment of the invention can store the preset secret key into the third channel data, namely, the preset secret key into the encrypted image, so that the preset secret key is prevented from being transmitted independently, and further the preset secret key is prevented from being leaked in the independent transmission process; moreover, because the preset key is stored in the encrypted image, different keys can be set for different original images respectively, so that the situation that once one key is leaked, the image contents of other subsequent encrypted images can be easily cracked can be avoided, the image contents of the original images are prevented from being leaked, and the safety of the original images is ensured.
In still another embodiment of the present invention, as shown in fig. 2, the step S103 may include the steps of:
step S201, performing two-dimensional frequency domain transformation on the third channel data to obtain frequency domain data;
in the embodiment of the present invention, the two-dimensional frequency domain Transform may refer to discrete cosine Transform (DCT for discrete cosine Transform) or discrete fourier Transform.
In this step, the third channel data may be used as an input parameter for two-dimensional frequency domain transformation, and frequency domain data may be obtained after the two-dimensional frequency domain transformation.
Step S202, storing the preset key into the frequency domain data to obtain key frequency domain data;
in this step, the preset key may be used to modify the pixel values of some pixels in the frequency domain data, or perform some specified operations with the pixel values of some pixels, for example: converting a key value of a preset key into a binary system to obtain a binary key value, inserting the binary key value into the first two columns of the frequency domain data, and if the kth bit of the binary key value is 1, setting the value of the 2 nd column of the kth row of the frequency domain data to be larger than the value of the 1 st column of the kth row; if the k bit of the binary key value is 0, the value of the 2 nd column in the k row is set to be smaller than the value of the 1 st column in the k row. Therefore, the preset key can be directly or indirectly stored in the frequency domain data to obtain the key frequency domain data.
And step S203, performing two-dimensional frequency domain inverse transformation on the key frequency domain data to obtain third channel data in which a preset key is stored.
In the embodiment of the present invention, the two-dimensional frequency domain inverse transform may refer to an inverse discrete cosine transform or an inverse discrete fourier transform, or the like.
In this step, the key frequency domain data may be used as an input parameter for the two-dimensional frequency domain inverse transformation, and after the two-dimensional frequency domain inverse transformation, the third channel data in which the preset key is stored may be obtained.
According to the embodiment of the invention, the third channel data is subjected to two-dimensional frequency domain transformation to obtain frequency domain data, the preset secret key is stored in the frequency domain data to obtain secret key frequency domain data, and finally the secret key frequency domain data can be subjected to two-dimensional frequency domain inverse transformation to obtain the third channel data stored with the preset secret key.
According to the embodiment of the invention, the preset key is stored in the frequency domain data, which is equivalent to the fact that the data of the preset key is scattered in the space domain, the correlation of pixel points is kept, the key is more difficult to find, the preset key is more difficult to obtain by an attacker, the safety of the preset key is ensured, and the safety of an encrypted image is further ensured.
In another embodiment of the present invention, as shown in fig. 3, the step S202 may include the following steps:
step S301, determining the position of a preset key to be stored in the frequency domain data;
in the embodiment of the present invention, a location for storing the preset key may be agreed with the receiver in advance, and the location is used as the location where the preset key is to be stored.
Step S302, using the preset key to modify the original data at the position;
in this step, the original data at the position may be directly modified according to the preset key, or the key value of the preset key may be indirectly stored by performing some specified operations on the pixel values of some pixels.
Step S303, determining data that is not modified to a preset key and data that is modified to the preset key in the frequency domain data as key frequency domain data.
In this step, since there are a location for not storing the preset key and a location for storing the preset key in the frequency domain data, after the original data is modified with the preset key, data that is not modified to the preset key and data that has been modified to the preset key in the frequency domain data may be determined as key frequency domain data.
According to the embodiment of the invention, the position of the preset key to be stored in the frequency domain data can be determined, then the original data at the position is modified by using the preset key, and finally the data which is not modified into the preset key and the data which is modified into the preset key in the frequency domain data can be determined as the key frequency domain data.
According to the embodiment of the invention, the preset key is stored in the frequency domain data at the appointed position, and the position for storing the preset key can be selected from the frequency domain data according to actual needs, so that the influence degree of the encryption mode on the original image is conveniently controlled, the influence on the image quality is reduced, and the user can conveniently watch the image.
Based on the foregoing embodiment, in another embodiment of the present invention, there is further provided an image decryption method applied to a receiving side, as shown in fig. 4, the method including:
step S401, performing image channel separation on image data of an encrypted image to obtain first channel data, second channel data and third channel data;
in this step, since the encrypted image is obtained by the sender merging the channel data of the multiple channels, image channel separation may be performed on the image data of the encrypted image using some channel separation tools/functions to obtain the first channel data, the second channel data, and the third channel data.
Step S402, extracting a preset key from the third channel data;
since the preset key is stored in the third channel data during encryption, the preset key can be extracted from the third channel data according to the convention with the sender, and the third channel data cannot be changed after the preset key is extracted.
Step S403, decrypting the first channel data and/or the second channel data by using the preset key;
in this step, the first channel data and/or the second channel data may be decrypted according to an inverse process of the method for encrypting the first channel data and/or the second channel data by using the preset key, so as to obtain the first channel data.
Step S404, after the preset key extraction and the channel data decryption are completed, image channel combination is carried out on the first channel data, the second channel data and the third channel data, and a decrypted image is obtained.
In this step, image channel merging may be performed on the first channel data, the second channel data, and the third channel data, which have completed the preset key extraction and the channel data decryption, in an image channel merging manner, so as to obtain a decrypted image.
The embodiment of the invention obtains first channel data, second channel data and third channel data by carrying out image channel separation on the image data of the encrypted image, extracts a preset secret key in the third channel data, decrypts the first channel data and/or the second channel data by using the preset secret key, and carries out image channel combination on the first channel data, the second channel data and the third channel data after finishing the extraction of the preset secret key and the decryption of the channel data to obtain a decrypted image.
The embodiment of the invention can extract the preset secret key from the encrypted image, so that the preset secret key is prevented from being transmitted independently, and further the preset secret key is prevented from being leaked in the independent transmission process; moreover, because the preset key is stored in the encrypted image, different keys can be set for different original images respectively, so that the situation that once one key is leaked, the image contents of other subsequent encrypted images can be easily cracked can be avoided, the image contents of the original images are prevented from being leaked, and the safety of the original images is ensured.
In still another embodiment of the present invention, as shown in fig. 5, the step S402 may include the steps of:
step S501, performing two-dimensional frequency domain transformation on the third channel data to obtain key frequency domain data;
in the embodiment of the present invention, the two-dimensional frequency domain Transform may refer to discrete cosine Transform (DCT for discrete cosine Transform) or discrete fourier Transform.
In this step, the third channel data may be used as an input parameter for two-dimensional frequency domain transformation, and after the two-dimensional frequency domain transformation, the key frequency domain data may be obtained.
Step S502, extracting the preset key from the key frequency domain data to obtain frequency domain data;
in this step, when the sender stores the preset key in the third channel data by modifying the data in the frequency domain data using the preset key, the receiver may directly extract the preset key from the key frequency domain data, and the key frequency domain data from which the preset key is extracted is used as the frequency domain data;
when the sender stores the preset key in the third channel data by performing some specified operations on the preset key and some pixel values, the receiver can extract the preset key from the key frequency domain data by using the inverse process of the operations.
The embodiment of the invention can automatically extract the preset key from the frequency domain data, namely extract the preset key from the spatial domain, so that the preset key is more difficult to be obtained by an attacker, the safety of the preset key is ensured, and the use by a user is facilitated on the basis of ensuring the safety of an encrypted image.
In another embodiment of the present invention, as shown in fig. 6, the step S502 may include the following steps:
step S601, determining the position of a stored preset key in the key frequency domain data;
in this embodiment of the present invention, the position for storing the preset key in the key frequency domain data may be agreed with the sender in advance, so in this step, the receiver may determine the position where the preset key is stored in the key frequency domain data according to the position in step S301.
Step S602, a preset key is extracted at the location.
According to the embodiment of the invention, the preset key is extracted from the designated position, so that the preset key is more difficult to be acquired by an attacker, the safety of the preset key is ensured, and convenience is brought to a user on the basis of ensuring the safety of the encrypted image.
In still another embodiment of the present invention, there is also provided an image encryption apparatus applied to a sender, as shown in fig. 7, the apparatus including:
the first channel separation module 11 is configured to perform image channel separation on image data of an original image to obtain three channel data;
the encryption module 12 is configured to encrypt first channel data and/or second channel data in the three channel data by using a preset key;
a storage module 13, configured to store the preset key in third channel data;
the first channel merging module 14 is configured to perform image channel merging on the first channel data, the second channel data, and the third channel data after completing the preset key storage and channel data encryption, so as to obtain an encrypted image.
In a further embodiment of the present invention, the storage module 13 comprises:
the first transformation submodule is used for carrying out two-dimensional frequency domain transformation on the third channel data to obtain frequency domain data;
the first storage submodule is used for storing the preset secret key into the frequency domain data to obtain secret key frequency domain data;
and the inverse transformation submodule is used for performing two-dimensional frequency domain inverse transformation on the key frequency domain data to obtain third channel data in which the preset key is stored.
In another embodiment of the present invention, the first storage submodule includes:
a first determining unit, configured to determine, in the frequency domain data, a position where a preset key is to be stored;
a modification unit for modifying the original data at the location using the preset key;
and a second determining unit, configured to determine, as key frequency domain data, data that has not been modified to a preset key and data that has been modified to the preset key in the frequency domain data.
In another embodiment of the present invention, there is also provided an image decryption apparatus applied to a receiving side, as shown in fig. 8, the apparatus including:
the second channel separation module 21 is configured to perform image channel separation on the image data of the encrypted image to obtain first channel data, second channel data, and third channel data;
an extracting module 22, configured to extract a preset key from the third channel data;
the decryption module 23 is configured to decrypt the first channel data and/or the second channel data by using the preset key to obtain first channel data;
and the second channel merging module 24 is configured to perform image channel merging on the first channel data, the second channel data, and the third channel data after completing preset key extraction and channel data decryption, so as to obtain a decrypted image.
In a further embodiment of the present invention, the extraction module 22 comprises:
the second transformation submodule is used for carrying out two-dimensional frequency domain transformation on the third channel data to obtain key frequency domain data;
and the extraction submodule is used for extracting the preset key from the key frequency domain data.
In another embodiment of the present invention, the extraction sub-module includes:
a third determining unit configured to determine a location where a preset key has been stored in the key frequency domain data;
an extraction unit for extracting a preset key at the location.
In another embodiment of the present invention, an electronic device is further provided, which includes a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
and a processor, configured to implement the image encryption method according to the foregoing method embodiment or the image decryption method according to the foregoing method embodiment when executing the program stored in the memory.
In the electronic device provided by the embodiment of the invention, the processor executes the program stored in the memory to realize image channel separation of the image data of the original image to obtain three channel data, encrypts the first channel data and/or the second channel data in the three channel data by using the preset key, stores the preset key in the third channel data, and after finishing the storage of the preset key and the encryption of the channel data, performs image channel combination on the first channel data, the second channel data and the third channel data to obtain the encrypted image, so that the preset key can be stored in the third channel data, namely the preset key is stored in the encrypted image, the preset key is prevented from being transmitted independently, and further the preset key is prevented from being leaked in the independent transmission process; moreover, because the preset key is stored in the encrypted image, different keys can be set for different original images respectively, so that the situation that once one key is leaked, the image contents of other subsequent encrypted images can be easily cracked can be avoided, the image contents of the original images are prevented from being leaked, and the safety of the original images is ensured.
Or, in the electronic device provided in the embodiment of the present invention, the processor implements image channel separation on image data of an encrypted image by executing a program stored in the memory, to obtain first channel data, second channel data, and third channel data, extracts a preset key from the third channel data, decrypts the first channel data and/or the second channel data using the preset key, and performs image channel merging on the first channel data, the second channel data, and the third channel data after completing the preset key extraction and the channel data decryption, to obtain a decrypted image. The preset key can be extracted from the encrypted image, so that the preset key is prevented from being transmitted independently, and further the preset key is prevented from being leaked in the independent transmission process; moreover, because the preset key is stored in the encrypted image, different keys can be set for different original images respectively, so that the situation that once one key is leaked, the image contents of other subsequent encrypted images can be easily cracked can be avoided, the image contents of the original images are prevented from being leaked, and the safety of the original images is ensured.
The communication bus 1140 mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus 1140 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 9, but this does not indicate only one bus or one type of bus.
The communication interface 1120 is used for communication between the electronic device and other devices.
The memory 1130 may include a Random Access Memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The processor 1110 may be a general-purpose processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the integrated circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, or discrete hardware components.
In still another embodiment of the present invention, there is also provided a computer-readable storage medium having stored thereon a program of an image encryption method or a program of an image decryption method, the program of the image encryption method realizing the image encryption method described in the aforementioned method embodiment or the steps of realizing the image decryption method described in the aforementioned method embodiment when executed by a processor.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present invention, which enable those skilled in the art to understand or practice the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. An image encryption method applied to a sender, the method comprising:
carrying out image channel separation on image data of an original image to obtain three channel data;
encrypting first channel data and/or second channel data in the three channel data by using a preset key;
storing the preset key in third channel data;
and after the preset key storage and the channel data encryption are finished, carrying out image channel combination on the first channel data, the second channel data and the third channel data to obtain an encrypted image.
2. The image encryption method according to claim 1, wherein the step of storing the preset key in the third channel data includes:
performing two-dimensional frequency domain transformation on the third channel data to obtain frequency domain data;
storing the preset key into the frequency domain data to obtain key frequency domain data;
and performing two-dimensional frequency domain inverse transformation on the key frequency domain data to obtain third channel data in which the preset key is stored.
3. The image encryption method according to claim 2, wherein the step of storing the preset key in the frequency domain data to obtain key frequency domain data comprises:
determining the position of a preset key to be stored in the frequency domain data;
modifying the original data at the position by using the preset key;
and determining the data which is not modified into the preset key and the data which is modified into the preset key in the frequency domain data as key frequency domain data.
4. An image decryption method, applied to a receiving side, the method comprising:
carrying out image channel separation on image data of the encrypted image to obtain first channel data, second channel data and third channel data;
extracting a preset key from the third channel data;
decrypting the first channel data and/or the second channel data by using the preset key;
and after the preset key extraction and the channel data decryption are finished, carrying out image channel combination on the first channel data, the second channel data and the third channel data to obtain a decrypted image.
5. The image decryption method according to claim 4, wherein the step of extracting the preset key in the third channel data comprises:
performing two-dimensional frequency domain transformation on the third channel data to obtain key frequency domain data;
and extracting the preset key from the key frequency domain data.
6. The image decryption method according to claim 5, wherein the step of extracting the preset key from the key frequency domain data comprises:
determining the position of a stored preset key in the key frequency domain data;
a pre-set key is extracted at the location.
7. An image encryption apparatus applied to a transmission side, the apparatus comprising:
the first channel separation module is used for carrying out image channel separation on the image data of the original image to obtain three channel data;
the encryption module is used for encrypting first channel data and/or second channel data in the three channel data by using a preset key;
the storage module is used for storing the preset key in third channel data;
and the first channel merging module is used for carrying out image channel merging on the first channel data, the second channel data and the third channel data after finishing the storage of the preset key and the encryption of the channel data so as to obtain an encrypted image.
8. An image decryption apparatus, applied to a receiving side, the apparatus comprising:
the second channel separation module is used for carrying out image channel separation on the image data of the encrypted image to obtain first channel data, second channel data and third channel data;
the extraction module is used for extracting a preset key from the third channel data;
the decryption module is used for decrypting the first channel data and/or the second channel data by using the preset key to obtain first channel data;
and the second channel merging module is used for carrying out image channel merging on the first channel data, the second channel data and the third channel data after finishing preset key extraction and channel data decryption to obtain a decrypted image.
9. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the image encryption method according to any one of claims 1 to 3 or the image decryption method according to any one of claims 4 to 6 when executing a program stored in a memory.
10. A computer-readable storage medium having stored thereon a program for an image encryption method or a program for an image decryption method, the program for the image encryption method implementing the image encryption method of any one of claims 1 to 3 or the steps of implementing the image decryption method of any one of claims 4 to 6 when executed by a processor.
CN202010356164.3A 2020-04-29 2020-04-29 Image encryption and decryption method and device, electronic equipment and storage medium Pending CN111651775A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010356164.3A CN111651775A (en) 2020-04-29 2020-04-29 Image encryption and decryption method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010356164.3A CN111651775A (en) 2020-04-29 2020-04-29 Image encryption and decryption method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111651775A true CN111651775A (en) 2020-09-11

Family

ID=72348149

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010356164.3A Pending CN111651775A (en) 2020-04-29 2020-04-29 Image encryption and decryption method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111651775A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114513305A (en) * 2022-04-18 2022-05-17 南昌工学院 Art painting image processing method and device
WO2023142440A1 (en) * 2022-01-28 2023-08-03 中国银联股份有限公司 Image encryption method and apparatus, image processing method and apparatus, and device and medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100169649A1 (en) * 2008-12-31 2010-07-01 Pitney Bowes Inc. Image encryption for print-and-scan channels using pixel position permutation
CN104809685A (en) * 2015-05-13 2015-07-29 哈尔滨工程大学 Color image one-time-key DNA (Deoxyribonucleic Acid) encryption method based on six-dimensional chaotic system
CN107734208A (en) * 2017-10-11 2018-02-23 中共中央办公厅电子科技学院 A kind of coloured image encipher-decipher method based on HSV space
CN108600196A (en) * 2018-04-04 2018-09-28 广东中星电子有限公司 The encryption method and device and decryption method and device of image
CN111031322A (en) * 2019-10-24 2020-04-17 五邑大学 BMP image encryption and decryption method and device of self-synchronizing chaotic stream cipher

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100169649A1 (en) * 2008-12-31 2010-07-01 Pitney Bowes Inc. Image encryption for print-and-scan channels using pixel position permutation
CN104809685A (en) * 2015-05-13 2015-07-29 哈尔滨工程大学 Color image one-time-key DNA (Deoxyribonucleic Acid) encryption method based on six-dimensional chaotic system
CN107734208A (en) * 2017-10-11 2018-02-23 中共中央办公厅电子科技学院 A kind of coloured image encipher-decipher method based on HSV space
CN108600196A (en) * 2018-04-04 2018-09-28 广东中星电子有限公司 The encryption method and device and decryption method and device of image
CN111031322A (en) * 2019-10-24 2020-04-17 五邑大学 BMP image encryption and decryption method and device of self-synchronizing chaotic stream cipher

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023142440A1 (en) * 2022-01-28 2023-08-03 中国银联股份有限公司 Image encryption method and apparatus, image processing method and apparatus, and device and medium
CN114513305A (en) * 2022-04-18 2022-05-17 南昌工学院 Art painting image processing method and device

Similar Documents

Publication Publication Date Title
Kumar et al. A first approach on an RGB image encryption
CN109102452B (en) Image encryption method based on Latin square array scrambling and bidirectional diffusion
CN102164034A (en) Device and method for establishing secure trust key
CN110505054B (en) Data processing method, device and equipment based on dynamic white box
CN111651775A (en) Image encryption and decryption method and device, electronic equipment and storage medium
Sabir et al. Multi-layer color image encryption using random matrix affine cipher, RP2DFrHT and 2D Arnold map
CN112035847B (en) Image encryption and decryption methods and devices, electronic equipment and storage medium
CN107248972B (en) Data encryption and decryption method and device and electronic equipment
Mishra et al. Security of RGB image data by affine hill cipher over SLn (Fq) and Mn (Fq) domains with Arnold transform
El Abbadi et al. New image encryption algorithm based on Diffie-Hellman and singular value decomposition
CN110598421B (en) Two-dimensional code encryption method and device and two-dimensional code decryption method and device
KR102438102B1 (en) Apparatus, method, computer-readable storage medium and computer program for encrypting information using image steganography
CA2592703A1 (en) Communication system and communication method
CN114338241B (en) Data encryption and decryption method and device and network router adopting device
CN111131270B (en) Data encryption and decryption method and device, electronic equipment and storage medium
Tanya Bindu et al. A survey on various crypto-steganography techniques for real-time images
Ajmera et al. Video Steganography: Using Scrambling-AES Encryption and DCT, DST Steganography
Ghazy et al. Block based embedding of encrypted watermarks using singular value decomposition
KR20230139647A (en) System and method for encrypting and decrypting data
CN110516461B (en) Multichannel image encryption method and device, storage medium and electronic equipment
Sani et al. Construction of S-box based on chaotic piecewise map: Watermark application
Mishra et al. An approach for security of color image data in coordinate, geometric, and frequency domains
Chatterjee et al. Secret communication combining cryptography and steganography
US10997317B2 (en) Method for safeguarding the confidentiality of the sender's identification of messages transmitted through promiscuous channels
CN109831596B (en) Image encryption method and device and electronic equipment

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