python - os.urandom or ssl.RAND_bytes? -


os.urandom or ssl.rand_bytes: when generating random bytes cryptographic purposes, more recommended?

if neither 1 better, tradeoffs , expected each in terms of differences?

note ssl.rand_bytes exists in python 3.

ssl.rand_bytes needs seeded before can used. cannot rely on ssl.rand_bytes alone. both os.urandom , `ssl.rand_bytes pseudo random number generators. prng's deterministic; when seeded same data, return same stream of pseudo random number bytes. these bytes should indistinguishable true random if observer not know seed value. os.urandom (re-)seeded using source of entropy within operating system.

using os.urandom should therefore preferred on ssl.rand_bytes. first of all, seeded (and reseeded operating system). furthermore, not require additional dependency on ssl library. drawback performance. faster use ssl.rand_bytes seeded big enough value os.urandom os.urandom requires system call time retrieve data.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -