Read out this book. Its ETS official book for GRE.
Enjoy
I want to change the world in verry nice manner. But God (The Great Developer) will not wish to share code with me.
{
arr[k]=mod(pow(a,i),q);
k++;
}
for(i=0;i{
for(j=0;j{
if ((i!=j) && (arr[i]==arr[j]))
{
flag=0;
break;
}
}
}
return flag;
}
void main()
{
clrscr();
long q,prem_root=2;
long p_A,k_A,p_B,k_B,pub_A,pub_B;
cout<<"Enter prime no : ";
cin>>q;
do
{
prem_root++;
}while(check_root(q,prem_root));
cout<<"Enter private key of A : ";
cin>>p_A;
pub_A=mod(pow(prem_root,p_A),q);
cout<<"Enter private key of B : ";
cin>>p_B;
pub_B=mod(pow(prem_root,p_B),q);
k_A=mod(pow(pub_B,p_A),q);
k_B=mod(pow(pub_A,p_B),q);
cout<<"Public key A : "<cout<<"Public key B : "< if(k_A==k_B)
{
cout<<"Key exchange successful...";
}
else
{
cout<<"Key exchange unsuccessful...";
}
getch();
}