To design RSA Encryption algorithm I need a variable which can hold 1024 bits .
To design RSA Encryption algorithm I need a variable which can hold 1024 bits .
Code:#include <limits.h> unsigned char foo[ 1024 / CHAR_BIT ];
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Quzah.Code:_Bool foo[1024]; /* C99 ;) */
Hope is the first step on the road to disappointment.
>_Bool foo[1024]; /* C99 */
This is misleading because it implies that _Bool can be less than sizeof(char) (which it can't in a conforming implementation).
My best code is written with the delete key.
As another point of view - look for a bignum library which will handle arbitrary length integers and floating point operations.
try:
http://swox.com/gmp/
Possibly, however, they wanted to store "1024 bits", and that would in fact give you the required 1024 "bits". Bits have one of two states, and oddly enough, so do _Bools. I never said it would be the best way to do it. As a matter of fact, it would be an absolute pain in the ass to work with. But it could be done.Originally Posted by Prelude
Quzah.
Hope is the first step on the road to disappointment.
As another aside - why are you writing RSA code? If it's a school assignment, okay.
If it is for production code, look for a tested library module. Encryption is not something you throw together and expect protection. Even tho the RSA math is pretty easy.
How do you plan to generate keys? - for example. I cannot begin to describe what an awful idea it is to push your code into any kind of production environment. Just don't do it.
>they wanted to store "1024 bits"
That's why I didn't dispute that it works. However, if they wanted an array of only 1024 bits, the logical error could be easily missed. There are already enough "language experts" ..........ing about C being obtuse without our help.
My best code is written with the delete key.
> As another aside - why are you writing RSA code?
I agree, not knowing how to even represent a basic crypto datatype is off to a bad start.
RSA may be "secure", but it can only be as secure as it's implementation. If that's buggy and leaks information, then all is lost even it it technically passes all the algorithmic tests.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.