Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why lowercase uuid?

Tags:

uuid

swift

I’m considering using uuid to differentiate my swift app, and looked around online for how to achieve it. While searching, I often found people lowercase the uuid such as:

let uuid = NSUUID().UUIDString.lowercaseString

Wouldn’t lowercasing the uuid be unnecessary or make it less random?

like image 536
Bruce Avatar asked Jan 19 '18 02:01

Bruce


People also ask

Should UUID be upper or lower case?

Are UUIDs Case-sensitive? No, UUIDs are written in base 16 which uses numbers 0-9 and characters a-f. There is no distinction between upper and lowercase letters.

Are UUID always 36 characters?

A UUID is made up of hex digits (4 chars each) along with 4 “-” symbols, which make its length equal to 36 characters. The Nil UUID is a special form of UUID in which all bits are set to zero.

What is the format of a UUID?

UUIDs are constructed in a sequence of digits equal to 128 bits. The ID is in hexadecimal digits, meaning it uses the numbers 0 through 9 and letters A through F. The hexadecimal digits are grouped as 32 hexadecimal characters with four hyphens: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.

What characters are allowed in a UUID?

The 32 characters of a UUID are hexadecimals, or base-16 representation. Each character can be a digit 0 through 9, or letter a through f. 32 hexadecimals x log2(16) bits/hexadecimal = 128 bits in a UUID.


2 Answers

It is not less random, because UUIDs are not case-sensitive. UUIDs are 128-bit numbers, and in string form they are represented using hexadecimal digits. ‘A’ and ‘a’ are the same digit.

Standards such as ITU-T X.667 and RFC 4122 require them to be formatted using lower-case letters, but also require parsers to accept upper-case letters.

The NSUUID class and UUID struct use upper-case letters when formatting. Long ago, someone either got it wrong, or made the decision before the choice of lower-case letters was standardized. Apple won't change it now because doing so could break existing code that relies on the use of upper-case letters.

On Apple platforms, the UUID formatting code, unparse.c, is written in C, and (according to the copyright) was originally written by Theodore T'so in 1996 or 1997. But the code uses upper-case letters because UUID_UNPARSE_DEFAULT_UPPER is defined in uuid-config.h.

like image 143
rob mayoff Avatar answered Nov 16 '22 01:11

rob mayoff


Because it is required by international standards

You may find the information here

6.5.4 Software generating the hexadecimal representation of a UUID shall not use upper case letters. NOTE – It is recommended that the hexadecimal representation used in all human-readable formats be restricted to lower-case letters.

like image 28
Developer Avatar answered Nov 16 '22 01:11

Developer