"RubenDV" <ru***************@skynet.be> wrote:
I am trying to make a cipher with a 256-bit key but i have no idea how
the store this key without using arrays of ints or something like that.
I just need a type that is big enough to hold the entire key, because i
am going to use multiplication operations and such, which i can
impossibly use on arrays or so i think. Is there a way to treat an
array as a single, huge number without really being that?
Yes; primary school mathematics extended to larger bases; in this case,
you're probably doing base-2**32 math instead of base-10. All you need
is an array of 8 uint32_t's (or another typedef for an unsigned integer
you know is 32 bits large (or another known, fixed, size)), and an
understanding of long multiplication.
In primary school, when you were taught to multiply two numbers, say 123
and 234, how did you do that? Like this:
234
345
---*
1170
936
702
-----
80730
Now, instead of digits from 0 to 9, you're multiplying integers from 0
to (2**N)-1, but the principle remains the same. You don't even need the
sub-results; all you need are two source integers, if you wish two
working integers (though at a pinch you can do without), and the result
array.
Richard