I need to generate several random strings for later use of length 128 bit (or 16 bytes, 32 hex characters). I have used this until now:
hex(random.getrandbits(128))[2:]
Unfortunately it turns out that it does not consistently produce 32 hex characters which is a requirement of my implementation. Some strings it produces are shorter than others, i.e. 30 or 31 characters, which is a problem.
Is there another way to achieve this?