Question
In this assignment, you will review Java programming skills. Read Java API documentation of BigInteger class by clicking here. Please take a look at the
In this assignment, you will review Java programming skills. Read Java API documentation of BigInteger class by clicking here.
Please take a look at the attached sample program. See what it does. Now write a program using BigInteger class to read four BigIntegers (m, e, d and n) and perform the following computations: (Not the value of m, e, d and n don't change when you do the following computations.)
1. compute and print e + d and print the result
2. compute and print d xor e
3. compute m and d xor d and print the result
4. compute d or e and print the result
5. Shift m to the right by 5 and print the result
6. Shift m to the left by 3 and print the result
7. Compute the value c = me mod n and then print c (hint: use modPow method)
8. compute g=cd mod n and then print g
9. "bullet proof" your code so that your program won't crash no matter what the input is. Instead, the program displays an error message giving useful feedback to the user.
10. Repeat computations in Step 7 and Step 8 with the following numbers:
1. choose a value for m as you like
2. e=65537 3.d=89489425009274444368228545921773093919669586065884257445497854456487674839629818390934941973262879616797970608917283679875499331574161113854088813275488110588247193077582527278437906504015680623423550067240042466665654232383502922215493623289472138866445818789127946123407807725702626644091036502372545139713 4.n=145906768007583323230186939349070635292401872375357164399581871019873438799005358938369571402670149802121818086292467422828157022922076746906543401224889672472407926969987100581290103199317858753663710862357656510507883714297115637342788911463535102712032765166518411726859837988672111837205085526346618740053
5. Repeat above steps (10.1 through 10.5) with different values of m. (with values of d, e, and n being as indicated above). For different values of m, observe the corresponding values of g. What relationship do you see between g and m?
11. Submit the following: a) your program source code (.java) file. b) a separate text or word document or PDF file including the output of your program runs and the observation made in step 10.
Attachment sample program mentioned above:
import java.io.*; import java.math.*; class BigNumberExample{ public static void main (String args[]) { try { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter number a"); String aval = in.readLine(); System.out.println("Enter number b"); String bval = in.readLine(); BigInteger a = new BigInteger(aval); BigInteger b = new BigInteger(bval); System.out.println(a.add(b)); } catch (Exception e) { e.printStackTrace(); } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started