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_rand in particular not suitable cryptographic purposes, or in other words - insecure.
  • mcrypt_dev_random can , block until new entropy data available. don't want blocking in web application , myth /dev/random somehow better /dev/urandom because of blocking has been debunked.

mcrypt_dev_urandom both non-blocking , secure.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -