Implement Diffi-Hellmen Key exchange Method.


Aim : Implement Diffi-Hellmen Key exchange Method.

C Program Code :


#include <stdio.h>
#include <conio.h>
#include <math.h>

void main()
{
        int q,al;
 int xa,xb,ya,yb,ka,kb;
 clrscr();
 printf("Enter Prime Number q : ");
 scanf("%d",&q);
 printf("Enter Primitive Root al : ");
 scanf("%d",&al);
 printf("Enter Private Integer xa : ");
 scanf("%d",&xa);
 printf("Enter Private Integer xb : ");
 scanf("%d",&xb);

 ya=((int)pow(al,xa)%q);

 printf("\nPublic Interger ya : %d",ya);
 yb=((int)pow(al,xb)%q);
 printf("\nPublic Interger yb : %d",yb);
 ka=((long int)pow(yb,xa)%q);

 printf("\nKey of A Ka : %d",ka);
 kb=((int)pow(ya,xb)%q);
 printf("\nKey of b Kb : %d",kb);
        getch();
}

Output :


Post a Comment

0 Comments