Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Because int values are stored in memory cells that use 4 bytes, which is 32 bits, there are only 23 4294967296 possible int values. So,

image text in transcribed
Because int values are stored in memory cells that use 4 bytes, which is 32 bits, there are only 23 4294967296 possible int values. So, an int variable can only store values between - in Java are limited to being between -2147483648 and 2147483647. What can you do if you want to do calculations that involve integer values that are much larger than this? You use the BigInteger class! In this Lab you are going to learn how to use the BigInteger class to do RSA encryption. We will only look at how to encrypt a large integer and send it to someone who can then decrypt it into another large integer. The individual user will have to figure out how to encode text messages or other information into large integers. RSA encryption uses modular arithmetic. To do arithmetic "mod n", we just do arithmetic normally, and then view n as 0. For n = 12 this is like clock arithmetic, where if it is 8 o'clock and you wait 7 hours, instead of being 15 o'clock, it is 3 o'clock, because we throw away all the 12's. Fortunately, the Biginteger class includes methods that do modular arithmetic. RSA encryption is a form of public key encruption. At "headquarters," someone comes up with special integers known as n and e, and they publish those values, saying to anyone in the world who cares, "to send us a number a, simply compute a mod n and send us that number, which we will call c." When headquarters receives the encrypted message c from someone, they simply compute ed mod n, where d is the secret decrypting number. This number turns out to be a Without going into a lot of interesting math, it turns out that the only way someone can figure out d is if they know how to factor n into a product of two prime numbers. And, as far as anyone knows, factoring a number n that is the product of two large prime numbers just takes too long (by "large" we mean hundreds of digits). This Enhanced Lab asks you to try this out, using n and e that are provided. Create a class Encrypt that will have the integers n and e as constants, will ask the user for their message a, will compute c = ae mod n, and will report the encrypted message c. For your test case, use these relatively tiny values for n and e, namely n 299448533341 e 121763

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions