Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 1 addition & 29 deletions agent/php/ElasticApm/Impl/Util/IdGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,6 @@ final class IdGenerator

public static function generateId(int $idLengthInBytes): string
{
return self::convertBinaryIdToString(self::generateBinaryId($idLengthInBytes));
}

/**
* @param array<int> $binaryId
*
* @return string
*/
private static function convertBinaryIdToString(array $binaryId): string
{
$result = '';
for ($i = 0; $i < count($binaryId); ++$i) {
$result .= sprintf('%02x', $binaryId[$i]);
}
return $result;
}

/**
* @param int $idLengthInBytes
*
* @return array<int>
*/
private static function generateBinaryId(int $idLengthInBytes): array
{
$result = [];
for ($i = 0; $i < $idLengthInBytes; ++$i) {
$result[] = mt_rand(0, 255);
}
return $result;
return bin2hex(random_bytes($idLengthInBytes));
}
}
Loading