【发布时间】:2013-03-22 07:45:57
【问题描述】:
这是我老师写的代码(python)。 (我使用蛮力发现的素数)。 我还有一些带有匹配哈希的密码的测试数据(现在我已经找到了函数中使用的两个素数,这并不重要)。
任何人都可以帮助我找到“扭转”这种情况的方法,或者至少给我一个提示吗?
def prime_number_hash(s , 17299, 209569):
"""
Will hash the string s using the two prime numbers p and n.
"""
h = 0
for k,l in enumerate(s):
v = ord(l)
# k is the index of the letter
h += v * pow(p,k)
return h % n
【问题讨论】:
-
请给我们一些有效的代码。
-
如果哈希是可逆的,它们将是一个真正出色的压缩。想一想,即使是千兆字节或更多字节,最终的哈希长度也与单个字符相同......
标签: python string security hash passwords