signature: add generate sign value method
This commit is contained in:
1 parent
1c4346805a
commit
d57006f6c3
1 file changed
+13
@@ -34,4 +34,17 @@ class Header
|
|||||||
{
|
{
|
||||||
return md5(uniqid(mt_rand(), true));
|
return md5(uniqid(mt_rand(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function generateSignValue(array $queryParams = [], string $body = '', string $randomNonce = ''): string
|
||||||
|
{
|
||||||
|
$apiKey = config('bitunix-api.api_key');
|
||||||
|
$apiSecret = config('bitunix-api.api_secret');
|
||||||
|
$timeStamp = (string)round(microtime(true) * 1000);
|
||||||
|
$digestedQueryParam = self::digestQueryParameters($queryParams);
|
||||||
|
|
||||||
|
$digestedHeader = $randomNonce . $timeStamp . $apiKey . $digestedQueryParam . $body;
|
||||||
|
$hash = hash('sha256', $digestedHeader);
|
||||||
|
$sign = $hash . $apiSecret;
|
||||||
|
return hash('sha256', $sign);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user