• Время чтения ~1 мин
  • 08.11.2022

Популярная библиотека PHP UUID от Бен Рэмси выпустила новую версию с поддержкой UUID v8, пользовательские UUID:

  • An implementation would like to embed extra information within the UUID other than what is defined in this document.
  • An implementation has other application/language restrictions which inhibit the use of one of the current UUIDs.
use Ramsey\Uuid\Uuid;
 
/*
The bytes should be a 16-byte octet string, an open blob of data that you may fill with 128 bits of information. However, bits 48 through 51 will be replaced with the UUID version field, and bits 64 and 65 will be replaced with the UUID variant. You must not rely on these bits for your application needs.
*/
 
$uuid = Uuid::uuid8("\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff");
 
printf(
    "UUID: %s\nVersion: %d\n",
    $uuid->toString(),
    $uuid->getFields()->getVersion()
);
 
/*
UUID: 00112233-4455-8677-8899-aabbccddeeff
Version: 8
*/

Comments

No comments yet
Yurij Finiv

Yurij Finiv

Full stack

Про мене

Professional Fullstack Developer with extensive experience in website and desktop application development. Proficient in a wide range of tools and technologies, including Bootstrap, Tailwind, HTML5, CSS3, PUG, JavaScript, Alpine.js, jQuery, PHP, MODX, and Node.js. Skilled in website development using Symfony, MODX, and Laravel. Experience: Contributed to the development and translation of MODX3 i...

Об авторе CrazyBoy49z
WORK EXPERIENCE
Контакты
Ukraine, Lutsk
+380979856297