Skip to content

[NFR]: UUID generator in Random #16326

@sinbadxiii

Description

@sinbadxiii

Hi guys!

Here I rewrote Random lib a bit for generate UUID. The generator allows you to get uuid version 1-5 (6,7,8 in developing).
This will also close the task #14608 (comment) and #14955

Prototype is here https://github.com/sinbadxiii/cphalcon-uuid

For example:

$random = new \Sparrow\Encryption\Security\Random();

//version 1
$random->uuid1(); //01e67d70-ddc8-11ed-ab2f-64a0807c6238
$random->uuid1(); //0c535000-ddc8-11ed-b96b-64a0807c6238
$random->uuid1(); //0d8ccf70-ddc8-11ed-a1c5-64a0807c6238

//version 3
$random->uuid3($uuid->uuid1(), "name") //c3410c85-6317-3d54-ba9e-d515be361767
$random->uuid3($uuid->uuid1(), "name") //6f3cede7-be2f-31f3-a278-5fee83616421
$random->uuid3($uuid->uuid1(), "name") //2a83e5e9-98e2-3584-ae41-2baeb33f8664

//version 4
$random->uuid4() //f52d2877-708f-4a2e-9cfb-0ca61a379e14
$random->uuid4() //e0170f8a-c263-4656-98c1-450553a8d48f
$random->uuid4() //0d5957c3-3506-45f5-b6dd-3d27c439ef81

//version 5
$uuid->uuid5($uuid->uuid4(), "name") //e2638379-8788-54d0-aa16-c2456941dddc
$uuid->uuid5($uuid->uuid4(), "name") //48edad3f-881b-568d-b998-5c8c3ed20728
$uuid->uuid5($uuid->uuid4(), "name") //cafcfaf8-e83f-5e7e-9a23-7039010f5168

We can discuss controversial points and I think to do a PR.

How do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    new feature requestPlanned Feature or New Feature Request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Released

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions