signature: generate dependencies for signature header
This commit is contained in:
1 parent
429c956e37
commit
1c4346805a
3 files changed
+85
-5
No files matched your search
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Msr\LaravelBitunixApi\Requests;
|
||||
|
||||
class Header
|
||||
{
|
||||
public static function sortQueryParameters(array $parameters): ?array
|
||||
{
|
||||
$sortableParameters = $parameters;
|
||||
|
||||
if (!count($sortableParameters)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
ksort($sortableParameters, SORT_LOCALE_STRING);
|
||||
return $sortableParameters;
|
||||
}
|
||||
|
||||
public static function digestQueryParameters(array $parameters): ?string
|
||||
{
|
||||
if (!count($parameters)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$sortedParameters = self::sortQueryParameters($parameters);
|
||||
return implode('', array_map(
|
||||
fn($k, $v) => $k . $v,
|
||||
array_keys($sortedParameters),
|
||||
array_values($sortedParameters)
|
||||
));
|
||||
}
|
||||
|
||||
public static function generateNonce(): ?string
|
||||
{
|
||||
return md5(uniqid(mt_rand(), true));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user