Diffie Hellman Key Exchange Algorithm (Java)

import java.util.*; class DiffieHellman { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println(“Enter the value of Xa & Xb”); int Xa=sc.nextInt(); int Xb=sc.nextInt(); System.out.println(“Enter a Prime no. p”); int p=sc.nextInt(); System.out.println(“Enter Primitive Root a, such that a<p”); int a=sc.nextInt(); int Ya=(int)((Math.pow(a,Xa))%p); int Yb=(int)((Math.pow(a,Xb))%p); int Ka=(int)((Math.pow(Yb,Xa))%p); int Kb=(int)((Math.pow(Ya,Xb))%p); if(Ka==Kb) { System.out.println(“Transmission successful”); } else { System.out.println(“Transmission failed”); } } } Continue reading Diffie Hellman Key Exchange Algorithm (Java)

All your Engineering Programs at one place

It’s not that easy to complete an experiment in 2 hours’ lab. Sometimes you finish up writing a program within just 15 minutes & sometimes even a whole week’s time is not enough to do so. We’re Engineers, we don’t need to copy everything word by word, but we need that one kick start. Once we get started, it’s tough to stop us. There are … Continue reading All your Engineering Programs at one place