What platforms offer SystemRandom?

故事扮演 提交于 2019-12-10 16:17:46

问题


Python's random.SystemRandom provides cryptographic-quality pseudorandom numbers. What platforms is it supported on? Most importantly, are there any platforms that it is not supported on, and if so, which ones? Can anyone provide any information about how portable it is?


回答1:


From http://docs.python.org/library/random.html

The random module also provides the SystemRandom class which uses the system function os.urandom() to generate random numbers from sources provided by the operating system.

From http://docs.python.org/library/os.html#os.urandom

This function returns random bytes from an OS-specific randomness source. The returned data should be unpredictable enough for cryptographic applications, though its exact quality depends on the OS implementation. On a UNIX-like system this will query /dev/urandom, and on Windows it will use CryptGenRandom. If a randomness source is not found, NotImplementedError will be raised.



来源:https://stackoverflow.com/questions/6219254/what-platforms-offer-systemrandom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!