Hacker News new | ask | show | jobs
by gzread 99 days ago
How's your UUIDv4 generated?

> Are you sure the way you're serializing it is how the remote system will deserialize it?

It's 16 bytes. There's no serialization.

3 comments

What do they look like when I put it in a url?
Use whatever encoding you want? Base64 is probably one of the most practical, but you're not obligated to use that.
UUIDs don't use base64
You can absolutely encode a UUID in base64, as you can any string of 128 bits.
128 random bits in some random format aren't a uuid. 0.2ml of water isn't a raindrop. If I say "you can provide me with a uuid" and you give me a base64-encoded string, it's getting rejected by validation. If I say "this text needs to be a Unicode string" and you give me a base64-encoded Unicode string's byte array, it's not going to go well.
Why are you implying that converting from base64 to and from standard UUID representation (hyphen-delimited hexadecimal) is more than a trivial operation? Either client or server can do this at any point.

Does Postgres not truly support UUID because it internally represents it as 128 bits instead of a huge number of encoded bytes in the standard representation? Of course not.

> There's no serialization.

Hex encoding with hyphens in the right spot isn't serialization?

Vibe endian
Schrodinger's complement