WICG / uuid

UUID V4
Other
63 stars 10 forks source link

refactor: simplify steps in algorithm #11

Closed bcoe closed 3 years ago

bcoe commented 3 years ago

Follow up to #5, based on @ctavan's feedback. This simplifies the algorithm steps, moving them closer to those described in RFC4122 (_they're almost identical to his reference implementation in Chromium_).

The one part I thought was a bit ugly was how giant step 5 becomes, overall I liked this approach better though.

Fixes #9


Preview | Diff

bcoe commented 3 years ago

I think we might have missed this in the previous update, but shouldn't the hexademical representation be a single character now? No padding needed?

@domenic I believe padding is necessary, from the spec:

hexOctet               = hexDigit hexDigit
hexDigit =
            "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9" /
            "a" / "b" / "c" / "d" / "e" / "f" /
            "A" / "B" / "C" / "D" / "E" / "F"

So each byte, in our case, represents two hexDigits, which will include "0".

An example where this comes up:

009db818-af0a-42ad-8084-5b6faba5c24a
bcoe commented 3 years ago

@domenic forgotten 😝