I am not very comfortable with using C++ but am very familiar with Java. I am trying to construct an RSA encryption. The issue I am running into is when numbers get large. I am currently using uint64_t for all of my numbers, but at one point the numbers get too big and my final answer is different than what it should be.
Another issue is converting text into ascii. I want it so that if I type 'a', it would convert to 97.
You'll have to get yourself a BigInt library of some kind. They're less efficient than built-in types, but have a larger dynamic range. There are several available, Google it.
As far as converting to ASCII----simply recognize that char is an integer type. If you read in the character 'a' to a char (or as part of a string made up of chars), then that char will have the value 97, and you can see this if you cast it to int on output.
This only gets slightly tricky when dealing with digits, since then the type you're reading it to determines the value you get. If you enter "5", for instance, then if you were doing cin >> intval you'd get inval with the value 5; but if you did cin >> charval, you'd get charval with the value 53 ('5').
This is for a class project so yeah, I'm stuck doing it.
I am having issues with the bigint class. I'm not 100% how to set it up and then how to declare a variable as a BigInt.
Just because it is for class doesn't mean you have to reinvent each and every line of code. I'm sure your teacher would rather have you concentrate on the RSA part than the BigInt part.
2 things though:
1 - Are the numbers you are manipulating so big as to need BigInts? With RSA, the answer is usually yes, but since this is also a class project, you can get away with using little keys. See with your professor if he expects you to actually use bigints, and if the answer is yes, do you have to code it yourself.
2 - Also, by reordering operations in a smart way, you can get the same result, but use smaller bounds in your intermediate operations. A typical example is when calculating a combination.
Yeah, I have already asked my teacher if we can do a "mini RSA" project. She said that she would consider our project weaker even though some kids in my class projects are jokes. She said it is fine to use BigInt classes and that it is mot likely needed. My issue comes because I have no idea how the BigInt class works. The one I acquired gave me bigint.h, bigint.cpp and main.cpp. I'm not sure what to do with these files and how to use them in my function.
I appreciate any help because I cannot seem to find information anywhere,
My issue comes because I have no idea how the BigInt class works. The one I acquired gave me bigint.h, bigint.cpp and main.cpp. I'm not sure what to do with these files and how to use them in my function.
You might want to look into using the GMP; the documentation is not bad, and a not-so-naive C++ wrapper is provided.
Unfortunatly this isn't a C++ course. It is a network security class so my knowledge of C++ does not matter. My group members believed programming in C++ would be a good idea. I have gotten that Big Integer Library but am not sure how to actually utilize it. I am using Eclipse IDE and MINIGW compiler. How can I use this library with these two?
There are usually two steps to using a library:
1) #include the relevant header files from it
2) Link against the relevant lib files from it, building the library first if necessary (it will come with a Makefile or VS project if that's the case)
For some "header-only" libraries, you don't need to do #2.