Answer the question
In order to leave comments, you need to log in
How to rewrite md5 hashing function from php to python3?
$request = array("apikey"=>$apikey,
"method"=>"calc",
"from_index"=>$from_index,
"to_index"=>$to_index,
"weight"=>$weight,
"ob_cennost_rub"=>$ob_cennost_rub
);
if ($password != "")
{
//если пароль указан, аутентификация по методу API ключ + API пароль.
$all_to_md5 = $request;
$all_to_md5[] = $password;
$hash = md5(implode("|", $all_to_md5));
$request["hash"] = $hash;
}
$hash = md5(implode("|", $all_to_md5));
Answer the question
In order to leave comments, you need to log in
And google for what? I myself am just starting to comprehend python and this is what I found.
import hashlib
example = {"a": 1, "b": 3}
m = hashlib.md5()
res = "|".join(str(value)for key, value in example.items())
m.update(res.encode('utf-8'))
md5 = m.hexdigest()
print(md5);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question