Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there any random function other than rand() in c++?
#1
Because I need to include stdlib.h to use it, but stdlib also has a function that conflicts with the other one I'm using (glut.h).

I tried google but nothing useful came up. That can conclude there's no other, but I try here in case there's another way nobody talks about.
Reply
#2
Not built-in, no. You could use the Mersenne Twister which, I believe, is built into Boost.

rand() is not a function that is suitable for cryptographic purposes anyway. Most programs use epoch time to seed the generator. Attackers can use that information to gain more information about the program or force an unrandom state.
Reply
#3
Fiel Wrote:rand() is not a function that is suitable for cryptographic purposes anyway. Most programs use epoch time to seed the generator. Attackers can use that information to gain more information about the program or force an unrandom state.

lol... I've been using it for my algorithms cryptography assignment. Although that is just a test program that will never be used for any real application. It's annoying that there is no better way of generating random numbers built into C/C++. (Although I guess it'd be really really hard to do)
Reply
#4
http://thedailywt%66.com/Articles/Random-Stupidity.aspx
Reply
#5
Luacake Wrote:http://thedailywtf.com/Articles/Random-Stupidity.aspx

That's easily the best PRNG I've... no wait. That's an actual RNG! It's not even pseudorandom! Pure brilliance. Submit that to RSA, folks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)