473,785 Members | 2,878 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how can i store huge values?

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!

Nov 15 '05 #1
4 1833
In article <11************ *********@o13g2 000cwo.googlegr oups.com>,
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?
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
Nov 15 '05 #2
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.programmin g, 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

Nov 15 '05 #3
>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
Nov 15 '05 #4
"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
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2398
by: Steve | last post by:
Hi, I have a web application where there are a number of columns a user can sort on (price, item etc). The database itself is HUGE (around 6 million rows) and even with all the indexing it slows down a bit if too many users start browsing. To be able to sort on a column, the webpage reloads and does a requery ORDERing on that particular column. How can I speed this up? Can I store a wholre resultset in a session variable? I tried doing...
2
1957
by: NWx | last post by:
Hi, Is Cache appropriate to store persistent variables used across the application? What I want is to store UserID for currently logged user, SessionID (my own SessionID, which keep track of datetime for login and logout as well as other info, like Client IP , etc) My objects I want store to cache are not set-up to expire. Or should I store them better in Session storage?
6
1919
by: Rudy | last post by:
Hello all! I am amazed how many posts I have read to store an image in SQL, and just as many against it. So I learned how to store an image in a SQL db and retrieve the image. A little tricky, but not too bad. But then I thought I wanted to try the other way, by putting the file location in SQL and storing the actual image in another directory. I plan to have many images on my web application, up to as many as 5000. Not to mention the...
6
3807
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for one day): \\FFDS24\ASP.NET Applications(_LM_W3SVC_1_Root_ATV2004)\Errors During Execution: 7 \\FFDS24\ASP.NET Apps v1.1.4322(_LM_W3SVC_1_Root_ATV2004)\Compilations
3
1493
by: serge calderara | last post by:
Dear all, One simple question relative to store procedure withinh ASP code on a web page. Let say that I am calling a store procedure to execute from a server button click on my web page. That store procedure is returning a bunch of values to my end user. In a matter of time based, what happen from my client web page if my store procedure runs for 3 minutes before returning any data back.
3
2864
by: Solution Seeker | last post by:
I want to Store the String value with Single Quotes in the Field of Database where if i try to Store the String value with Single Quotes (as it is) then it is throwing the error as SQL String Truncated. so we need a solution to store and retrieve user Entered value along with single quotes into the Database. i am using the String variable to frame the Qry(that is then passed to Database for execution) which is as follows
4
2272
by: Dave G | last post by:
Firstly, apologies as this is not strictly an Access problem. I have a Access 2003 database containing records about people, and each person has 2 photos associated with the record. The photos are stored in a 'photos' folder. When a record is displayed, so are the photos. It all works fast and well. But I'm now getting close to 50,000 records and although it still works well I'm worried about having 100,000 jpgs in one folder.
9
19846
by: Ajinkya | last post by:
Hello friends ! , I am very new to java script.If anyone can help me then I will be very very thankful to his/her. I am using php and mysql in my project and I have one textarea and one list boxes,now whenever user fill any value(email-Id) to textarea and press submit button then value going to listbox. These values are one or multiple , then they goes into list box , In list box these values are store in array . I mean user...
3
2165
by: Ahmad Jalil Qarshi | last post by:
Hi, I have a text file having size about 2 GB. The text file format is like: Numeric valueAlphaNumeric values Numeric valueAlphaNumeric values Numeric valueAlphaNumeric values For example consider following chunk of actual data:
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10152
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8974
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.