Returns a random v4 UUID of the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
, where each x
is replaced with a random hexadecimal digit from 0 to f, and y
is replaced with a random hexadecimal digit from 8 to b.
There's also @LeverOne's approach using iteration, which is one byte shorter.
That's because it's not part of the spec, it's part of the genius of @subzey. Look at the string that's being replaced
0
and1
(1
is used as the head of a segment to prevent truncation),8
, which is special cased with the^
operation to clamp it to the proper values, but not4
, which cannot be replaced because it specifies the version in the spec.