-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLSC_Decryption.m
More file actions
57 lines (57 loc) · 1.79 KB
/
LSC_Decryption.m
File metadata and controls
57 lines (57 loc) · 1.79 KB
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
function [X0,P0,T] = LSC_Decryption(Key,E)
% zE = imread('encr.jpg');
[m,n,k]=size(E);
l = min(round(sqrt(m)),round(sqrt(n)));
L=l*l;
for N = 4:-1:1
if(N==1)
X0(N) = single(mod((Key(1)*Key(4)+Key(3)*Key(5)),1));
P0(N) = single(mod((Key(2)*Key(4)+Key(3)*Key(5)),1));
X0
P0
end
if(N==2)
X0(N) = single(mod((Key(1)*Key(4)+Key(3)*Key(6)),1));
P0(N) = single(mod((Key(2)*Key(4)+Key(3)*Key(6)),1));
X0
P0
end
if(N==3)
X0(N) = single(mod((Key(1)*Key(4)+Key(3)*Key(7)),1));
P0(N) = single(mod((Key(2)*Key(4)+Key(3)*Key(7)),1));
X0
P0
end
if(N==4)
X0(N) = single(mod((Key(1)*Key(4)+Key(3)*Key(8)),1));
P0(N) = single(mod((Key(2)*Key(4)+Key(3)*Key(8)),1));
X0
P0
end
X = lsc_py(4*L,X0(N),P0(N));
X1 = lsc_py(L,X0(N),P0(N));
% if(k==3)
% red = E(:,:,1);
% green = E(:,:,2);
% blue = E(:,:,3);
% C1 = uint8(ROS_Decryp(red,X1,L));
% C2 = uint8(ROS_Decryp(green,X1,L));
% C3 = uint8(ROS_Decryp(blue,X1,L));
%
% C = cat(3,C1,C2,C3);
% imrotate(C,90);
% red = C(:,:,1);
% green = C(:,:,2);
% blue = C(:,:,3);
% T1 = decry_scramb(red,X);
% T2 = decry_scramb(green,X);
% T3 = decry_scramb(blue,X);
% T = cat(3,T1,T2,T3);
% else
C = (ROS_Decryp(E,X1,L));
imrotate(C,-90);
T = decry_scramb(C,X);
% end
E = T;
end
end