Sinisterly
C++ True Random Generator - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: C, C++, & Obj-C (https://sinister.ly/Forum-C-C-Obj-C)
+--- Thread: C++ True Random Generator (/Thread-C-True-Random-Generator)

Pages: 1 2


RE: C++ True Random Generator - w00t - 12-17-2013

Yes, random values may wind up being not random to a human viewer( repeated, etc ), but the odds of that happening significantly over hundreds of thousands of runs is miniscule. The testing for randomness is an interesting field.

I remember one test now {random}\nRand should equal maxRand / 2, with some percentage devation.

Of course, the reason that this particular example is bad has nothing to do with the randomness of the seed, it has to do with the predictability of the seed. The same problem is seen when using the pid as a seed. A malicious user can easily manipulate either one of these.


RE: C++ True Random Generator - Azrael - 12-17-2013

(12-15-2013, 10:42 PM)Night Owl Wrote: Found on my old files tought it might be helpful to members
Code:
#include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { srand(time(0)); for (int x = 1; x<10; x++) { cout << 1+(rand()%6) <<endl; } return 0; }

You should take a look on the .Net Lib for System.Security.Cryptography.RandomNumberGenerator Wink

i don't know if you are coding for Win or for Unix, but it provides good (pseudo)random numbers ^^

so have a nice day
Azrael


RE: C++ True Random Generator - cxS - 12-18-2013

(12-17-2013, 07:22 PM)Azrael Wrote: You should take a look on the .Net Lib for System.Security.Cryptography.RandomNumberGenerator Wink

i don't know if you are coding for Win or for Unix, but it provides good (pseudo)random numbers ^^

so have a nice day
Azrael

You propose a .NET method then proceed to ask about him coding in Windows or a Unix based system, and even after he has demonstrated that he is writing C, not any .NET language? I'm not sure what you're trying to point out...


RE: C++ True Random Generator - Azrael - 12-18-2013

(12-18-2013, 02:02 AM)cxS Wrote: You propose a .NET method then proceed to ask about him coding in Windows or a Unix based system, and even after he has demonstrated that he is writing C, not any .NET language? I'm not sure what you're trying to point out...

Sorry, my thoughts are sometimes a bit confusing.

i wanted to point out that this class generates very good random numbers ^^
but untill that point i didn't thought about platforms, so when i realized it could be run anywhere i asked for the platform ^^

and as a little comment: .net is just managed code which can be used everywhere in any language on Windows (sadly mono isnt that complete as .net).

have a nice day
Azrael


RE: C++ True Random Generator - cxS - 12-19-2013

(12-18-2013, 03:20 PM)Azrael Wrote: Sorry, my thoughts are sometimes a bit confusing.

i wanted to point out that this class generates very good random numbers ^^
but untill that point i didn't thought about platforms, so when i realized it could be run anywhere i asked for the platform ^^

and as a little comment: .net is just managed code which can be used everywhere in any language on Windows (sadly mono isnt that complete as .net).

have a nice day
Azrael

I know, but it's still not going to be very useful for a C implementation. It's IL, and the only other parts you could get from such, is the strategy, and what methods are being natively called via P/invoke perhaps. I still wouldn't choose to take that path though by preference.


RE: C++ True Random Generator - Azrael - 12-19-2013

(12-19-2013, 05:35 AM)cxS Wrote: I know, but it's still not going to be very useful for a C implementation. It's IL, and the only other parts you could get from such, is the strategy, and what methods are being natively called via P/invoke perhaps. I still wouldn't choose to take that path though by preference.

that might be true ^^