Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFR]: UUID generator in Random #16326

Open
sinbadxiii opened this issue Apr 18, 2023 · 5 comments
Open

[NFR]: UUID generator in Random #16326

sinbadxiii opened this issue Apr 18, 2023 · 5 comments
Labels
new feature request Planned Feature or New Feature Request

Comments

@sinbadxiii
Copy link
Contributor

sinbadxiii commented Apr 18, 2023

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?

@sinbadxiii sinbadxiii added the new feature request Planned Feature or New Feature Request label Apr 18, 2023
@Izopi4a
Copy link
Member

Izopi4a commented Apr 18, 2023

nice !

@sinbadxiii
Copy link
Contributor Author

added version 6

//version 6
$random->uuid6(); //1ede4ea1-7725-6670-916f-f9e288af019f 
$random->uuid6(); //1ede4ea1-7725-6770-be3c-f9e288af019f
$random->uuid6(); //1ede4ea1-7725-67e0-8837-f9e288af019f
...
$random->uuid6(); //1ede4eac-294b-6fe0-bedf-313f2e13333a
$random->uuid6(); //1ede4eac-294c-6120-a6fb-313f2e13333a
$random->uuid6(); //1ede4eac-294c-61a0-9490-313f2e13333a

@niden
Copy link
Member

niden commented May 2, 2023

I think we need to add this to the framework.

@niden
Copy link
Member

niden commented May 2, 2023

@sinbadxiii if you are OK with it to merge it, we can get a PR going, alternatively it can be a package on its own.

@sinbadxiii
Copy link
Contributor Author

@sinbadxiii if you are OK with it to merge it, we can get a PR going, alternatively it can be a package on its own.

ok, thanks!

I want to add versions 7-8 and run more tests and then I will prepare PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature request Planned Feature or New Feature Request
Projects
None yet
Development

No branches or pull requests

3 participants