Пример #1
0
def check_hash_one_word_list(list_of_word, md5_hash):
    for word in list_of_word:
        word_hash = md5_hasher.md5_hash_sentence(word)

        if word_hash == md5_hash:
            return True, word
    else:
        return False, None
Пример #2
0
def check_three_words(word_one,
                      word_two,
                      word_three,
                      md5_hash="4624d200580677270a54ccff86b9610e"):
    word_hash = md5_hasher.md5_hash_sentence(word_one + " " + word_two + " " +
                                             word_three)

    if word_hash == md5_hash:
        return True
    else:
        return False
Пример #3
0
def check_hash_for_list_pair_combinations(list_of_word_pairs, md5_hash):
    for word_pair in list_of_word_pairs:
        combinations = itertools.permutations(word_pair)
        for combination in combinations:
            sentence = combination[0] + " " + combination[1]
            word_hash = md5_hasher.md5_hash_sentence(sentence)

            if word_hash == md5_hash:
                return True, sentence

    else:
        return False, None
Пример #4
0
def check_three_tuples(tuple1,
                       tuple2,
                       tuple3,
                       md5_hash="4624d200580677270a54ccff86b9610e"):
    tuple_hash = md5_hasher.md5_hash_sentence(tuple1[0] + " " + tuple2[0] +
                                              " " + tuple3[0])

    if tuple_hash == md5_hash:
        print("-------Found the hash------- ", tuple1, tuple2, tuple3)
        return True
    else:
        return False
def test_check_three_tuples():
    tuple1 = ("This", None)
    tuple2 = ("is", None)
    tuple3 = ("Sparta!", None)

    sentence = "This is Sparta!"
    hashed_sentence = md5_hasher.md5_hash_sentence(sentence)

    hashed_result = word_checking.check_three_tuples(tuple1, tuple2, tuple3,
                                                     hashed_sentence)

    assert hashed_result
def test_multiple_cpu_solver_binary_numpy_search_three_words():
    solver = anagram_solver.MultipleCpuSolverBinaryNumpySearch()

    sentence_to_find = "zen above actor"
    md5_hash = md5_hasher.md5_hash_sentence(sentence_to_find)

    anagram_given = "nezabvoe torca"

    # todo: i don't like this reference to path!

    path_to_file = os.path.abspath("test_wordlist")

    result_sentece = solver.solve_anagram(anagram_sentence=anagram_given,
                                          path_to_wordlist=path_to_file,
                                          md5_hash=md5_hash)

    assert result_sentece == sentence_to_find
def test_did_not_find_anagram_sentence():
    solver = anagram_solver.MultipleCpuSolverBinaryNumpySearch()

    sentence_to_find = "aaa bbb ccc"
    md5_hash = md5_hasher.md5_hash_sentence(sentence_to_find)

    anagram_given = "ezn"

    # todo: i don't like this reference to path!

    path_to_file = os.path.abspath("test_wordlist")

    result_sentence = solver.solve_anagram(anagram_sentence=anagram_given,
                                           path_to_wordlist=path_to_file,
                                           md5_hash=md5_hash)

    expected_result = "No result"

    assert result_sentence == expected_result
def test_search_multi_core_binary_search_numpy():
    solver = anagram_solver.MultipleCpuSolverBinaryNumpySearch()

    sentence_to_find = "abc ab ac"

    md5_hash_sentence = md5_hasher.md5_hash_sentence(sentence_to_find)

    a, b, c = 2, 3, 5

    anagram_product_sum = a * b * c * a * b * a * c

    list_tuple_prime_sums = [("abc", a * b * c), ("cba", c * b * a),
                             ("ab", a * b), ("ac", a * c), ("ba", b * a),
                             ("bc", b * c), ("a", a), ("b", b), ("c", c)]

    result = solver.distribute_work(list_tuple_prime_sums, anagram_product_sum,
                                    md5_hash_sentence)

    assert result == sentence_to_find
Пример #9
0
def test_is_sentence_an_anagram_with_hashing_md5():
    sentence = "pastils turnout towy"
    hashed_sentence = md5_hasher.md5_hash_sentence(sentence)
    print(hashed_sentence)
    assert hashed_sentence == '4624d200580677270a54ccff86b9610e'