Disclosure of Invention
The invention aims to provide an image encryption method and an image decryption method for solving the contradiction that smaller storage space and good encryption effect cannot be obtained at the same time.
In order to achieve the above object, the present disclosure provides a digital image encryption method based on modular inverse operation, including the following steps:
s1: giving an original image A;
s2: the pixel point in the ith row and the jth column in A is represented as pi,jAll the pixel points with the value of i + j being an odd number are classified into a first class, and all the pixel points with the value of i + j being an even number are classified into a second class;
s3: and performing modular inverse operation on all the pixel points of the first type or the second type, and replacing the original pixel value with the obtained modular inverse value to obtain an encrypted image A'.
The image decryption method is used for decrypting the image A' encrypted by the digital image encryption method, and comprises the following steps:
a1: performing modulo inversion operation on the pixels of the first type or the second type in A' according to claim 1 to obtain a modulo inversion value of the pixel;
a2: and replacing the original pixel value with the obtained modulus inverse value to restore the original image A.
The invention has the beneficial effects that:
1. in the invention, the classification of the pixel points of the image is determined according to the parity of the row mark and the column mark, so the classification method is simple and easy to implement;
2. the encryption of the pixel point is obtained by solving the modulo inversion of the pixel value of the point, and the operation is simple because other operations are not involved;
3. according to the digital image encryption method and the image decryption method based on the modular inverse operation, the system does not need extra information in the whole encryption and recovery process, so that the image information transmission efficiency is high;
4. when the encrypted image provided by the invention is recovered, the modulo inversion of the pixel value at the encrypted position is only required to be solved, and the value can be obtained by looking up a table. Therefore, the method for recovering the encrypted image is simple and efficient, and requires a small amount of computation.
5. In the process of encrypting and decrypting the image, each pixel point is independent, so that the error of the individual pixel point can not cause the diffusion phenomenon of the error.
On the basis of the technical scheme, the invention can be further improved as follows:
preferably, the pixel point p is selected in S3
i,jInverse of its modulus
The method comprises the following steps:
Detailed Description
The following detailed description of specific embodiments of the present disclosure is provided in connection with the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present disclosure, are given by way of illustration and explanation only, not limitation.
As shown in fig. 1, the digital image encryption method based on modular inverse operation includes the following steps:
(1) giving an original image A;
(2) the pixel point in the ith row and the jth column in A is represented as pi,jAll the pixel points with the value of i + j being an odd number are classified into a first class, and all the pixel points with the value of i + j being an even number are classified into a second class;
(3) and performing modular inverse operation on all the pixel points of the first type or the second type, and replacing the original pixel value with the obtained modular inverse value to obtain an encrypted image A'.
At S3, pixel point p is pointed out
i,jInverse of its modulus
The method comprises the following steps:
specifically, note S1Is the set of all the pixel points with the value of i + j being odd number:
S1={p1,2,p1,4,...,pi,j,., where i + j ≡ 1(mod 2)
Note S2Set of all pixels whose value i + j is even:
S2={p1,1,p1,3,...,pi,j,., where i + j ≡ 0(mod 2)
When the modulo inversion operation is performed on the first type of pixel points,
the image A is encrypted to obtain an image A ', and pixel points p ' of the image A 'i,jComprises the following steps:
the image decryption method is used for decrypting the image A' encrypted by the digital image encryption method, and comprises the following steps:
(1) performing modular inverse operation on the first type of pixel points in A';
(2) and replacing the original pixel value with the obtained modulus inverse value to restore the original image A.
Specifically, the first type pixel point p ' in A ' is subjected to 'i,jThe calculation method of the modular inversion operation comprises the following steps:
Due to the fact that
Thus, the original image A can be obtained.
In the invention, the classification of the pixel points of the image is determined according to the parity of the row mark and the column mark, so the classification method is simple and easy to implement;
the encryption of the pixel point is obtained by solving the modulo inverse operation of the pixel value of the point, and the method is simple and easy to implement because other operations are not involved;
according to the image encryption and recovery method based on modular inverse operation, the system does not need extra information in the whole encryption and decryption process, so that the image information transmission efficiency is high;
when the encrypted image provided by the invention is recovered, the modulo inversion of the pixel value at the encrypted position is only required to be solved, and the value can be obtained by inquiring the following table. Therefore, the recovery method of the encrypted image is simple and efficient, and the required computation amount is small.
The following table sets the modulo inversions of all possible pixel values, the values in the table being modulo inverses from 1 to 255 with respect to 257, respectively.
1
|
129
|
86
|
193
|
103
|
43
|
147
|
225
|
200
|
180
|
187
|
150
|
178
|
202
|
120
|
241
|
121
|
100
|
230
|
90
|
49
|
222
|
190
|
75
|
72
|
89
|
238
|
101
|
195
|
60
|
199
|
249
|
148
|
189
|
235
|
50
|
132
|
115
|
145
|
45
|
163
|
153
|
6
|
111
|
40
|
95
|
175
|
166
|
21
|
36
|
126
|
173
|
97
|
119
|
243
|
179
|
248
|
226
|
61
|
30
|
59
|
228
|
102
|
253
|
87
|
74
|
234
|
223
|
149
|
246
|
181
|
25
|
169
|
66
|
24
|
186
|
247
|
201
|
244
|
151
|
165
|
210
|
96
|
205
|
127
|
3
|
65
|
184
|
26
|
20
|
209
|
176
|
152
|
216
|
46
|
83
|
53
|
139
|
135
|
18
|
28
|
63
|
5
|
215
|
164
|
177
|
245
|
188
|
224
|
250
|
44
|
218
|
116
|
124
|
38
|
113
|
134
|
159
|
54
|
15
|
17
|
158
|
140
|
114
|
220
|
51
|
85
|
255
|
2
|
172
|
206
|
37
|
143
|
117
|
99
|
240
|
242
|
203
|
98
|
123
|
144
|
219
|
133
|
141
|
39
|
213
|
7
|
33
|
69
|
12
|
80
|
93
|
42
|
252
|
194
|
229
|
239
|
122
|
118
|
204
|
174
|
211
|
41
|
105
|
81
|
48
|
237
|
231
|
73
|
192
|
254
|
130
|
52
|
161
|
47
|
92
|
106
|
13
|
56
|
10
|
71
|
233
|
191
|
88
|
232
|
76
|
11
|
108
|
34
|
23
|
183
|
170
|
4
|
155
|
29
|
198
|
227
|
196
|
31
|
9
|
78
|
14
|
138
|
160
|
84
|
131
|
221
|
236
|
91
|
82
|
162
|
217
|
146
|
251
|
104
|
94
|
212
|
112
|
142
|
125
|
207
|
22
|
68
|
109
|
8
|
58
|
197
|
62
|
156
|
19
|
168
|
185
|
182
|
67
|
35
|
208
|
167
|
27
|
157
|
136
|
16
|
137
|
55
|
79
|
107
|
70
|
77
|
57
|
32
|
110
|
214
|
154
|
64
|
171
|
128
|
|
According to the image encryption and recovery method based on modular inverse operation, the pixel points are independent, so that error diffusion cannot be caused by errors of individual pixel points.
The preferred embodiments of the present disclosure are described in detail with reference to the accompanying drawings, however, the present disclosure is not limited to the specific details of the above embodiments, and various simple modifications may be made to the technical solution of the present disclosure within the technical idea of the present disclosure, and these simple modifications all belong to the protection scope of the present disclosure.
It should be noted that, in the foregoing embodiments, various features described in the above embodiments may be combined in any suitable manner, and in order to avoid unnecessary repetition, various combinations that are possible in the present disclosure are not described again.
In addition, any combination of various embodiments of the present disclosure may be made, and the same should be considered as the disclosure of the present disclosure, as long as it does not depart from the spirit of the present disclosure.