Random hash in Python

后端 未结 9 1666
陌清茗
陌清茗 2020-12-23 13:11

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

9条回答
  •  粉色の甜心
    2020-12-23 13:23

    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...

提交回复
热议问题