Monday, October 22, 2018

Extended euclidean cipher using C programming language


This is a code for Extended euclidean using C programming language.



Extended euclidean :-
Source code:-

#include<stdio.h>
#include<conio.h>
int main()
{
    int r1,a,r2,b,r,q,s1,s2,t1,t2,s,t;
    printf("Enter the value of a and b:");
    scanf("%d%d",&a,&b);
    r1=a;
    r2=b;
    s1=1,s2=0,t1=0,t2=1;
    while(r2>0)
    {
        q=r1/r2;
        r=r1-q*r2;
        s=s1-q*s2;
        t=t1-q*t2;
        printf(" %d    %d   %d     %d      %d   %d  %d  %d   %d   %d \n",q,r1,r2,r,s1,s2,s,t1,t2,t);
        r1=r2;
        r2=r;
        s1=s2;
        s2=s;
        t1=t2;
        t2=t;
    }
    printf(" %d   *   %d   +   %d    *   %d   = gcd(%d,%d) = %d \n",s,a,t,b,a,b,r1);
    getch();
}


Output:-


Diffie–Hellman key exchange using C programming language

This is a code for  Diffie–Hellman key exchange  using C programming language. Diffie–Hellman key exchange :- Source code:- #in...