[Tutor] What are these things urandom() returns?

Dick Moores rdm at rcblue.com
Tue Oct 10 10:00:15 CEST 2006


"urandom(n)

Return a string of n random 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 CryptGenRandom. If a 
randomness source is not found, NotImplementedError will be raised. 
New in version 2.4."

 >>> from os import urandom
 >>> urandom(10)
'\xc0\xf0\xea\x0c\xdd\x95u at Z\x89'
 >>>

???

Thanks,

Dick Moores
Win XP, Python 2.5




More information about the Tutor mailing list