Hello I wanted to convert from PHP to Python:
bin2hex(random_bytes(8))
But i got an error using: hex(os.urandom(8))
CodePudding user response:
Use binascii.hexlify() or bytes.hex() to convert from bytes to hexadecimal:
>>> import binascii
>>> import os
>>> binascii.hexlify(os.urandom(8))
b'1f981c91062fa8bb'
>>> os.urandom(8).hex()
'194adba04509969e'
