import hashlib


def main():
    break_hash()


def break_hash():
    hash_to_crack = input('Give hash: ')
    with open('./common.txt') as passwords:
        pswd_list = passwords.read().split('\n')
        print(pswd_list)
        i = 0
        # Go through the list
        while i <= len(pswd_list):
            # Hash the word on list
            hashed = hashlib.md5(pswd_list[i].encode('utf-8')).hexdigest()
            print(hashed)
            # If hashes match print the hash and break the loop
            if hash_to_crack==hashed:
                print('This is the password:',pswd_list[i])
                break
            i += 1


if __name__ == "__main__":
    main()
