-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathencryption.m
144 lines (79 loc) · 4.41 KB
/
encryption.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
% Encryption -Function
% -----------------------------------------------------------------------------------------------------------------------------------
function anss=encryption(a)
% STEP 1 : input original image
ori=entropy(a);
figure;
imshow(a);title('lena original');
% -----------------------------------------------------------------------------------------------------------------------------------
% STEP 2: Decompose in to R,G,B
% -----------------------------------------------------------------------------------------------------------------------------------
% STEP 3: Chaos sequence generation.
X1=arnoldx(x,y);
X2=arnoldx(x,y);
X3=arnoldx(x,y);
% Normalized chaotic sequence (arnold).
% -----------------------------------------------------------------------------------------------------------------------------------
% STEP 4: DNA Encoding on R,G,B components.
for i= 1:65536
DR(i)=DNA_encode_rule01(R(i));
end
% -----------------------------------------------------------------------------------------------------------------------------------
%STEP 5:DNA Encoding on Chaotic sequence S1,S2,S3.
D1=string();
for i= 1:65536
D1(i)=DNA_encode_rule01(S1(i));
end
% -----------------------------------------------------------------------------------------------------------------------------------
% STEP 6: DNA xor operation on R,G,B and chaotic sequence (S1,S2,S3):
for i=1:65536
XDR(i)=DNA_xor(DR(i),D1(i));
end
% -----------------------------------------------------------------------------------------------------------------------------------
% STEP 7: Calculating Hamming distance on R,G,B with respect to chaotic sequence:
for i=1:65536
HR(i)=disthamming(R(i),S1(i));
end
% -----------------------------------------------------------------------------------------------------------------------------------
% for decryption
% -----------------------------------------------------------------------------------------------------------------------------------
% STEP 8:DNA Encoding on Hamming distance.
for i=1:65536
DHR(i)=DNA_encode_rule01(HR(i),1);
end
% -----------------------------------------------------------------------------------------------------------------------------------
% STEP 9: DNA XOR operation on Encoded Hamming distance and Encoded Chaotic Sequence:
for i=1:65536
XR(i)=DNA_xor(DHR(i),D1(i));
end
% -----------------------------------------------------------------------------------------------------------------------------------
% STEP 10 : DNA Decoding on XOR- Hamming and Chaotic:
% -----------------------------------------------------------------------------------------------------------------------------------
% STEP 11: confusion and permutation by mandelbrotset
for i=1:65536;
rxt(i)=DNA_decode_rule01(XDR(i),1);
end
-------------------------------------------------------------------------------------------------------
% Calling Mandelbrot set function
mdset=md();
% find max element
% 1=coloumn_min, 2=row_min
for j=1:256;
mdm(j)=maximum(mdset,j,1);
% -----------------------------------------------------------------------------------------------------------------------------------
% shift to right with mdm check
% -----------------------------------------------------------------------------------------------------------------------------------
% STEP 12:DNA diffusion process
SR=reshape(rxtp,1,65536);
% diffusion using XORed Hamming and Confused R,G,B
% -----------------------------------------------------------------------------------------------------------------------------------
figure;
imshow(CR);title('diffused red');
imwrite(CR,'diffused red.png');
% -----------------------------------------------------------------------------------------------------------------------------------
figure;
imshow(cipherimage);title('cipherimage');
disp('Created by JITHIN K C');
anss=ric;
end
% -----------------------------------------------------------------------------------------------------------------------------------