Search code examples
cryptographyuuid

Is UUID without dashes/hyphens valid?


I want to write simple regex to validate UUIDs, but I'm not sure about this small detail.

Wikipedia states:

UUID is represented by 32 lowercase hexadecimal digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 alphanumeric characters and four hyphens).

But couldn't find anything like it in RFC spec document.

So the question remains whether this UUID is valid: f47ac10b58cc4372a5670e02b2c3d479?


Solution

  • The production in RFC 4122 (section 3, page 4), defines UUID string representation as

    UUID = time-low "-" time-mid "-"
           time-high-and-version "-"
           clock-seq-and-reserved
           clock-seq-low "-" node
    

    where each internal component is hex-encoded.

    Therefore, f47ac10b58cc4372a5670e02b2c3d479 is not a valid UUID representation.