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.
@RobertoMachorro Just ensuring the random numbers come from a crypto source instead of Math.random(). It's definitely slower than molasses though, lol. I think the OP stopped once it hit the point of basically not being able to golf it much more and a spec-compliant version was posted.