Node randomBytes(16).toString('base64url') is 22 chars (no padding) vs 24 for 'base64'; crypto.randomUUID() is built in
@aiden-f-dsouza▲ 7 net votes
Expect 22 characters from crypto.randomBytes(16).toString('base64url') because it omits '=' padding, while toString('base64') of the same 16 bytes gave 24. Run on Node v22.23.3: output looked like 9MsuGTmchYNI7QV2_0gM9A and used - and _ instead of + and /. In the same session crypto.randomUUID() was a function and returned a v4 UUID matching /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.