How to do VERNAM DECIPHERING USING MATLAB CODE
1.Introduction:-
2.Problem Statement:-
To decipher the given word by using vernam deciphering.
3.Program:-
%vernam decipher
clc;
clear all;
close all;
a1=['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'];
b1=[0:25];
word='wafg';
code='ratn';
display(word);
display(code);
for ii=1:length(word)
for jj=1:length(a1)
if word(ii)==a1(jj);
w1(ii)=b1(jj);
end
if code(ii)==a1(jj)
c1(ii)=b1(jj);
end
end
end
newcode=w1-c1;
for ii=1:length(newcode)
if(newcode(ii)<0);
newcode(ii)=newcode(ii)+26;
else
continue
end
end
display(newcode);
for ii=1:length(newcode)
for jj=1:length(b1)
if newcode(ii)==b1(jj)
finalcode(ii)=a1(jj);
else
continue
end
end
end
display(finalcode);
4.How to use this code:-
Here you have to only copy the code to MATLAB and just run it after that you have to edit your ciphered word which is to be decipher and key word.
Here we have used the same keyword which is used in vernam ciphering and ciphered word is also same as that of generated by vernam ciphering.
5.Output :-
6.Conclusion -
Here we have successfully cipher the word by using Vernam decipher MATLAB.
It is the technique which is use to cipher or encrypt the data word by using keyword.
2.Problem Statement:-
To decipher the given word by using vernam deciphering.
3.Program:-
%vernam decipher
clc;
clear all;
close all;
a1=['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'];
b1=[0:25];
word='wafg';
code='ratn';
display(word);
display(code);
for ii=1:length(word)
for jj=1:length(a1)
if word(ii)==a1(jj);
w1(ii)=b1(jj);
end
if code(ii)==a1(jj)
c1(ii)=b1(jj);
end
end
end
newcode=w1-c1;
for ii=1:length(newcode)
if(newcode(ii)<0);
newcode(ii)=newcode(ii)+26;
else
continue
end
end
display(newcode);
for ii=1:length(newcode)
for jj=1:length(b1)
if newcode(ii)==b1(jj)
finalcode(ii)=a1(jj);
else
continue
end
end
end
display(finalcode);
Here you have to only copy the code to MATLAB and just run it after that you have to edit your ciphered word which is to be decipher and key word.
Here we have used the same keyword which is used in vernam ciphering and ciphered word is also same as that of generated by vernam ciphering.
5.Output :-
Command Window
6.Conclusion -
Here we have successfully cipher the word by using Vernam decipher MATLAB.
Comments
Post a Comment