I'm making a project in python and I would like to create a random number that is cryptographically secure, How can I do that? I have read online that the numbers generated by the regular randomizer are not cryptographically secure, and that the function
>>> import os >>> os.urandom(10) 'm\xd4\x94\x00x7\xbe\x04\xa2R' >>> type(os.urandom(10)) <type 'str'> >>> map(ord, os.urandom(10)) [65, 120, 218, 135, 66, 134, 141, 140, 178, 25]
Return a string of
nrandom bytes suitable for cryptographic use.
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