How to create a random 160 bit prime number in C++? [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am working on a project in school and I need to create a 160 bit value. I haven't programmed in a while so I can't figure out how I would implement this. Any help would be appreciated.

You need a library for big integers (assuming you can't just take a ready-to-use cryptographic library).
First you create a random 160-bit value, not necessarily prime. Depending on the platform, you may use /dev/random, CryptGenRandom, or some other enthropy source(s), (possible several ones, combined).
Then you increment the value in a loop, applying e.g. Miller-Rabin (pseudo-)primality test to each candidate, until you find a prime number.

Related

108-bit integer in test bench [duplicate]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I was working on a factorial program, and the program didn't work when trying to find the factorial of 1000. I think big integers are the solution; how do they work? (In either C or C++)
GMP can do bigint operations for both C and C++. The documentation on that site is a good introduction, if you use the C++ classes they behave almost exactly like built-in primitive types.
Look for the GMP. See the other question regarding this topic:
Handling very large Integers
C++ Big Integer

Upto how many numbers next_permutation (given in CPP <algorithm>)works? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am using next_permutation in cpp (algorithm library). What is the upper limit on the length of the string which it can permute? As i can permute a string of length 5 easily but for length 50 it's just do not stop. I know 50! is quite large so i want to know if there is some reasonable limit on it's usage.
Well it works for as many numbers as your memory will fit. It simply takes longer. And by longer I mean that for 50! you will have to wait about 96442456880115988215412887386050129516671872047 years on a contemporary computer or a lot of orders of magnitute longer then the universe is supposed to exist.

Generating unique random numbers in a multi dimensional array in C++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am trying to create a 3x5 two dimensional array that contains the values 1-15 in a randomized order so that each number will only be used once.
Generate a vector or array containing the numbers 1-15 and then use std::random_shuffle, putting the result in your array.
I would suggest using boost random and using the uniform int or uniform small int distribution

Is the "!=" comparision operator faster than ">"? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
A really basic question:
Considering an unsigned integer value, we would like to check that is not equal to 0. Using != or >, which one would be more efficient to use in C++?
Is your application too slow? If it is, the first thing you should do is profile -- this will show you what is causing your program to be slow.
If you aren't having efficiency issues with your program then you shouldn't be worried about this. In fact, worrying about speed at this stage is a bad thing because often people write less readable code in an attempt to improve speed when it's not even an issue.

Of these four libraries, which are you most likely to use? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I'm trying to pick out my next hackery project. It'll likely be one of the following:
A sparse radix trie Implementation with extremely fast set operations
A really good soft heap implementation
A bloomier filter implementation
A collection of small financial algorithms, such as deriving total returns given a set of dividends and minimal information about them.
But I can't choose. So I thought I'd put my fate in the hands of my peers. Which of those four would you find most useful? Most interesting to work on? Which do you think is the most needed?
I didn't know what a bloomier (maybe Bloom?) filter is until reading your question. Sounds cool and useful.