Advertisement
AlessandroG

Untitled

Nov 6th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import hashlib
  2. import random
  3. import string
  4.  
  5. sha1_value = {}
  6. find = False
  7. k = 12
  8. while find is False:
  9. value = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(32))
  10. hash_object = hashlib.sha1(value.encode())
  11. hex_dig = hash_object.hexdigest()
  12.  
  13. if sha1_value.get(hex_dig[len(hex_dig)-k:], 0) != 0:
  14. print("collisione\nValore 1")
  15. print(sha1_value[hex_dig[len(hex_dig)-k:]] + "-->" + hex_dig[len(hex_dig)-k:] )
  16. print("valore2\n" + value + "-->"+ hex_dig[len(hex_dig)-k:])
  17. find = True
  18. sha1_value[hex_dig[len(hex_dig)-k:]] = value
  19.  
  20. print(len(sha1_value))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement