Partager via


Generate Random Data Securely

Use CryptGenRandom to generate random data. This function has two of the properties of a good random number generator, unpredictability and even value distribution.

On a Windows CE device, entropy is generated for CryptGenRandom by the following sources:

  • Thread and kernel switches (CeGetRandomSeed)
  • The current process identifier (GetCurrentProcessId)
  • The current thread identifier (GetCurrentThreadId)
  • Ticks since boot (GetTickCount)
  • Current time (GetLocalTime)
  • Memory information (GlobalMemoryStatus)
  • Object store statistics (GetStoreInformation)

All of this information is added to a buffer, which is hashed using MD4 and used as the key to modify a buffer, using RC4, provided by the user.

If Cryptography Services features are not included in your platform, you can also use CeGenRandom to generate random numbers.

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.