Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 394
Karol Avatar asked Jun 30 '14 01:06

Karol


People also ask

Do UUIDs need hyphens?

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).

Can I remove dashes from UUID?

In UUIDs, that number is 128 bits long and is written in hexadecimal, so unlike a phone number it's less “obviously” a number, but the basic principle is the same. Deleting the dashes won't change the number and thus won't impact security.

How many unique UUIDs are there?

As per Wikipedia, the number of UUIDs generated to have atleast 1 collision is 2.71 quintillion.

How long is an UUID?

Universally Unique Identifiers, or UUIDS, are 128 bit numbers, composed of 16 octets and represented as 32 base-16 characters, that can be used to identify information across a computer system. This specification was originally created by Microsoft and standardized by both the IETF and ITU.


1 Answers

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.

like image 119
Oleg Estekhin Avatar answered Oct 16 '22 19:10

Oleg Estekhin