Lets say that I want to do this
hashlibAlgo = "md5"
Hash= hashlib.**"hashlibAlgo"**("blah blah blah").hexdigest()
How can I do that. If I substitute the name of a method with a string it obviously does not work. How can I make it work? In powershell is easy, but I cannot figure it in Python.
You can get function to execute with getattr:
>>> import hashlib
>>> hashlibAlgo = "md5"
>>> getattr(hashlib, hashlibAlgo)("blah blah blah").hexdigest()
'55e562bfee2bde4f9e71b8885eb5e303'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With