How to do DEFFIE HELLMAN (DH) USING MATLAB CODE

1.Introduction:-
Diffie hellman is a technique which uses symmetric key for encryption and decryption.


2.Problem Statement:-
To generate key K using the Diffie hellman for the given values.



3.Program:-
clc;
clear all;
close all;
n=input('Enter value of n:');
g=input('Enter value of g:');
x=input('Enter value of x:');
y=input('Enter value of y:');
A=mod(g^x,n);
B=mod(g^y,n);
k1=mod(B^x,n);
k2=mod(A^y,n);
display(k1)
display(k2)

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 give your values of n,g,x,y .


5.Output :-
                                


Command Window

                                                 




6.Conclusion -
Here we have successfully generate KEY for Deffie hellman using the MATLAB.

Comments

Popular post

How to add ,read,insert IMAGE in MATLAB

How to plot different discrete signal using MATLAB

How to do Frequency Shift Keying (FSK) using MATLAB