Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib, random, string, time, argparse
- import profile
- def get_random_string(length):
- return ''.join(random.choice(string.letters.join(string.digits)) for i in range(length))
- def get_truncated_hash(message, k):
- #return hashlib.sha512(message).digest()[-k:]
- return hashlib.sha512(message).digest()[0:k]
- def attack(k):
- i = 0
- while True:
- hash = get_truncated_hash(str(i), k)
- #print(hash)
- #print hash.encode("hex")
- if(hash == "\00" * k):
- print "String is " + str(i)
- print ("hash for s is " + hash.encode("hex"))
- break
- else:
- i = i + 1
- start=time.time()
- attack(3)
- print(time.time()-start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement