Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

I need a cryptographically secure pseudorandom number generator for use in C++

encryption random number generator graphical

  • Please log in to reply
2 replies to this topic

#1 null

null

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 128 posts

Posted 05 June 2011 - 01:24 AM

I'm up to the stage of actually performing the encryption of the data in my encryption algorithm. Its a Symmetric-key algorithm meaning its only using 1 key. My first thing I'm going to do is generate the key, which then will be used later for encryption. I already know that its complicated to generate an integer that holds the same properties as a REAL random number. I also understand that the build in ran() function for C++ is not secure for encryption (also srand, more secure, but not enough). So now I am looking for a Cryptographically secure pseudorandom number generator (yes I copied that phrase from Wikipedia) for use in C++ (cross platform). Any ideas, suggestions?
  • 0

#2 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 05 June 2011 - 03:02 AM

srand is just a seeding function, it is not a more secure version of rand.

C++0x will contain facilities to generate random numbers, however you may wish to look in to the various Mersenne twister libraries available to be compiled. They provide large periods of fairly uniform numbers (unlike rand()) and are better defined (rand() can differ hundreds of times among different compilers)

There are various here for the C family of languages: Mersenne Twister in C, C++, C#
  • 0

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.


#3 fkl

fkl

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 417 posts

Posted 05 June 2011 - 12:07 PM

You might also take a look at Donald's Knuth's theory as well as programs on random number generation to understand the complexity of this problem which seems so trivial initially. There are a few solutions too.

Knuth: Recent News
http://www.eng.aubur...dom_Numbers.pdf
Knuth: Programs
  • 0





Also tagged with one or more of these keywords: encryption, random number, generator, graphical

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download