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.
Can anyone explain the reasoning behind what seems rather arbitrary, in the replacing only 0s, 1s, and 8s with random hex digits, and not, for example, replacing all numbers with such digits? I'm sure I missed some detail that explains it.