How to generate a valid UUID v4 that starts with specific characters?
Suppose I want to generate UUID v4 that starts with 00
– short of looping through random UUIDs until I get UUID that starts with 00
, is there a better way of doing it?
You can just remove the first two characters of a generated UUID and prepend "00"
in its place.
console.log('00' + crypto.randomUUID().slice(2));