使用 Python 循环中的 md5 散列

Hash with md5 in loop with Python

我尝试查找以 5 '0' 开头的输入的 md5 散列

import md5
my_input = raw_input()
it = 1 
good_start = False

while not good_start:
    m = md5.new()
    m.update(my_input+str(it))
    my_string = m.hexdigest()
    good_start = my_string[0:4].count('0') == 5
    it += 1
    if it==609043:
        print my_string
        break

这是预期的输出

000001dbbfa3a5c83a2d506429c7b00e

这是我得到的输出

48fbdf1af6eb206e65ef98bf8a78ad85

在你的代码中你递增 it before 做比较:

 it += 1
 if it==609043:
   print my_string

这意味着当 it 为 609042

时,您将看到 my_string 的值