Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- def check_hashes(strings, target_hash):
- # Convert the target hash to lowercase
- target_hash = target_hash.lower()
- # Loop through each string in the list
- for string in strings:
- # Compute the SHA-256 hash of the string
- hash = hashlib.sha256(string.encode()).hexdigest().lower()
- # Compare the hash to the target hash
- if hash == target_hash:
- # If the hashes match, return the string
- return string
- # If no match is found, return None
- return None
- strings = [
- 'password',
- '123456',
- '12345678',
- ...
- ...
- ...
- 'evangeli',
- 'eeeee1',
- 'eyphed',
- ]
- target_hash = 'e6e62ee55819cdc13126a8633ee8c43eaf48abf491cbca92129ddf5505b70bc1'
- print(check_hashes(strings, target_hash)) # Outputs: 'foo'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement