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?
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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With