Good time!
I create a POST request and send it to another URL . The request contains the generated md5 hash. The problem is that having the same values, I get different hashes. Why it happens?
Request:
$merchant_password = "password"; $merchant_name = "Name merchant"; $amount = "100"; $date = "2017-06-09 11:20:16"; $id_transfer = "f191a923-6311-47c8-bc38-04851355ae68"; $fee = "30"; $hash_string2= $amount.':' .$merchant_password.':' .$date.':' .$id_transfer; $hash2=strtoupper(md5($hash_string2)); // Send POST request $url = "http://example.com/post.php"; $post_data = array ( "amount" => $amount, "fee" => $fee, "method" => "ADV Cash", "merchant_name" => $merchant_name, "status" => "Confirmed", "date" => $date, "id_method_transaction" => $id_transfer, "ballance" => "123", "hash" => $hash2 ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // указываем, что у нас POST запрос curl_setopt($ch, CURLOPT_POST, 1); // добавляем переменные curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); $output = curl_exec($ch); curl_close($ch); echo $output; }else{ } Request handler:
<?php // строка, которую будем записывать $merchant_password = "password"; $amount = $_POST['amount']; $fee = $_POST['fee']; $method = $_POST['method']; $status = $_POST['status']; $date = $_POST['date']; $id_method_transaction = $_POST['id_method_transaction']; $ballance = $_POST['ballance']; $merchant_name = $_POST['merchant_name']; $id_transfer = $_POST['id_transfer']; $hash = $_POST['hash']; $hash_string= $amount.':' .$merchant_password.':' .$date.':' .$id_transfer; $user_hash=strtoupper(md5($hash_string)); // открываем файл, если файл не существует, //делается попытка создать его $fp = fopen("file.txt", "w"); // записываем в файл текст fwrite($fp, $amount . ' ' . $fee . ' ' . $method . ' ' . $status . ' '. $date . ' '. $id_method_transaction . ' '. $ballance . ' '. $merchant_name . ' ' .$id_transfer . ' ' . $hash . ' // user hash - ' . $user_hash); // закрываем fclose($fp); ?> The result of the query:
100 30 ADV Cash Confirmed 2017-06-10 11:20:16
Grateful for any help or direction!