Question: Hi all, I need to code this preferably in Python or Java. Below is the assignment and the Java psuedo code to complete with to
Hi all,
I need to code this preferably in Python or Java. Below is the assignment and the Java psuedo code to complete with to dos. I'm not really sure where to start any help would great.




import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class RSA_assignment
{
static Scanner console = new Scanner (System.in);
public static void main(String [] args) throws FileNotFoundException
{
System.out.println("Q. How to say hello on Java? : A. Hello Java!!!");
System.out.println("Q. How to say hello on C++? : A. Hello C++!!!");
Scanner inFile = new Scanner (new FileReader("/Users/vboogie/Downloads/DataStructures/workspace/CSC255/src/Kamilla2.txt"));
long p,q;
long e;
String ggg;
ggg= inFile.next(); //e=
e=inFile.nextInt();
ggg= inFile.next(); //p=
p=inFile.nextLong();
ggg= inFile.next(); //q=
q=inFile.nextLong();
if ((p-1)%e==0||(q-1)%e==0) {System.out.println("I must choose another e from teacher's website");}
else{ System.out.println("gcd(e,(p-1)(q-1))=1");
BigInteger nBI= BobCalculateN(p, q);
BigInteger eBI= new BigInteger(""+e);
System.out.println("p="+p+" q="+q);
BigInteger dBI=BobCalculateD(p, q, e );
System.out.println("dBI="+dBI);
String mStr; //message
long m; //coded value as for a=01,b=02,.. z=26
// if a is first it coded 1, etc.
ggg= inFile.next(); //message=
String mmm=inFile.next();
System.out.println("message="+mmm);
mStr=getCode(mmm);
System.out.println("mStr="+mStr);
m= Long.parseLong(mStr); //work only for 9-10 letters long
BigInteger mBI=new BigInteger(""+m);
String c;
BigInteger cBI = mBI.modPow(eBI,nBI);
// c is encrypted message to post nBI n-to post
System.out.print("n= ");
System.out.print(nBI);
System.out.println();
System.out.print("e= ");
System.out.print(eBI);
System.out.println();
System.out.print("c= ");
System.out.print(cBI);
System.out.println();
System.out.print("m= ");
System.out.print(mBI);
System.out.println();
// PrintWriter outFile = new PrintWriter("Encripted.txt");
// I will get encrypted c from somebody , d and n are mine
BigInteger decryptedmBI=cBI.modPow(dBI, nBI); //decrypted message
// outFile.println(cBI);
// outFile.println(decriptedmBI);
System.out.print("mBI= ");
System.out.println(mBI);
System.out.print("decryptedmBI= ");
System.out.println(decryptedmBI);
String decriptedStr=decryptedmBI.toString();
System.out.println(decriptedStr);
//Print decoded message on meaningful English
PrintLetters(decriptedStr);
inFile.close();
// outFile.close();
}
}
public static long findPrime()
{
//ToDo
long p=0;
return p;
}
public static void PrintLetters(String decriptedStr)
{
//ToDo
}
public static void getCodeOfLetters(String str)
{
//todo
}
public static String getCode(String str)
{
//ToDo
String temp="1";
return temp;
}
public static BigInteger BobCalculateD(long p, long q, long e )
{
//ToDo
BigInteger dBI=new BigInteger(""+0);
return dBI;
}
public static BigInteger BobCalculateN(long p, long q)
{
//ToDo
BigInteger nBI= new BigInteger(""+p);
return nBI;
}
}
Encrypt and decrypt messages using a key(n, e), wheren pq, and p and q are prime numbers with 10 digits each, and e is relatively prime to (p -1)q 1). Two numbers are relatively prime if their greatest common divisor is 1 Use the Euclidean Algorithm to verify: gcd(e, (p - 1)(q -1))- 1 function gcd (e, m) while y 0 r=xmod y return x Encrypt the following message: "The camera is hidden in the bushes" Concatenate the letters in the message into blocks of 10 letters. For example: "thecamerai", would be the first block to encrypt. Notice, we will concatenate the letters after removing spaces. If there are empty spaces at the end of a block, pad with the letter "x'; for example: "hebushesxx". Encrypt and decrypt messages using a key(n, e), wheren pq, and p and q are prime numbers with 10 digits each, and e is relatively prime to (p -1)q 1). Two numbers are relatively prime if their greatest common divisor is 1 Use the Euclidean Algorithm to verify: gcd(e, (p - 1)(q -1))- 1 function gcd (e, m) while y 0 r=xmod y return x Encrypt the following message: "The camera is hidden in the bushes" Concatenate the letters in the message into blocks of 10 letters. For example: "thecamerai", would be the first block to encrypt. Notice, we will concatenate the letters after removing spaces. If there are empty spaces at the end of a block, pad with the letter "x'; for example: "hebushesxx
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
