Bonsoir à tous, je débute avec Matlab à l'université et j'ai besoin d'encrypter avec le code Cesar, j'ai réaliser un petit quelque chose mais ce n'est toujours pas bon pour les minuscule, il y a un problème à la lettre a et dès que je le règle un problème sur la lettre y apparaît et de plus le prof me demande de le faire d'une façon bien plus simplifié
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
function ceaser
clc
x=input('Enter Input Text =','s');
len=length(x);
array=[];
input1=[];
key = input( 'Enter Key Value');
for i=1:len
input1(i)=x(i);
end
for i=1:len
array(i)=input1(i)+key;
%handling small alphabets
if array(i)>122 && input1(i)>=97
array(i)=array(i)-122;
array(i)=array(i)+96;
end
%handling capital alphabets
if array(i)>90 && input1(i)<=65
array(i)=array(i)-90;
array(i)=array(i)+64;
end
end
disp('Ecryption Result');
ENCRYPT = char(array)
for i=1:len
array(i)=array(i)-key;
%handling small alphabets in Decryption
if array(i)<=97 && input1(i)>=122
array(i)=97-array(i);
array(i)=123-array(i);
end
%handling capital alphabets
if array(i)<65 && input1(i)<=90
array(i)=65-array(i);
array(i)=91-array(i);
end
end
disp('Decryption Result');
DECRYPT = char(array)