Python中的随机哈希 [英] Random hash in Python

查看:285
本文介绍了Python中的随机哈希的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Python中生成随机哈希(MD5)的最简单方法是什么?

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

推荐答案

md5-hash只是一个128位的值,所以如果您想要一个随机的值:

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

这篇关于Python中的随机哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆