decode os.urandom() bytes object
Use binascii.hexlify
. It works both in Python 2.x and Python 3.x.
>>> import binascii
>>> binascii.hexlify(os.urandom(32))
b'daae7948824525c1b8b59f9d5a75e9c0404e46259c7b1e17a4654a7e73c91b87'
If you need a string object instead of a bytes object in Python 3.x, use decode()
:
>>> binascii.hexlify(os.urandom(32)).decode()
'daae7948824525c1b8b59f9d5a75e9c0404e46259c7b1e17a4654a7e73c91b87'