upvote
Well that depends on your luck, it could be a valid one about 1/16th of the time.
reply
1/64, actually, because RFC-compliant (variant 1) UUIDv4 requires fixed values for both the version nibble and two bits of the variant nibble.

The fact that we're discussing this at all is a reasonable argument for using a library function.

reply
While it might be invalid, will most libraries choke if you give them a pseudo UUIDv4?
reply
Nice, thanks and I agree.
reply
I didn't say about 16 random bytes. But you're almost there. You generate 16 random bytes and perform few bitwise operations to set version and variant bits correctly.

Not that it matters. I don't even think that there's a single piece of software in the world which would actually care about these bits rather than treating the whole byte array as opaque thing.

reply
Let's call it a valid UUIDv0 - all bits randomized including the version bits :)
reply
What if I generate 16 random bytes and use that as id?
reply
No problem, just don't call it UUID
reply