Python equivalent to mcrypt_create_iv in PHP -
basically converting php codeigniter's encryption method python stuck while converting php's mcrypt_create_iv library python.
thanks in advance.
mcrypt_create_iv() php interface os-level pseudo-random generators (it's not part of libmcrypt, contrary function name implies).
python provides such interfaces via os module , need os.urandom().
for example, if need translate mcrypt_create_iv(16, mcrypt_dev_urandom) python, you'd need write os.urandom(16).
to clarify possible confusion:
you may've used mcrypt_dev_random or mcrypt_rand in php, there literally no reason use either of instead of mcrypt_dev_urandom - better measurable criteria:
mcrypt_randin particular not suitable cryptographic purposes, or in other words - insecure.mcrypt_dev_randomcan , block until new entropy data available. don't want blocking in web application , myth/dev/randomsomehow better/dev/urandombecause of blocking has been debunked.
mcrypt_dev_urandom both non-blocking , secure.
Comments
Post a Comment