-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecrypt.m
More file actions
45 lines (35 loc) · 1.04 KB
/
Copy pathdecrypt.m
File metadata and controls
45 lines (35 loc) · 1.04 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
function msg = decrypt(code,cle)
chart = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',',','!','?'];
%transferé la "clé" a l'inverse
cle = Inverse(cle);
%__Eliminer l'espace entre les lettres
code = El_espace(code);
% convert code -----> :in tableau T
for i = 1 : size(code,2)
for j = 1 : size(chart,2)
if (code(i) == chart(j))
T(1,i)=j-1;
end
end
end
%convert tableau T -----> matrix Mat avec la clé "2*2" or "3*3"
Mat = Tab_matrix(cle,T);
%produit la clé pour matrix "Mat"
Mat = produit(cle,Mat);
% modulo 29
for i = 1 : size(Mat,1)
for j= 1 : size(Mat,2)
Mat(i,j) = mod(Mat(i,j),29);
end
end
% transferé matrix mat ------->: tableau T
T = matrix_Tab(Mat);
% transferé T ------->: message
for i = 1 : size(T,2)
for j = 1 : size(chart,2)
if (T(i) == j-1)
msg(1,i)= chart(j);
end
end
end
end