CN117714614A - Image encryption method, image decryption method, electronic device, and storage medium - Google Patents
Image encryption method, image decryption method, electronic device, and storage medium Download PDFInfo
- Publication number
- CN117714614A CN117714614A CN202311695661.6A CN202311695661A CN117714614A CN 117714614 A CN117714614 A CN 117714614A CN 202311695661 A CN202311695661 A CN 202311695661A CN 117714614 A CN117714614 A CN 117714614A
- Authority
- CN
- China
- Prior art keywords
- image
- component
- area
- information
- target
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 83
- 230000000739 chaotic effect Effects 0.000 claims abstract description 132
- 238000004590 computer program Methods 0.000 claims description 16
- 230000005540 biological transmission Effects 0.000 abstract description 6
- 238000010586 diagram Methods 0.000 description 13
- 238000004891 communication Methods 0.000 description 8
- 238000005336 cracking Methods 0.000 description 8
- 230000006870 function Effects 0.000 description 7
- 238000012545 processing Methods 0.000 description 7
- 230000008569 process Effects 0.000 description 6
- 238000006243 chemical reaction Methods 0.000 description 5
- 238000013461 design Methods 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 2
- 238000003780 insertion Methods 0.000 description 2
- 230000037431 insertion Effects 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000000007 visual effect Effects 0.000 description 2
- 241000023320 Luma <angiosperm> Species 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 239000000969 carrier Substances 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 239000011521 glass Substances 0.000 description 1
- 238000003064 k means clustering Methods 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000010801 machine learning Methods 0.000 description 1
- OSWPMRLSEDHDFF-UHFFFAOYSA-N methyl salicylate Chemical compound COC(=O)C1=CC=CC=C1O OSWPMRLSEDHDFF-UHFFFAOYSA-N 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000001953 sensory effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N1/00—Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
- H04N1/44—Secrecy systems
- H04N1/448—Rendering the image unintelligible, e.g. scrambling
- H04N1/4486—Rendering the image unintelligible, e.g. scrambling using digital data encryption
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/23—Clustering techniques
- G06F18/232—Non-hierarchical techniques
- G06F18/2321—Non-hierarchical techniques using statistics or function optimisation, e.g. modelling of probability density functions
- G06F18/23213—Non-hierarchical techniques using statistics or function optimisation, e.g. modelling of probability density functions with fixed number of clusters, e.g. K-means clustering
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/001—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using chaotic signals
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N1/00—Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
- H04N1/46—Colour picture communication systems
- H04N1/56—Processing of colour picture signals
Landscapes
- Engineering & Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Signal Processing (AREA)
- Physics & Mathematics (AREA)
- Multimedia (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Bioinformatics & Computational Biology (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Evolutionary Biology (AREA)
- Evolutionary Computation (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Artificial Intelligence (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Life Sciences & Earth Sciences (AREA)
- Probability & Statistics with Applications (AREA)
- Storage Device Security (AREA)
Abstract
The invention discloses an image encryption method, an image decryption method, an electronic device and a storage medium. The method relates to the technical field of information security, and comprises the following steps: acquiring an image to be encrypted and associated information; determining at least one target clustering area according to a first component of the image to be encrypted; encrypting each target clustering area, the second component of the image to be encrypted and the third component of the image to be encrypted respectively to obtain an intermediate image; inserting an information area into the intermediate image, and writing encryption information into the information area to obtain an encrypted target image, wherein the position of the information area is determined according to the size of the intermediate image and the associated information, and the encryption information comprises the number information of target clustering areas, chaotic encryption keys of each target clustering area, the position information of each target clustering area, the chaotic encryption keys of the second component of the image to be encrypted and the chaotic encryption keys of the third component of the image to be encrypted. The scheme can improve the safety of image storage and transmission and avoid information leakage.
Description
Technical Field
The present invention relates to the field of information security technologies, and in particular, to an image encryption method, an image decryption method, an electronic device, and a storage medium.
Background
With the rapid development of network technology and multimedia technology, digital images have become one of the most important information carriers. For example, in the financial field, the digital image may be as customer identity information and transaction image information. Since the digital image contains personal confidential information of a user or an enterprise, it is necessary to secure the storage and use of the digital image.
Currently, digital images are generally encrypted using chaotic encryption algorithms. However, the existing chaotic encryption algorithm has a simple encryption structure and weak external impact resistance, and once a key is leaked, the security of a digital image is difficult to ensure.
Disclosure of Invention
The invention provides an image encryption method, an image decryption method, electronic equipment and a storage medium, which can improve the safety of image storage and transmission and avoid information leakage.
According to an aspect of the present invention, there is provided an image encryption method including: acquiring an image to be encrypted and associated information, wherein the image to be encrypted is an image in YUV format; determining at least one target clustering area according to a first component of an image to be encrypted, wherein the first component is any one of a Y component, a U component and a V component; encrypting each target clustering region, a second component of the image to be encrypted and a third component of the image to be encrypted respectively to obtain an intermediate image, wherein the second component and the third component are two other components except the first component in the Y component, the U component and the V component; inserting an information area into the intermediate image, and writing encryption information into the information area to obtain an encrypted target image, wherein the position of the information area is determined according to the size of the intermediate image and the associated information, and the encryption information comprises the number information of target clustering areas, the chaotic encryption key of each target clustering area, the position information of each target clustering area, the chaotic encryption key of the second component of the image to be encrypted and the chaotic encryption key of the third component of the image to be encrypted.
Optionally, acquiring the image to be encrypted and the associated information includes: receiving an original image, shooting time of the original image and shooting equipment identification ID sent by shooting equipment, wherein the original image is an image in an RGB format; the original image is converted into an image to be encrypted, and the photographing time and the photographing apparatus ID of the original image are used as associated information.
Optionally, determining at least one target cluster area according to the first component of the image to be encrypted includes: clustering the first components of the image to be encrypted to obtain a plurality of candidate clustering areas; determining a deformation clustering area corresponding to each candidate clustering area according to the horizontal maximum length and the vertical maximum length of each candidate clustering area, wherein the deformation clustering area is the minimum circumscribed rectangular area of the candidate clustering area corresponding to the deformation clustering area; and for at least two deformation clustering areas with overlapping areas, respectively determining the duty ratio of the overlapping areas in each deformation clustering area, and taking the deformation clustering area with the largest duty ratio as a target clustering area.
Optionally, for any one target clustering area, encrypting the target clustering area includes: randomly generating a first chaotic system parameter and a first chaotic system initial value corresponding to a target clustering area; generating a first chaotic encryption sequence corresponding to the target clustering region according to the first chaotic system parameter and the first chaotic system initial value; encrypting the target clustering region by using a first chaotic encryption sequence;
Encrypting the second component of the image to be encrypted and the third component of the image to be encrypted comprises: randomly generating a second chaotic system parameter and a second chaotic system initial value; generating a second chaotic encryption sequence according to the second chaotic system parameter and the second chaotic system initial value; and respectively encrypting the second component of the image to be encrypted and the third component of the image to be encrypted by using the second chaotic encryption sequence.
Optionally, inserting an information area on the intermediate image includes: determining a reference position according to the size of the intermediate image and the associated information; and inserting an information area on the intermediate image according to the reference position, wherein the information area is a row of pixel points which comprise the reference position and have the same length as the intermediate image, or the information area is a column of pixel points which comprise the reference position and have the same width as the intermediate image.
Optionally, one target cluster area has a sequence number, and the sequence number of the target cluster area is determined according to the upper left corner coordinate and the lower right corner coordinate of the target cluster area.
Writing encrypted information in the information area, comprising: dividing an information area into an effective information area and an ineffective information area, wherein the effective information area comprises a plurality of continuous pixel points taking a pixel point where a reference position is located as a starting point, and the ineffective information area comprises all other pixel points except the effective information area in the information area; encryption information is written in the effective information area, and a first component, a second component, and a third component of each pixel point in the ineffective information area are set randomly.
Optionally, the effective information area includes 1 first pixel point, 2n second pixel points and 1 third pixel point which are sequentially and continuously arranged, and n is the number information of the target cluster area.
Writing encrypted information in the effective information area, comprising: setting a first component of the first pixel point as the number information of the target clustering area, and randomly setting a second component and a third component of the first pixel point; for a target clustering area with a sequence number of i, setting a first component of a (2 i-1) th second pixel point as a first chaotic system parameter corresponding to the target clustering area, setting a second component and a third component of the (2 i-1) th second pixel point as an upper left corner abscissa and an upper left corner ordinate of the target clustering area respectively, setting the first component of the 2i th second pixel point as a first chaotic system initial value corresponding to the target clustering area, and setting the second component and the third component of the 2i th second pixel point as a lower right corner abscissa and a lower right corner ordinate of the target clustering area respectively; and setting the second component and the third component of the third pixel point as the second chaotic system parameter and the second chaotic system initial value respectively, and randomly setting the first component of the third pixel point.
According to another aspect of the present invention, there is provided an image decryption method including: acquiring an image to be decrypted and associated information, and determining the position of an information area according to the size of the image to be decrypted and the associated information; reading decryption information stored in the information area according to the position of the information area, and deleting the information area from the image to be decrypted to obtain an intermediate image, wherein the decryption information comprises the number information of target clustering areas, a chaotic decryption key of each target clustering area, position information of each target clustering area, a chaotic decryption key of a second component of the intermediate image and a chaotic decryption key of a third component of the intermediate image, the target clustering area corresponds to a first component of the intermediate image, the first component is any one component of a Y component, a U component and a V component, and the second component and the third component are other two components except the first component; and respectively decrypting the second component of each target clustering area, the second component of the intermediate image and the third component of the intermediate image according to the decryption information to obtain a decrypted target image, wherein the decrypted target image is an image in YUV format.
According to another aspect of the present invention, there is provided an electronic apparatus including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the method described in any one of the embodiments of the invention.
According to another aspect of the invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to perform the method described in any one of the embodiments of the invention.
The technical scheme of the embodiment of the invention designs a novel image encryption and decryption method. For an image encryption method, at least one target clustering area is determined by acquiring an image to be encrypted and associated information and according to a first component of the image to be encrypted; encrypting each target clustering area, the second component of the image to be encrypted and the third component of the image to be encrypted respectively to obtain an intermediate image; and finally, inserting an information area into the intermediate image, and writing encryption information into the information area to obtain the encrypted target image. On one hand, because the encryption is respectively carried out aiming at different target clustering areas, the relevance of each characteristic of the first component in the image is reduced, and the cracking difficulty is improved; on the other hand, the second component and the third component in the image are encrypted as a whole, and the encryption complexity of the whole image is balanced; in addition, the storage position of the encryption information is determined according to the size of the intermediate image and the associated information, so that the randomness of the storage position is realized, the cracking difficulty is further improved, the purposes of improving the safety of image storage and transmission are realized, and information leakage is avoided.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of an image encryption method according to a first embodiment of the present invention;
FIG. 2 is a schematic diagram of determining a deformed cluster region corresponding to a candidate cluster region according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a further determination of a target cluster region based on the deformed cluster region shown in FIG. 2 according to an embodiment of the present invention;
FIG. 4 is a schematic diagram showing an embodiment of the present invention for inserting an information area on an intermediate image and writing encrypted information in the information area;
Fig. 5 is a flowchart of an image decryption method according to a second embodiment of the present invention;
fig. 6 is a schematic structural diagram of an image encryption device according to a third embodiment of the present invention;
fig. 7 is a schematic structural diagram of an image decryption device according to a fourth embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," "third," "original," "target," "candidate," and the like in the description and claims of the present invention and in the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be noted that the steps of image acquisition, storage, use, processing and the like in the invention all conform to relevant regulations of national laws and regulations.
Example 1
Fig. 1 is a schematic flow chart of an image encryption method according to an embodiment of the present invention, where the method may be applied to the case of encrypting an image, and the method may be performed by an image encryption device, which may be implemented in hardware and/or software, and the image encryption device may be configured in an electronic device (such as a computer or a server). The electronic device provided by the invention can have both the image encryption function and the image decryption function, namely, the electronic device can realize the image encryption method of the first embodiment and the image decryption method of the second embodiment. As shown in fig. 1, the method includes:
s110, acquiring an image to be encrypted and associated information, wherein the image to be encrypted is a YUV format image.
The image to be encrypted is any image in YUV format which needs to be encrypted. The associated information is information related to the image to be encrypted, such as attribute information of the image to be encrypted.
In an embodiment, the method of "acquiring the image to be encrypted and the associated information" in step S110 may include the following two steps.
Step a1: and receiving an original image, shooting time of the original image and shooting equipment Identification (ID) sent by a shooting equipment, wherein the original image is an image in an RGB format.
The photographing apparatus may be any apparatus having a photographing function, such as a video camera, a still camera, a video recorder, and the like. The photographing apparatus photographs an original image, and transmits the original image, a photographing time of the original image, and a photographing apparatus ID to the image encryption device.
The shooting time of the original image can be accurate to year, month and day, or accurate to time-division second. The shooting device ID is an ID obtained by numbering a plurality of shooting devices in turn, and in order to ensure that subsequent images can be decrypted smoothly, all electronic devices in one system are consistent in numbering to the same shooting device, i.e., one shooting device has a unique and unified shooting device ID.
Step a2: the original image is converted into an image to be encrypted, and the photographing time and the photographing apparatus ID of the original image are used as associated information.
Since the original image is an RGB format image, format conversion is performed on the original image to obtain an image to be encrypted in YUV format, and the shooting time and the shooting device ID of the original image are used as associated information.
An RGB format image refers to an image in which each pixel is made up of R, G, B components, with R, G, B being described by different gray levels. Whereas the YUV format image uses brightness and chromaticity to represent the color of each pixel, where the Y component represents brightness (Luminance, luma), i.e., gray scale value, the U component, the V component represents chromaticity (Chroma or Chroma), describing hue and saturation.
In one embodiment, the conversion relationship between the original image and the image to be encrypted is:
Y=0.299*R+0587*G+0.114*B;
U=0564*(B-Y);
V=0.713*(R-Y)。
for example, assuming that the original image is an RGB image a, the photographing time of the RGB image a is 2023, 5, 10, 14, 35 minutes, 20 seconds, and the photographing apparatus ID is 10305. After conversion, the obtained image to be encrypted is a YUV image B, and the associated information is 2023, 5, 10, 14 minutes, 20 seconds (i.e. the shooting time of the RGB image A) and 10305 (i.e. the shooting device ID).
S120, determining at least one target clustering area according to a first component of the image to be encrypted, wherein the first component is any one of a Y component, a U component and a V component.
In the invention, the first component is any one of the Y component, the U component and the V component, and the second component and the third component are other two components except the first component. For example, the first component is a Y component, the second component is a U component, and the third component is a V component; or the first component is a U component, the second component is a Y component, and the third component is a V component; alternatively, the first component is a V component, the second component is a U component, and the third component is a Y component.
Preferably, since the human visual system is more sensitive to luminance than color, the first component is typically the Y component, the second component is the U component, and the third component is the V component, taking into account the characteristics of the YUV format.
In an embodiment, the method of determining at least one target cluster region according to the first component of the image to be encrypted in step S120 may include the following three steps.
Step b1: clustering the first components of the image to be encrypted to obtain a plurality of candidate clustering areas.
Clustering refers to the process of dividing a collection of physical or abstract objects into multiple classes made up of similar objects. In the invention, a K-means clustering algorithm (K-means clusteringalgorithm, KMA) can be adopted to cluster the first component of the image to be encrypted, so as to obtain a plurality of candidate cluster areas.
Step b2: and determining a deformation clustering area corresponding to each candidate clustering area according to the horizontal maximum length and the vertical maximum length of each candidate clustering area, wherein the deformation clustering area is the minimum circumscribed rectangular area of the candidate clustering area corresponding to the deformation clustering area.
In step b2, for each candidate cluster region, a corresponding deformed cluster region needs to be determined. Taking a candidate clustering area as an example, the method for specifically determining the deformation clustering area comprises the following steps: determining the horizontal maximum length and the vertical maximum length of the candidate clustering region, wherein the horizontal maximum length and the vertical maximum length can be understood as the x-axis maximum length and the y-axis maximum length of a two-dimensional coordinate system where the image to be encrypted is positioned; and expanding the candidate cluster region into a deformed cluster region according to the horizontal maximum length and the vertical maximum length of the candidate cluster region. The deformation clustering region is the minimum circumscribed rectangular region of the candidate clustering region corresponding to the deformation clustering region, and the length and the width of the deformation clustering region are the horizontal maximum length and the vertical maximum length of the candidate clustering region respectively.
Therefore, the candidate clustering area is expanded into the deformation clustering area, the shape of the clustering area can be standardized, and the position of the clustering area can be conveniently recorded.
Step b3: and for at least two deformation clustering areas with overlapping areas, respectively determining the duty ratio of the overlapping areas in each deformation clustering area, and taking the deformation clustering area with the largest duty ratio as a target clustering area.
After determining the deformed cluster areas corresponding to all the candidate cluster areas, the deformed cluster areas can be divided into two types: the first category is that no overlapping area exists in other deformation clustering areas; the second category is that there are overlapping regions with other deformation cluster regions.
For the first type of deformation clustering areas, the deformation clustering areas cannot be used as target clustering areas, and the first type of deformation clustering areas can be directly discarded; for the second type of deformed cluster regions, the deformed cluster regions may or may not be the target cluster regions.
For at least two deformed cluster areas (i.e., the deformed cluster areas of the second type mentioned in the above embodiment) where there is an overlapping area, the duty ratio of the overlapping area in each deformed cluster area may be determined, and the deformed cluster area with the largest duty ratio may be used as the target cluster area, and the remaining deformed cluster areas may not be used as the target cluster areas.
Therefore, the deformation clustering areas can be screened, the purpose of controlling the number of target clustering areas is achieved, and the complexity of subsequent encryption is reduced.
Fig. 2 is a schematic diagram of determining a deformed cluster region corresponding to a candidate cluster region according to an embodiment of the present invention. As shown in fig. 2, 6 candidate cluster areas are counted as candidate cluster area 1 to candidate cluster area 6, respectively. And determining the deformation clustering areas corresponding to each candidate clustering area based on the horizontal maximum length and the vertical maximum length of each candidate clustering area respectively to obtain deformation clustering areas 1 'to 6'.
Fig. 3 is a schematic diagram of further determining a target cluster region based on the deformed cluster region shown in fig. 2 according to an embodiment of the present invention. As shown in fig. 3, since the deformed cluster region 1 'does not overlap with other deformed cluster regions, the deformed cluster region 1' cannot be regarded as a target cluster region. For the deformed cluster region 2' and the deformed cluster region 3', since the overlapped region exists in the deformed cluster region 2' and the duty ratio of the overlapped region in the deformed cluster region 2' is smaller than that of the overlapped region in the deformed cluster region 3', the deformed cluster region 2' cannot be used as a target cluster region, and the deformed cluster region 3' can be used as a target cluster region. For the deformation clustering region 4', the deformation clustering region 5' and the deformation clustering region 6', since the deformation clustering region 4' and the deformation clustering region 5 'have overlapping regions, the deformation clustering region 5' and the deformation clustering region 6 'have overlapping regions, the overlapping regions of the deformation clustering region 4' and the deformation clustering region 5 'occupy a larger area in the deformation clustering region 4', and the overlapping regions of the deformation clustering region 5 'and the deformation clustering region 6' occupy a larger area in the deformation clustering region 6', the deformation clustering region 5' cannot be used as a target clustering region, and the deformation clustering region 4 'and the deformation clustering region 6' can be used as target clustering regions. The final target cluster areas are the deformed cluster area 3', the deformed cluster area 4' and the deformed cluster area 6'.
In an embodiment, a target cluster region may also have a sequence number. The sequence number of the target cluster area is determined according to the upper left corner coordinates and the lower right corner coordinates of the target cluster area. For example, the upper left, lower right, and lower right coordinates of the target cluster regions are summed, and the target cluster regions are ordered in order of magnitude of the summation.
S130, encrypting each target clustering area, a second component of the image to be encrypted and a third component of the image to be encrypted respectively to obtain an intermediate image, wherein the second component and the third component are two components except the first component in the Y component, the U component and the V component.
In one embodiment, the encryption process of step S130 can be divided into two main categories: one is to encrypt each target cluster area; the other is to encrypt the second component of the image to be encrypted and the third component of the image to be encrypted. And (5) summarizing all encryption results to obtain the intermediate image.
Specifically, taking any one target clustering area as an example, the method for encrypting the target clustering area may include the following three steps.
Step c1: and randomly generating a first chaotic system parameter and a first chaotic system initial value corresponding to the target clustering region.
Step c2: and generating a first chaotic encryption sequence corresponding to the target clustering region according to the first chaotic system parameter and the first chaotic system initial value.
Step c3: and encrypting the target clustering area by using the first chaotic encryption sequence.
Because the first chaotic system parameters and the first chaotic system initial values corresponding to each target clustering area are randomly generated, each target clustering area can be independently encrypted, so that the relevance of each characteristic of the first component in the image is reduced, and the cracking difficulty is improved.
In particular, the method of encrypting the second component of the image to be encrypted and the third component of the image to be encrypted may comprise the following three steps.
Step d1: and randomly generating a second chaotic system parameter and a second chaotic system initial value.
Step d2: and generating a second chaotic encryption sequence according to the second chaotic system parameter and the second chaotic system initial value.
Step d3: and respectively encrypting the second component of the image to be encrypted and the third component of the image to be encrypted by using the second chaotic encryption sequence.
Because the second component of the image to be encrypted and the third component of the image to be encrypted are encrypted as a whole, and the chaotic encryption sequences adopted during encryption are the same, the encryption complexity of the whole image is balanced on the basis of independently encrypting each target clustering area.
S140, inserting an information area into the intermediate image, and writing encryption information into the information area to obtain an encrypted target image, wherein the position of the information area is determined according to the size of the intermediate image and the associated information, and the encryption information comprises the number information of target clustering areas, the chaotic encryption key of each target clustering area, the position information of each target clustering area, the chaotic encryption key of the second component of the image to be encrypted and the chaotic encryption key of the third component of the image to be encrypted.
In one embodiment, the method of inserting an information area on the intermediate image and writing encryption information in the information area in step S140 may include the following four steps.
Step e1: and determining the reference position according to the size of the intermediate image and the associated information.
The size of the intermediate image is the same as the size of the image to be encrypted, the size of the original image. Since different images have differences, and the associated information is information related to the image to be encrypted, there is also a difference. Therefore, the reference position is random, thereby ensuring that the storage position of the encrypted information is also random.
Optionally, the reference position includes an abscissa position and an ordinate position, and the abscissa position of the reference position may be determined according to a ratio of a length of the intermediate image to a photographing time (such as a result of adding time of year, month, day, and second) of the original image; the ordinate position of the reference position may be determined from the ratio of the width of the intermediate image to the photographing apparatus ID.
Step e2: and inserting an information area on the intermediate image according to the reference position, wherein the information area is a row of pixel points which comprise the reference position and have the same length as the intermediate image, or the information area is a column of pixel points which comprise the reference position and have the same width as the intermediate image.
When the information area is a row of pixels comprising a reference position and having the same length as the intermediate image, the insertion of the information area on the intermediate image can be understood as an enlargement of a row of pixels at the abscissa position of the reference position of the intermediate image, i.e. the intermediate image changes from the original P rows of pixels to p+1 rows of pixels.
Similarly, when the information area is a column of pixels including the reference position and having the same width as the intermediate image, inserting the information area on the intermediate image can be understood as enlarging a column of pixels at the ordinate position of the reference position of the intermediate image, that is, the intermediate image is changed from the original Q columns of pixels to q+1 columns of pixels.
Step e3: dividing the information area into an effective information area and an ineffective information area, wherein the effective information area comprises a plurality of continuous pixel points taking the pixel point where the reference position is as a starting point, and the ineffective information area comprises all the other pixel points except the effective information area in the information area.
Since all the pixels in the information area are not necessarily used to write the encrypted information, the area where the pixels that need to write the encrypted information are located may be referred to as an effective information area, and the area where the pixels that do not need to write the encrypted information are located may be referred to as an ineffective information area.
In one possible implementation manner, the number of pixels included in the effective information area is 2×n+1, where n is the number information of the target cluster area.
Step e4: encryption information is written in the effective information area, and a first component, a second component, and a third component of each pixel point in the ineffective information area are set randomly.
For the invalid information region, the first component, the second component, and the third component of each pixel included therein are randomly set.
For the effective information area, in one possible implementation manner, the effective information area includes 1 first pixel point, 2n second pixel points and 1 third pixel point which are sequentially and continuously arranged, and n is the number information of the target cluster area. The position of the first pixel point is the reference position.
The method for writing the encrypted information in the effective information area specifically comprises the following steps: setting a first component of the first pixel point as the number information of the target clustering area, and randomly setting a second component and a third component of the first pixel point; for a target clustering area with a sequence number of i, setting a first component of a (2 i-1) th second pixel point as a first chaotic system parameter corresponding to the target clustering area, setting a second component and a third component of the (2 i-1) th second pixel point as an upper left corner abscissa and an upper left corner ordinate of the target clustering area respectively, setting the first component of the 2i th second pixel point as a first chaotic system initial value corresponding to the target clustering area, and setting the second component and the third component of the 2i th second pixel point as a lower right corner abscissa and a lower right corner ordinate of the target clustering area respectively; and setting the second component and the third component of the third pixel point as the second chaotic system parameter and the second chaotic system initial value respectively, and randomly setting the first component of the third pixel point.
Fig. 4 is a schematic diagram illustrating inserting an information area in an intermediate image and writing encrypted information in the information area according to an embodiment of the present invention. As shown in fig. 4, the information area is drawn by taking as an example a line of pixel points including a reference position and having the same length as the intermediate image. The information area comprises an effective information area and an ineffective information area, and the number of the target clustering areas is 3 and is respectively marked as a target clustering area 1, a target clustering area 2 and a target clustering area 3. The effective information area includes 2×3+1=8 pixels, and all pixels except the effective information area in the information area are invalid information areas.
For the first pixel point, the first component of the first pixel point is set to 3, and the second component and the third component of the first pixel point are set randomly.
For the 1 st to 2 nd second pixel points, the method is used for storing encryption information of a target cluster area with the sequence number of 1: setting the first component of the 1 st second pixel point as a first chaotic system parameter corresponding to the target clustering area 1, setting the second component and the third component of the 1 st second pixel point as an upper left-hand abscissa and an upper left-hand ordinate of the target clustering area 1 respectively, setting the first component of the 2 nd second pixel point as a first chaotic system initial value corresponding to the target clustering area 1, and setting the second component and the third component of the 2 nd second pixel point as a lower right-hand abscissa and a lower right-hand ordinate of the target clustering area 1 respectively.
For the 3 rd to 4 th second pixel points, the method is used for storing encryption information of a target cluster area with the sequence number of 2: setting the first component of the 3 rd second pixel point as a first chaotic system parameter corresponding to the target clustering area 2, setting the second component and the third component of the 3 rd second pixel point as an upper left-hand abscissa and an upper left-hand ordinate of the target clustering area 2 respectively, setting the first component of the 4 th second pixel point as a first chaotic system initial value corresponding to the target clustering area 2, and setting the second component and the third component of the 4 th second pixel point as a lower right-hand abscissa and a lower right-hand ordinate of the target clustering area 2 respectively.
For the 5 th to 6 th second pixel points, the method is used for storing the encryption information of the target clustering area with the sequence number of 3: setting the first component of the 5 th second pixel point as a first chaotic system parameter corresponding to the target clustering area 3, setting the second component and the third component of the 5 th second pixel point as an upper left-hand abscissa and an upper left-hand ordinate of the target clustering area 3 respectively, setting the first component of the 6 th second pixel point as a first chaotic system initial value corresponding to the target clustering area 3, and setting the second component and the third component of the 6 th second pixel point as a lower right-hand abscissa and a lower right-hand ordinate of the target clustering area 3 respectively.
And for the third pixel point, setting the second component and the third component of the third pixel point as the second chaotic system parameter and the second chaotic system initial value respectively, and randomly setting the first component of the third pixel point.
The storage position of the encryption information is determined according to the size of the intermediate image and the associated information, so that the randomness of the storage position is realized, the cracking difficulty is further improved, the purposes of improving the safety of image storage and transmission are realized, and information leakage is avoided.
The technical scheme of the embodiment of the invention designs a novel image encryption and decryption method. For an image encryption method, at least one target clustering area is determined by acquiring an image to be encrypted and associated information and according to a first component of the image to be encrypted; encrypting each target clustering area, the second component of the image to be encrypted and the third component of the image to be encrypted respectively to obtain an intermediate image; and finally, inserting an information area into the intermediate image, and writing encryption information into the information area to obtain the encrypted target image. On one hand, because the encryption is respectively carried out aiming at different target clustering areas, the relevance of each characteristic of the first component in the image is reduced, and the cracking difficulty is improved; on the other hand, the second component and the third component in the image are encrypted as a whole, and the encryption complexity of the whole image is balanced; in addition, the storage position of the encryption information is determined according to the size of the intermediate image and the associated information, so that the randomness of the storage position is realized, the cracking difficulty is further improved, the purposes of improving the safety of image storage and transmission are realized, and information leakage is avoided.
Example two
Fig. 5 is a flow chart of an image decryption method according to a second embodiment of the present invention, where the method may be performed by an image decryption device, and the image decryption device may be implemented in hardware and/or software, and the image decryption device may be configured in an electronic device (such as a computer or a server). The electronic device provided by the invention can have both the image encryption function and the image decryption function, namely, the electronic device can realize the image encryption method of the first embodiment and the image decryption method of the second embodiment. As shown in fig. 5, the method includes:
s210, acquiring an image to be decrypted and associated information, and determining the position of an information area according to the size of the image to be decrypted and the associated information.
The image to be decrypted is any one of the images to be decrypted, such as the encrypted target image mentioned in the first embodiment.
Since the image to be decrypted is obtained by inserting an information area in the intermediate image, it is first necessary to divide the intermediate image and the information area.
Specifically, when the information area is a row of pixels with the same length as the intermediate image, the size p×q of the intermediate image may be determined according to the size (p+1) ×q of the image to be decrypted; then determining a reference position according to the size P of the intermediate image and the associated information; and finally, determining a row of pixel points corresponding to the abscissa position of the reference position as the position of the information area.
Similarly, when the information area is a row of pixels with the same width as the intermediate image, the size p×q of the intermediate image may be determined according to the size p×q (q+1) of the image to be decrypted; then determining a reference position according to the size P of the intermediate image and the associated information; and finally, determining a column of pixel points corresponding to the ordinate position of the reference position as the position of the information area.
Alternatively, the association information may include a photographing time of the initial image and a photographing apparatus ID. The shooting time of the original image can be accurate to year, month and day, or accurate to time-division second. The photographing apparatus ID is an ID obtained by numbering a plurality of photographing apparatuses in sequence. The reference position comprises an abscissa position and an ordinate position, and the abscissa position of the reference position can be determined according to the ratio of the length of the intermediate image to the shooting time (such as the addition result of time, month, day, time, and second) of the original image; the ordinate position of the reference position may be determined from the ratio of the width of the intermediate image to the photographing apparatus ID.
S220, reading decryption information stored in the information area according to the position of the information area, and deleting the information area from the image to be decrypted to obtain an intermediate image, wherein the decryption information comprises the number information of target clustering areas, a chaotic decryption key of each target clustering area, the position information of each target clustering area, a chaotic decryption key of a second component of the intermediate image and a chaotic decryption key of a third component of the intermediate image, the target clustering area corresponds to the first component of the intermediate image, the first component is any one component of a Y component, a U component and a V component, and the second component and the third component are other two components except the first component.
After the position of the information area is determined, the decryption information stored in the information area can be read according to the position of the information area, and the information area is deleted from the image to be decrypted, so that an intermediate image is obtained.
Specifically, since all the pixels in the information area do not necessarily store decryption information, the first component of the reference position (i.e., the first pixel) may be read first to obtain the number information n of the target cluster area. Then, knowing that 2n pixel points after the first pixel point are second pixel points, and 1 pixel point after the second pixel point is third pixel point. Only the first pixel, the second pixel and the third pixel are stored with decryption information.
In one embodiment, the first pixel point stores the number information of the target cluster areas; the second pixel point stores a chaotic decryption key of each target clustering area and position information of each target clustering area; the third pixel point stores a chaotic decryption key of the second component of the intermediate image and a chaotic decryption key of the third component of the intermediate image.
For 2n second pixel points, the method for reading the chaotic decryption key of each target clustering area and the position information of each target clustering area stored in the second pixel points comprises the following steps: each 2 pixels in the 2n pixels are used for storing chaotic decryption keys and position information of 1 target cluster area. Namely, the 1 st to 2 nd second pixels behind the first pixel are used for storing the chaos decryption key and the position information of the target cluster area with the sequence number of 1, the 3 rd to 4 th second pixels behind the first pixel are used for storing the chaos decryption key and the position information of the target cluster area with the sequence number of 2, and the (2 n-1) th to 2 n-th second pixels behind the first pixel are used for storing the chaos decryption key and the position information of the target cluster area with the sequence number of n.
Taking the (2 i-1) th to the (2 i) th second pixel points after the first pixel point as an example, the first component of the (2 i-1) th second pixel point is a first chaotic system parameter corresponding to a target cluster area with a sequence number of i, the second component and the third component of the (2 i-1) th second pixel point are respectively an upper left corner abscissa and an upper left corner ordinate of the target cluster area with the sequence number of i, the first component of the (2 i) th second pixel point is a first chaotic system initial value corresponding to the target cluster area with the sequence number of i, and the second component and the third component of the (2 i) th second pixel point are respectively a lower right corner abscissa and a lower right corner ordinate of the target cluster area with the sequence number of i.
For the third pixel point, the second component and the third component of the third pixel point are the second chaotic system parameter and the second chaotic system initial value, wherein the second chaotic system parameter and the second chaotic system initial value are the second component of the intermediate image and the chaotic decryption key of the third component of the intermediate image.
S230, decrypting the second component of each target clustering area, the second component of the intermediate image and the third component of the intermediate image according to the decryption information to obtain a decrypted target image, wherein the decrypted target image is an image in a YUV format.
In one embodiment, the decryption process of step S230 can be mainly divided into two types: one is to decrypt each target cluster region; the other is to decrypt the second component of the intermediate image and the third component of the intermediate image. And summarizing all decryption results to obtain the decrypted target image.
Specifically, taking any one target clustering area as an example, the method for decrypting the target clustering area may include: generating a first chaotic encryption sequence corresponding to the target clustering region according to a first chaotic system parameter and a first chaotic system initial value corresponding to the target clustering region; determining the position of the target clustering region according to the left upper-corner abscissa, the left upper-corner ordinate, the right lower-corner abscissa and the right lower-corner ordinate of the target clustering region; and decrypting the first component of the intermediate image corresponding to the position of the target clustering region by using the first chaotic encryption sequence.
In particular, the method of decrypting the second component of the intermediate image and the third component of the intermediate image may comprise: generating a second chaotic encryption sequence according to the second chaotic system parameter and the second chaotic system initial value; and decrypting the second component of the intermediate image and the third component of the intermediate image respectively using the second chaotic encryption sequence.
On the basis of the above embodiment, since the decrypted target image is an image in YUV format, format conversion is also required to be performed on the decrypted target image, so as to obtain an original image in RGB format.
In one embodiment, the conversion relationship between the decrypted target image and the original image is:
R=Y+1.402*V;
G=Y-0.344*U-0.714*V;
B=Y+1.772*U。
the technical scheme of the embodiment of the invention designs a novel image encryption and decryption method. For an image decryption method, obtaining an image to be decrypted and associated information, and determining the position of an information area according to the size of the image to be decrypted and the associated information; reading decryption information stored in the information area according to the position of the information area, and deleting the information area from the image to be decrypted to obtain an intermediate image, wherein the decryption information comprises the number information of target clustering areas, chaotic decryption keys of each target clustering area, position information of each target clustering area, chaotic decryption keys of a second component of the intermediate image and chaotic decryption keys of a third component of the intermediate image, and the target clustering areas correspond to the first component of the intermediate image; and finally, decrypting the second component of each target clustering area, the second component of the intermediate image and the third component of the intermediate image according to the decryption information to obtain a decrypted target image. On one hand, because decryption is respectively carried out aiming at different target clustering areas, the relevance of each characteristic of the first component in the image is reduced, and the cracking difficulty is improved; on the other hand, the second component and the third component in the image are decrypted as a whole, and the decryption complexity of the whole image is balanced; in addition, the storage position of the decryption information is determined according to the size of the image to be decrypted and the associated information, so that the randomness of the storage position is realized, the cracking difficulty is further improved, the purposes of improving the safety of image storage and transmission are realized, and information leakage is avoided.
Example III
Fig. 6 is a schematic structural diagram of an image encryption device according to a third embodiment of the present invention. As shown in fig. 6, the apparatus includes: the system comprises an acquisition module 601, a clustering module 602, a chaotic encryption module 603 and an information insertion module 604.
The obtaining module 601 is configured to obtain an image to be encrypted and associated information, where the image to be encrypted is an image in YUV format;
the clustering module 602 is configured to determine at least one target clustering area according to a first component of an image to be encrypted, where the first component is any one of a Y component, a U component, and a V component;
the chaotic encryption module 603 is configured to encrypt each target cluster area, a second component of the image to be encrypted, and a third component of the image to be encrypted to obtain an intermediate image, where the second component and the third component are two components other than the first component in the Y component, the U component, and the V component;
the information inserting module 604 is configured to insert an information area into the intermediate image, and write encryption information into the information area, so as to obtain an encrypted target image, where the position of the information area is determined according to the size of the intermediate image and the associated information, and the encryption information includes the number information of the target cluster areas, the chaotic encryption key of each target cluster area, the position information of each target cluster area, the chaotic encryption key of the second component of the image to be encrypted, and the chaotic encryption key of the third component of the image to be encrypted.
Optionally, the acquiring module 601 is specifically configured to receive an original image sent by a capturing device, a capturing time of the original image, and a capturing device identifier ID, where the original image is an image in an RGB format; the original image is converted into an image to be encrypted, and the photographing time and the photographing apparatus ID of the original image are used as associated information.
Optionally, the clustering module 602 is specifically configured to cluster the first component of the image to be encrypted to obtain a plurality of candidate cluster areas; determining a deformation clustering area corresponding to each candidate clustering area according to the horizontal maximum length and the vertical maximum length of each candidate clustering area, wherein the deformation clustering area is the minimum circumscribed rectangular area of the candidate clustering area corresponding to the deformation clustering area; and for at least two deformation clustering areas with overlapping areas, respectively determining the duty ratio of the overlapping areas in each deformation clustering area, and taking the deformation clustering area with the largest duty ratio as a target clustering area.
Optionally, the chaotic encryption module 603 is specifically configured to randomly generate a first chaotic system parameter and a first chaotic system initial value corresponding to the target clustering area; generating a first chaotic encryption sequence corresponding to the target clustering region according to the first chaotic system parameter and the first chaotic system initial value; encrypting the target clustering region by using a first chaotic encryption sequence; randomly generating a second chaotic system parameter and a second chaotic system initial value; generating a second chaotic encryption sequence according to the second chaotic system parameter and the second chaotic system initial value; and respectively encrypting the second component of the image to be encrypted and the third component of the image to be encrypted by using the second chaotic encryption sequence.
Optionally, the information inserting module 604 is specifically configured to determine the reference position according to the size of the intermediate image and the associated information; and inserting an information area on the intermediate image according to the reference position, wherein the information area is a row of pixel points which comprise the reference position and have the same length as the intermediate image, or the information area is a column of pixel points which comprise the reference position and have the same width as the intermediate image.
Optionally, one target cluster area has a sequence number, and the sequence number of the target cluster area is determined according to the upper left corner coordinate and the lower right corner coordinate of the target cluster area.
The information inserting module 604 is specifically configured to divide the information area into an effective information area and an ineffective information area, where the effective information area includes a plurality of continuous pixels starting from a pixel where the reference position is located, and the ineffective information area includes all pixels except the effective information area in the information area; encryption information is written in the effective information area, and a first component, a second component, and a third component of each pixel point in the ineffective information area are set randomly.
Optionally, the effective information area includes 1 first pixel point, 2n second pixel points and 1 third pixel point which are sequentially and continuously arranged, and n is the number information of the target cluster area.
The information inserting module 604 is specifically configured to set a first component of the first pixel point as number information of the target cluster area, and randomly set a second component and a third component of the first pixel point; for a target clustering area with a sequence number of i, setting a first component of a (2 i-1) th second pixel point as a first chaotic system parameter corresponding to the target clustering area, setting a second component and a third component of the (2 i-1) th second pixel point as an upper left corner abscissa and an upper left corner ordinate of the target clustering area respectively, setting the first component of the 2i th second pixel point as a first chaotic system initial value corresponding to the target clustering area, and setting the second component and the third component of the 2i th second pixel point as a lower right corner abscissa and a lower right corner ordinate of the target clustering area respectively; and setting the second component and the third component of the third pixel point as the second chaotic system parameter and the second chaotic system initial value respectively, and randomly setting the first component of the third pixel point.
The image encryption device provided by the embodiment of the invention can execute the image encryption method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example IV
Fig. 7 is a schematic structural diagram of an image decryption device according to a fourth embodiment of the present invention. As shown in fig. 7, the apparatus includes: a determining module 701, an information obtaining module 702 and a chaotic decryption module 703.
A determining module 701, configured to obtain an image to be decrypted and associated information, and determine a position of an information area according to a size of the image to be decrypted and the associated information;
the information obtaining module 702 is configured to read decryption information stored in the information area according to a position of the information area, and delete the information area from the image to be decrypted to obtain an intermediate image, where the decryption information includes number information of target cluster areas, a chaotic decryption key of each target cluster area, position information of each target cluster area, a chaotic decryption key of a second component of the intermediate image, and a chaotic decryption key of a third component of the intermediate image, the target cluster area corresponds to a first component of the intermediate image, the first component is any one of a Y component, a U component, and a V component, and the second component and the third component are two components of the Y component, the U component, and the V component except the first component;
the chaotic decryption module 703 is configured to decrypt each target cluster area, the second component of the intermediate image, and the third component of the intermediate image according to the decryption information, to obtain a decrypted target image, where the decrypted target image is an image in YUV format.
The image decryption device provided by the embodiment of the invention can execute the image decryption method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example five
Fig. 8 shows a schematic diagram of the structure of an electronic device 10 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 8, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the respective methods and processes described above, such as an image encryption method or an image decryption method.
In some embodiments, the image encryption method or the image decryption method may be implemented as a computer program, which is tangibly embodied in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the image encryption method or the image decryption method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the image encryption method or the image decryption method in any other suitable way (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.
Claims (10)
1. An image encryption method, comprising:
acquiring an image to be encrypted and associated information, wherein the image to be encrypted is an image in YUV format;
determining at least one target clustering area according to a first component of the image to be encrypted, wherein the first component is any one of a Y component, a U component and a V component;
encrypting each target clustering region, a second component of the image to be encrypted and a third component of the image to be encrypted respectively to obtain an intermediate image, wherein the second component and the third component are two other components except the first component in the Y component, the U component and the V component;
Inserting an information area into the intermediate image, and writing encryption information into the information area to obtain an encrypted target image, wherein the position of the information area is determined according to the size of the intermediate image and the association information, and the encryption information comprises the number information of the target clustering areas, the chaotic encryption key of each target clustering area, the position information of each target clustering area, the chaotic encryption key of the second component of the image to be encrypted and the chaotic encryption key of the third component of the image to be encrypted.
2. The image encryption method according to claim 1, wherein acquiring the image to be encrypted and the associated information includes:
receiving an original image, shooting time of the original image and shooting equipment identification ID sent by shooting equipment, wherein the original image is an image in an RGB format;
and converting the original image into the image to be encrypted, and taking the shooting time of the original image and the shooting equipment ID as the associated information.
3. The image encryption method according to claim 1, wherein determining at least one target cluster area from the first component of the image to be encrypted comprises:
Clustering the first components of the image to be encrypted to obtain a plurality of candidate clustering areas;
determining a deformation clustering region corresponding to each candidate clustering region according to the horizontal maximum length and the vertical maximum length of each candidate clustering region, wherein the deformation clustering region is the minimum circumscribed rectangular region of the candidate clustering region corresponding to the deformation clustering region;
and for at least two deformation clustering areas with overlapping areas, respectively determining the duty ratio of the overlapping areas in each deformation clustering area, and taking the deformation clustering area with the largest duty ratio as the target clustering area.
4. The image encryption method according to claim 1, wherein encrypting the target cluster area for any one of the target cluster areas includes:
randomly generating a first chaotic system parameter and a first chaotic system initial value corresponding to the target clustering region;
generating a first chaotic encryption sequence corresponding to the target clustering region according to the first chaotic system parameter and the first chaotic system initial value;
encrypting the target clustering region by using the first chaotic encryption sequence;
Encrypting the second component of the image to be encrypted and the third component of the image to be encrypted comprises:
randomly generating a second chaotic system parameter and a second chaotic system initial value;
generating a second chaotic encryption sequence according to the second chaotic system parameter and the second chaotic system initial value;
and respectively encrypting the second component of the image to be encrypted and the third component of the image to be encrypted by using the second chaotic encryption sequence.
5. The image encryption method according to claim 4, wherein inserting an information area on the intermediate image includes:
determining a reference position according to the size of the intermediate image and the associated information;
and inserting the information area on the intermediate image according to the reference position, wherein the information area is a row of pixel points which comprise the reference position and have the same length as the intermediate image, or the information area is a column of pixel points which comprise the reference position and have the same width as the intermediate image.
6. The image encryption method according to claim 5, wherein one of the target cluster areas has a sequence number, the sequence number of the target cluster area being determined based on the upper left corner coordinates and the lower right corner coordinates of the target cluster area;
Writing encrypted information in the information area, comprising:
dividing the information area into an effective information area and an ineffective information area, wherein the effective information area comprises a plurality of continuous pixel points taking the pixel point where the reference position is located as a starting point, and the ineffective information area comprises all the pixel points except the effective information area in the information area;
writing the encryption information in the effective information area, and randomly setting a first component, a second component and a third component of each pixel point in the ineffective information area.
7. The image encryption method according to claim 6, wherein the effective information area includes 1 first pixel, 2n second pixels, and 1 third pixel, which are sequentially and continuously arranged, n being the number information of the target cluster area;
writing the encrypted information in the effective information area, including:
setting a first component of the first pixel point as the number information of the target clustering area, and randomly setting a second component and a third component of the first pixel point;
for the target clustering area with the sequence number of i, setting a first component of a (2 i-1) th second pixel point as a first chaotic system parameter corresponding to the target clustering area, setting a second component and a third component of the (2 i-1) th second pixel point as an upper left corner abscissa and an upper left corner ordinate of the target clustering area respectively, setting a first component of the 2i th second pixel point as a first chaotic system initial value corresponding to the target clustering area, and setting a second component and a third component of the 2i th second pixel point as a lower right corner abscissa and a lower right corner ordinate of the target clustering area respectively;
And setting the second component and the third component of the third pixel point as the second chaotic system parameter and the second chaotic system initial value respectively, and randomly setting the first component of the third pixel point.
8. An image decryption method, comprising:
acquiring an image to be decrypted and associated information, and determining the position of an information area according to the size of the image to be decrypted and the associated information;
reading decryption information stored in the information area according to the position of the information area, deleting the information area from the image to be decrypted to obtain an intermediate image, wherein the decryption information comprises the number information of target clustering areas, chaotic decryption keys of each target clustering area, the position information of each target clustering area, chaotic decryption keys of a second component of the intermediate image and chaotic decryption keys of a third component of the intermediate image, the target clustering area corresponds to a first component of the intermediate image, the first component is any one of a Y component, a U component and a V component, and the second component and the third component are other two components except the first component;
And decrypting each target clustering area, the second component of the intermediate image and the third component of the intermediate image according to the decryption information to obtain a decrypted target image, wherein the decrypted target image is an image in a YUV format.
9. An electronic device, the electronic device comprising:
at least one processor; and a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-8.
10. A computer readable storage medium storing computer instructions for causing a processor to perform the method of any one of claims 1-8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311695661.6A CN117714614A (en) | 2023-12-11 | 2023-12-11 | Image encryption method, image decryption method, electronic device, and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311695661.6A CN117714614A (en) | 2023-12-11 | 2023-12-11 | Image encryption method, image decryption method, electronic device, and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117714614A true CN117714614A (en) | 2024-03-15 |
Family
ID=90158222
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311695661.6A Pending CN117714614A (en) | 2023-12-11 | 2023-12-11 | Image encryption method, image decryption method, electronic device, and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117714614A (en) |
-
2023
- 2023-12-11 CN CN202311695661.6A patent/CN117714614A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9740884B2 (en) | Method and device for generating a code | |
US10832086B2 (en) | Target object presentation method and apparatus | |
US10970804B2 (en) | Image processing device and image processing method for selecting regions based on gradiation for embedding a watermark | |
Song et al. | Protection of image ROI using chaos-based encryption and DCNN-based object detection | |
US11210765B2 (en) | Image processing method and device, storage medium and computer device | |
CN109684797B (en) | Virtual IP protection method and system for confrontation network generated picture based on block chain | |
CN111402120A (en) | Method and device for processing annotated image | |
JP7282474B2 (en) | Encryption mask determination method, encryption mask determination device, electronic device, storage medium, and computer program | |
CN113221767B (en) | Method for training living body face recognition model and recognizing living body face and related device | |
CN114626967A (en) | Digital watermark embedding and extracting method, device, equipment and storage medium | |
CN112581344A (en) | Image processing method and device, computer equipment and storage medium | |
US20220284448A1 (en) | Anti-counterfeiting and encryption method based on local random image transformation technique | |
EP3410686B1 (en) | Image processing device, image processing method, and program | |
CN108021815B (en) | Image encryption method and device and electronic equipment | |
CN108932703B (en) | Picture processing method, picture processing device and terminal equipment | |
US9036921B2 (en) | Face and expression aligned movies | |
CN117714614A (en) | Image encryption method, image decryption method, electronic device, and storage medium | |
CN115731442A (en) | Image processing method, image processing device, computer equipment and storage medium | |
CN113868690B (en) | Trusted deposit certificate based privacy calculation method and system | |
US11782850B2 (en) | Information processing method, server, terminal, and computer storage medium | |
CN114140805A (en) | Image processing method, image processing device, electronic equipment and storage medium | |
CN108665434B (en) | Image synthesis method and device | |
CN112925594A (en) | Page data processing and checking method and device | |
US20230015096A1 (en) | Picture processing method and apparatus, electronic device and storage medium | |
CN109242763A (en) | Image processing method, picture processing unit, terminal device |
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 |