/* */ #ifndef D_SIMPLE_RANDOMIZER_H #define D_SIMPLE_RANDOMIZER_H #include "Randomizer.h" #include #include #ifdef __MINGW32__ # include #endif // __MINGW32__ namespace aria2 { class SimpleRandomizer : public Randomizer { private: static std::unique_ptr randomizer_; #ifdef __MINGW32__ HCRYPTPROV cryProvider_; #else // !__MINGW32__ std::minstd_rand eng_; #endif //!__MINGW32__ SimpleRandomizer(); public: static const std::unique_ptr& getInstance(); virtual ~SimpleRandomizer(); void init(); /** * Returns random number in [0, to). */ virtual long int getRandomNumber(long int to) CXX11_OVERRIDE; void getRandomBytes(unsigned char *buf, size_t len); long int operator()(long int to); }; } // namespace aria2 #endif // D_SIMPLE_RANDOMIZER_H