如何在 python3 中转换 php md5(sha1(time()))?

How to convert php md5(sha1(time())) in python3?

我是 python 的新人..

通常我在 PHP md5(sha1(time())) 中这样做,它会转换为:017df9435b048f86ac28a274543ac46df5e20e0ecff32123a58287

现在如何在 python3 中完成?

我试过导入 hashlib print(hashlib.md5(int(round(time.time() * 1)))) 但效果不佳。

有人可以帮助我吗?提前谢谢你。

它 return 与

的值不同
md5(sha1(time()))

同时因为 php 函数 md5 和 sha1 return 与 python3 函数 hashlib.sha1 hashlib.md5 有一些不同,但下面的代码可能是你想要的:

import hashlib,time
print(hashlib.md5(hashlib.sha1(str(int(round(time.time()))).encode()).hexdigest().encode()).hexdigest())