Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
15 lines (14 sloc) 460 Bytes
# usage: python file sha1
# very slow
import sys, hashlib
data = open(sys.argv[1], 'rb').read()
assert len(sys.argv[2]) == 40
sha = sys.argv[2].decode('hex')
for i in xrange(len(data)):
print i, '/', len(data)
for j in xrange(0, len(data) - i):
if hashlib.sha1(buffer(data, i, j)).digest() == sha:
#if hashlib.sha1(data[i:i+j]).digest() == sha:
print 'got it: %d+%d' % (i, j)
Jump to Line
Something went wrong with that request. Please try again.