Skip to content

Uuid v7 collisions #518

@vudaltsov

Description

@vudaltsov

Description

From time to time I get v7 collisions. I also noticed that since 0ba1ffb uuids of this version do not differ much in the random part, maybe, that's the reason?

Steps to reproduce

<?php

// generate_uuids_v7.php

use function Ramsey\Uuid\v7;

require_once __DIR__.'/vendor/autoload.php';

for ($j = 0; $j < 100; ++$j) {
    $uuids = '';

    for ($i = 0; $i < 1_000_000; ++$i) {
        $uuids .= v7()."\n";
    }

    file_put_contents('uuids_v7.txt', $uuids, $j === 0 ? 0 : FILE_APPEND);
}
php generate_uuids_v7.php && sort uuids_v7.txt | uniq -cd

Expected behavior

Empty output

Screenshots or output

   2 018b2847-0e47-7148-8dec-df216b0d76c7
   2 018b2847-a950-7367-9fa7-e3344774c890
   2 018b2847-c3b4-7203-be93-5976ad423647
   2 018b2847-fbbd-703e-b616-d256da1f0ec0
   2 018b2848-1f15-7200-b831-ddc7c0e6f86f
   2 018b2848-dcbf-72eb-b6ea-256c9e1f5d38

Environment details

  • version of this package: 4.7.4
  • PHP version: 8.2.10
  • OS: macOS Ventura (13.3.1)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions