@ 2018-06-07T15:16:49Z <?php
class Guid
{
private $guid = '';
public function __construct($guid)
{
$this->guid = $guid;
}
public static function newGuid()
{
return new Guid('35918bc9-196d-40ea-9779-889d79b753f0');
}
public function __toString()
{
return $this->guid;
}
public function toByteArray()
{
$str = str_replace('-', '', $this->guid);
$ints = array_map('hexdec', str_split($str, 2));
// swap
$newints = $ints;
$newints[0] = $ints[3];
$newints[1] = $ints[2];
$newints[2] = $ints[1];
$newints[3] = $ints[0];
$newints[4] = $ints[5];
$newints[5] = $ints[4];
$newints[6] = $ints[7];
$newints[7] = $ints[6];
return implode('', array_map('chr', $newints));
}
public function printBytes($bytes)
{
for ($i = 0; $i < strlen($bytes); $i++) {
echo strtoupper(dechex(ord($bytes[$i]))).' ';
}
echo "\n";
}
}
$guid = Guid::newGuid();
$str = $guid->toByteArray();
$guid->printBytes($str);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.1.0 - 7.1.25 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 C9 8B 91 35 6D 19 EA 40 97 79 88 9D 79 B7 53 F0
Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
C9 8B 91 35 6D 19 EA 40 97 79 88 9D 79 B7 53 F0
preferences:dark mode live preview
161.04 ms | 402 KiB | 172 Q