RSA Algorithm

import java.io.*;
import java.util.*;
import java.math.*;
class RSA
{
public static void main(String args[]) throws IOException
{
Double p,q,n,d,c,t,m;
Double e=13.0;
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Two Prime Numbers:");
p=Double.parseDouble(br.readLine());
q=Double.parseDouble(br.readLine());
n=p*q;
t=(p-1)*(q-1);
d=Math.pow(e,-1);
d=((1+k*t)/e);
System.out.println("enter the message");
m=Double.parseDouble(br.readLine());
c=Math.pow(m,e)%n;
t=Math.pow(c,d)%n;
System.out.println("Encrypted message"+c);
System.out.println("original message"+m);

}
}
Output:

No comments:

Post a Comment