WAP to Implement Diffi-Helman Algorithm

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<MATH.H>
void main()
{
            int  a,xa,xb,b,c,d,e;
            clrscr();
            int ya,yb,k1,k2,q;
            printf("enter prime no q:=");
            scanf("%d",&q);
            printf("Enter prime no a where a is primitive root of q:=");
            scanf("%d",&a);
            printf("enter secret key xa:=");
            scanf("%d",&xa);
            printf("enter secret key xb:=");
            scanf("%d",&xb);

            b=pow(a,xa);
            ya=b%q;
            c=pow(a,xb);
            yb=c%q;
            printf("value of public key ya:=%d\n",ya);
            printf("value of public key yb:=%d\n",yb);

            d=pow(yb,xa);
            k1=d%q;
            e=pow(ya,xb);
            k2=e%q ;
            printf("value of k1:=%d\n", k1);
            printf("value of k2:=%d\n",k2);
            printf("here we get k1=k2 so keys are exchanged");
            getch();
}

Related Posts Plugin for WordPress, Blogger...

Engineering material

GTU IDP/ UDP PROJECT

GTU IDP/ UDP PROJECT

Patel free software download

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP