How to do VERNAM CIPHERING USING MATLAB CODE

1.Introduction:-
It is the technique which is use to cipher or encrypt the data word by using keyword.


2.Problem Statement:-
To cipher the given word by using vernam ciphering.



3.Program:-
%vernam cipher
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='famt';
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)>25);
        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 word which is to be cipher and key word.


5.Output :-



Command Window

                                                 




6.Conclusion -
Here we have successfully cipher the word by using Vernam cipher MATLAB.

Comments

Popular post

How to plot AM (Amplitude Modulated) signal using MATLAB

How to add ,read,insert AUDIO in MATLAB