-
Notifications
You must be signed in to change notification settings - Fork 347
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
Add generation of uuid V4 #325
Comments
Well im open for it but adding another lib to implement all this crypto stuff is a bit overkill imo. For 2.0 we improve the way we use extensions so i guess the best way there would be to create an extension that has a dependency on the ramsey uuid lib. We do not want this from core point of view but duplicating stuff again is also not right. |
Thank you for the feedback I've also found some quite simple scripts here and there, like in the PHP doc but i don't know how reliable they are and if the public static function v4() {
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand(0, 0x0fff) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node"
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
);
} I can also easily build a small provider for my app for the moment |
Indeed. Lets stick with this approach since if you look at the total installs and stars and such this is the way to go. Its a simple lib and atleast we know that they are valid at that point (crypto stuff) I will note it down for a possible extension for v2 though! |
Sorry i'm not sure i got your point here: did you mean add a simple function in v1 or build my own ? |
Add your own for now. |
Hello,
In Faker there is support for uuids but only version 3. Would you consider adding support for V4 as well ?
There was a PR in the old repo fzaninotto#1536
https://github.com/symfony/polyfill-uuid/blob/main/Uuid.php could be relevant here and could also be used to generate the other versions
I can make a PR if you're up for the change
The text was updated successfully, but these errors were encountered: