Skip to content

Commit 9f9055a

Browse files
committed
use sorted serialize
1 parent 807c861 commit 9f9055a

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/functions.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,13 @@ function sign(PrivateKey $privateKey, array $data): string
147147
*/
148148
function serialize(array $data): string
149149
{
150-
return array_reduce(
151-
array_keys($data),
152-
fn ($acc, $key) => $acc . $key . $data[$key],
153-
''
154-
);
150+
$result = '';
151+
ksort($data);
152+
foreach ($data as $key => $value) {
153+
$result .= $key . $value;
154+
}
155+
156+
return $result;
155157
}
156158
}
157159

0 commit comments

Comments
 (0)