Reputation: 4295
I'd like to use the PostgreSQL function gen_random_uuid()
from pgcrypto to generate application tokens (API keys). Will these be sufficiently random?
Upvotes: 0
Views: 525
Reputation: 32274
The gen_random_uuid()
function produces a standard version 4 UUID. That gives you 122 bits of randomness which is about as good as it gets: "only after generating 1 billion UUIDs every second for the next 100 years, the probability of creating just one duplicate would be about 50%".
Upvotes: 4