Guest User

Python MD5 Hash Checker

a guest
Jan 9th, 2024
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. import itertools
  2. import hashlib
  3.  
  4. def md5_crack(target_hash, min_length, max_length):
  5.     charset = [chr(i) for i in range(ord('a'), ord('z')+1)] + \
  6.               [chr(i) for i in range(ord('A'), ord('Z')+1)] + \
  7.               [chr(i) for i in range(ord('0'), ord('9')+1)] + \
  8.               list('!@#$%^&*()_-+=[]{}|;:,.<>?')
  9.  
  10.     for length in range(min_length, max_length + 1):
  11.         for attempt in itertools.product(charset, repeat=length):
  12.             attempt_str = ''.join(attempt)
  13.             if hashlib.md5(attempt_str.encode()).hexdigest() == target_hash:
  14.                 return attempt_str
  15.  
  16.     return None
  17.  
  18. target = '900150983cd24fb0d6963f7d28e17f72'  # MD5 hash of 'abc'
  19. result = md5_crack(target, 1, 4)
  20. if result:
  21.     print(f"Password found: {result}")
  22. else:
  23.     print("Password not found within the specified range and character set.")
Advertisement
Add Comment
Please, Sign In to add comment