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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -