The CSIS Problem You have just been hired by CSIS in their cryptography division. You are working with their encryption algorithm that happens to use an encryption strategy called RSA. (You can read more about RSA encryption on your own time). Essentially, all you need to know is that RSA works with numbers, really big numbers, like numbers that have, on average, 400 digits. Your job is to help out your Senior developer by making large numbers easier to work with. Write a C# program called HugeNumber.cs. It should have two fields 1. A string that holds the value of the number 2. An int that holds how many digits are in the number (The leng

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

The CSIS Problem
You have just been hired by CSIS in their cryptography division. You are working with their encryption algorithm that happens to use an encryption strategy called RSA. (You can read more about RSA encryption on your own time).
Essentially, all you need to know is that RSA works with numbers, really big numbers, like numbers that have, on average, 400 digits.

Your job is to help out your Senior developer by making large numbers easier to work with.

Write a C# program called HugeNumber.cs. It should have two fields
1. A string that holds the value of the number
2. An int that holds how many digits are in the number (The length of the string).

It should also have:

3. A constructor that only takes the value as a parameter. The number of digits should be calculated
4. A public Display method that simply returns the value of the nuber
5. A method called NumDigits() that returns the number of digits in the number (This can be a property if you're feeling frisky).
6. A method called EndsWith() that returns the digit in the one's place (should be an int)
7. A comptareTo method (more on that below)


Your job is to implement a CompareTo method for these numbers. 

CmpareTo(HugeNumber o) should returns -1 if the current value is less than o's value, 0 if they are equal, and 1 if its larger.

The only caveat here is that you are not allowed to use the String's built in CompareTo methods - it's too slow while working with these numbers.

You cannot use BigInt / BigDouble

To test your application, put the following code in Program.cs inside of a main method.
Please also submit this file :D
HugeNumber num1 = new HugeNumber("4000000000000000000000000000000000000000000000000000000000000000000001")
HugeNumber num2 = new HugeNumber("4000000000000000000000000000000000000000000000000000000000000000000002")

Console.WriteLine(num1.CompareTo(num2)) // -1

HINT:
First check the length of both Huge Numbers. If they are different, then figuring out whether to return 1 or -1 should be easy.
If the numbers have the same number of digits, just loop through the string and find the first value that's larger. That HugeNumber must be bigger than the other.

How to loop through a string in C#
foreach (char c in someString)
{
    // You don't need to convert c to an integer. The relative difference is the same.

}

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Public key encryption
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY