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

Consider fully compliant UUID4 generator #9

Closed
JujuAdams opened this issue Jul 16, 2021 · 0 comments
Closed

Consider fully compliant UUID4 generator #9

JujuAdams opened this issue Jul 16, 2021 · 0 comments
Labels
bug 😅 Juju did a bad thing

Comments

@JujuAdams
Copy link
Owner

    //As per https://www.cryptosys.net/pki/uuid-rfc4122.html
    //FIXME - Do this without random()/choose() calls
    var _UUID = md5_string_utf8(string(current_time) + string(date_current_datetime()) + string(random(0xFFFFFF)));
    _UUID = string_upper(_UUID)
    _UUID = string_set_byte_at(_UUID, 13, 0x34);
    _UUID = string_set_byte_at(_UUID, 17, choose(0x38, 0x39, 0x41, 0x42));
    _UUID = string_insert("-", _UUID, 21)
    _UUID = string_insert("-", _UUID, 17)
    _UUID = string_insert("-", _UUID, 13)
    _UUID = string_insert("-", _UUID, 9)
    return _UUID;
}
@JujuAdams JujuAdams added the bug 😅 Juju did a bad thing label Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 😅 Juju did a bad thing
Projects
None yet
Development

No branches or pull requests

1 participant