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? Any help is
appreciated!
|
|
0
|
|
|
|
Reply
|
ruben.de.visscher (9)
|
8/8/2005 6:12:39 PM |
|
In article <1123524759.032711.80090@o13g2000cwo.googlegroups.com>,
RubenDV <ruben.de.visscher@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?
Not within standard C.
>Any help is appreciated!
You should get one of the portable "bignum" packages that provide
arithmetic operations on arbitrary precision integers.
--
"Never install telephone wiring during a lightning storm." -- Linksys
|
|
0
|
|
|
|
Reply
|
roberson2 (8067)
|
8/8/2005 6:18:41 PM
|
|
RubenDV 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? Any help is
> appreciated!
General (not C specific) algorithm questions often get better answers
in comp.programming, so you might want to post such there rather than
here. I suggest you google for "bignum library", sounds like that
is what you want.
-David
|
|
0
|
|
|
|
Reply
|
lndresnick (326)
|
8/8/2005 6:21:40 PM
|
|
>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? Any help is
>appreciated!
One way to do it is to store the key as an ASCII decimal number in
a 257-byte character array (including '\0' terminator. You can do
the multiplication like you learned to in elementary school, handling
a digit at a time. I didn't say it would be efficient. One advantage
is that the result is already formatted so you can print it.
You can also look at 'bignum' packages, which tend to represent
things as arrays of (unsigned) integers, but the work is done for
you. Many of them work a lot like the decimal number approach,
except they are using base-65536 or base-2**32 or some other large
number of bits which is more efficient.
Gordon L. Burditt
|
|
0
|
|
|
|
Reply
|
gordonb.4t7wz (1)
|
8/8/2005 6:57:30 PM
|
|
"RubenDV" <ruben.de.visscher@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
|
|
0
|
|
|
|
Reply
|
rlb (4118)
|
8/9/2005 6:32:12 AM
|
|
|
4 Replies
30 Views
(page loaded in 0.09 seconds)
Similiar Articles: howto: MOV EAX, <64bit value> ? - comp.lang.asm.x86Hello Newsgroup, how can I store a 64 bit value in a EAX register for 686 or below x86 32bit amd pc architectures? ..8087 ..386 ..model flat ..code ... Add values to an array - comp.soft-sys.matlabHi, I'm new in using Matlab. X and Y is the centre point of my circle. I want to store the value of x and y which will be random numbers. So i use... Lookup: Howto display one field and store the value of another ...Lookup: Howto display one field and store the value of another ... Is this the best way to store my data? - comp.soft-sys.matlab ..... comp.databases.filemaker > Can you ... How to c the wavread function.. - comp.soft-sys.matlabHi all, Can i have your advise how can i c the ... below: abData[i+1] ... abData[i] In big Endian ... abData[i]; int b2 = abData[i + 1]; int value; //Store ... How can I find the maximum value of a sine wave ? (Simulink ...R-wave detection in ECG signal - comp.soft-sys.matlab How can I find the maximum value of a ... The sine wave is being generated by an ... can store all of this data in ... How to find largest value? - comp.soft-sys.matlabHow to Find the Largest Value in an Array in Visual Basic | eHow.com A Visual Basic array is a data structure that allows you to store a list of values. Arrays can store ... Matrix into Blob Column - comp.soft-sys.matlab> Hallo Joseph, > > > When I store my matrix, all the double values are rounded off as ints so that data is lost. How can i resolve this? > > Maybe it's a good idea ... BoxPlot Outliers Values Detection - comp.soft-sys.matlab ...I need to get the values of the outliers as a list (Demand1,Price1) How can I do that without using gname as am running on a huge data file so interactively naming it ... How can I add string to an integer matrix ?? - comp.soft-sys ...Add values to an array - comp.soft-sys.matlab I want to do this for N number of times, so how can i store ALL the ... Now I want to find 16 largest values in matrix A. JEditorPane html font size - comp.lang.java.guiBut it is not displayed that big. How can i display the text that big with the font ... Possible values: An integer between 1 and 7. This sets the font to some fixed ... Watch Videos, Save Big, Shop SmartWatch Videos, Save Big, Shop Smart. Beauty bargins that keep your look fresh., Do's and Don'ts for Healthy Nails., New Products. New Savings., Summer savings are here ... sql - How to store multiple values in TSQL Variables - Stack OverflowYou cannot store it into a single variable - one variable can hold one value. But you can easily store it into a in-memory table - something like: 7/28/2012 4:29:00 AM
|