Potrzebuje informacji jak w delphi wykonać szyfrowanie za pomocą sha512. Czy są gotowe komponenty do tego?
Kod który chce przenieść z php do delphi.
function query(path, $key = `, $secret = `, array $req = array()) {
//generates a timestamp to the request (required for authentication)
$mt = explode(' ', microtime());
req['nonce'] = $mt[1].substr($mt[0], 2, 6);
//prepare POST data
post_data = http_build_query($req, '', '&');
//authorization headers
headers = array(
'Rest-Key: ' . $key,
'Rest-Sign: ' . base64_encode(hash_hmac('sha512', $post_data, base64_decode($secret), true)),
);
//CURL initialization
static $ch = null;
if (is_null($ch)) {
ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt(ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; Bitcurex PHP client; ' . php_uname('s') . '; PHP/' . phpversion() . ')');
}
curl_setopt(ch, CURLOPT_URL, 'https://domena.pl/' . path);
curl_setopt(ch, CURLOPT_POSTFIELDS, post_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, headers);
//executes the query
res = curl_exec($ch);
if (res === false) throw new Exception('Could not get reply: ' . curl_error($ch));
res = json_decode($res, true);
if (!res) {
throw new Exception('Invalid data received, please make sure connection is working and requested API exists');
}
return res;
}
//info retrieving
query('0/get', 'kluczapi', 'sekretapi');
</Code>
Proszę o wskazówki jakiej funkcji użyć aby poprawnie działało uwierzytelnianie api w delphi.