CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2006
    Posts
    109

    Real random number generator

    I need to use randomness in my application in I'm not use that the pseudo-random rand() function will be random enough.

    Where can I find a real random generator?

  2. #2
    Join Date
    May 2006
    Location
    Norway
    Posts
    1,709

  3. #3

    Re: Real random number generator

    Please refer X9.31 PRNG which is a true Pseudo Random Number Generator which takes into consideration all entropies. One possible place to refer it would be the Openssl implementation.

    Thanks.
    C++ is divine.

  4. #4
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Real random number generator

    If all you need is a better pseudo-random number generator (you're correct that the built-in rand() function is not that good), then Google for Mersenne Twister and you will get literally thousands of hits. Here's one: "Mersenne Twister Random Number Generator" at http://www-personal.engin.umich.edu/...neTwister.html

    Here's another: "Pseudo random number generators" at http://www.agner.org/random/

    Both include source code and a discussion of results/performance.

    If you need a "true" random number generator, then this implies that there is a source of true entropy. See the "True Random Number Generator" section in this Wikipedia article: "List of random number generators" at http://en.wikipedia.org/wiki/List_of...ber_generators

    Mike
    Last edited by MikeAThon; May 2nd, 2007 at 08:03 PM.

  5. #5
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Real random number generator

    Point is, only with software, you can only get pseudo-number generators. Computers are deterministic and so is the software. If you want true random numbers you must use a hardware device to generate them.

    My question is: what kind of application do you have that requires random numbers?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured