查找具有相同sha1散列第一位的单词

2024-04-26 17:24:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要找到两个哈希值在前两位匹配的单词。你知道吗

我已经尝试过这样做,随机抽取一个数字,然后检查某个范围内的任何数字是否具有相同的前11个十六进制字符,但这不会返回任何结果。你知道吗

import random
import hashlib 
for y in range (0,20):
    a = random.randint(0,6000000)
    stra = str(a)
    result = hashlib.sha1(stra.encode()) 
    print(result.hexdigest()) 
    print(a)
    re = result.hexdigest()
    for i in range(0, 6000000):
            secon = str(i)
            seconda = hashlib.sha1(secon.encode())
            second = seconda.hexdigest()
            if re[0:10] == second[0:10]:
                if re != second:
                    print("dwkdowkd")
                    print(re)
                    print(second)

Tags: inimportreforrange数字randomresult