Random hash in Python

mistero picture mistero · Jun 10, 2009 · Viewed 81.5k times · Source

What is the easiest way to generate a random hash (MD5) in Python?

Answer

sth picture sth · Jun 10, 2009

A md5-hash is just a 128-bit value, so if you want a random one:

import random

hash = random.getrandbits(128)

print("hash value: %032x" % hash)

I don't really see the point, though. Maybe you should elaborate why you need this...