If an application needs true RNG data in bulk, it should use the operating system facilities (such as /dev/random on Linux) directly and wait for entropy to become available. As a rule of thumb, this class should not be called upon to generate more than a kilobyte per second of random data (note: this may vary from system to system). Therefore, system() should not be used for high-frequency random number generation, lest the entropy pool become empty. Whether those generators are still of cryptographic quality is implementation-defined. If that happens, first the operating system then QRandomGenerator will fall back to Pseudo Random Number Generators of decreasing qualities (Qt’s fallback generator being the simplest). However, if they are true RNGs, those facilities have finite entropy sources and thus may fail to produce any results if their entropy pool is exhausted. On such systems, those facilities are true Random Number Generators. This function will use hardware facilities to generate random numbers where available. System() may be used to access the system-wide random number generator, which is cryptographically-safe on all systems that Qt runs on. The most common way of generating new values is to call the generate(), generate64() or fillRange() functions. The class can generate 32-bit or 64-bit quantities, or fill an array of those. On Unix systems, it’s equivalent to reading from /dev/urandom or the getrandom() or getentropy() system calls. System() may be used to access the system’s cryptographically-safe random generator. This object is thread-safe, may be shared for most uses, and is always seeded from system() Additionally, global() returns a global instance of QRandomGenerator that Qt will ensure to be securely seeded. SecurelySeeded() can be used to create a QRandomGenerator that is securely seeded with system(), meaning that the sequence of numbers it generates cannot be easily predicted. But given different seeds, the results should be considerably different. That is to say, given the same seed data, QRandomGenerator will generate the same sequence of numbers. When seeded, the sequence of numbers generated by this class is deterministic. Like the C++ random engines, QRandomGenerator can be seeded with user-provided values through the constructor. QRandomGenerator may be used to generate random values from a high-quality random number generator.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |