简体   繁体   中英

md5(str.encode(var1)).hexdigest() giving hex value as 382fbe213f159eecf85facb256f265d0 - how to know the var1?

While running the test case, my code is failing as the expected value in hex is different then my answer.

for example, my ws_std value is 13.06 ie var1

md5(str.encode(var1)).hexdigest()  giving hex value as 382fbe213f159eecf85facb256f265d0 

But I am not sure if it matches with the hex value.

Getting error in below code:-

variables = ["ws_std", "p_range", "corr", "dew_month", "max_gust_month", "max_gust_value", "avg_temp", "temp_range", "max_p_range_day", "num_days_std", "median_b_days"]
answers = [ws_std, p_range, corr, dew_month, max_gust_month, max_gust_value, avg_temp, temp_range, max_p_range_day, num_days_std, median_b_days]

answer_dict = dict()

for var, ans in zip(variables, answers):
    answer_dict[var] = md5(str.encode(ans)).hexdigest()

with open('test_files/hash.pk', 'rb') as file:
    hash_dict = pickle.load(file)


def test_ws_std():
    assert hash_dict["ws_std"] == answer_dict["ws_std"]

Error Code:-

========================================================== FAILURES ==========================================================
________________________________________________________ test_ws_std _________________________________________________________

    def test_ws_std():
>       assert hash_dict["ws_std"] == answer_dict["ws_std"]
E       AssertionError: assert 'c8cc550afa85...2c6946c238f36' == '382fbe213f159...facb256f265d0'
E         - c8cc550afa85496c4ee2c6946c238f36
E         + 382fbe213f159eecf85facb256f265d0

test.py:40: AssertionError

see comments below. output required: ws_std

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM