Permalink
Browse files

Now using CFUUIDCreate as the seed for newly generated OpenUDID

Voted by the community as a better alternative to [[NSProcessInfo
processInfo] globallyUniqueString]
  • Loading branch information...
1 parent c46a42e commit f0287087da47aba2bffcefd05bba3f4a7ee3b399 @ylechelle committed May 30, 2012
Showing with 13 additions and 4 deletions.
  1. +13 −4 OpenUDID.m
View
@@ -121,14 +121,23 @@ + (NSString*) _generateFreshOpenUDID {
// _openUDID = [[UIDevice currentDevice] uniqueIdentifier];
// }
#endif
- // Next we try to use an alternative method which uses the host name, process ID, and a time stamp
- // We then hash it with md5 to get 32 bytes, and then add 4 extra random bytes
- // Collision is possible of course, but unlikely and suitable for most industry needs (e.g.. aggregate tracking)
+ // Next we generate a UUID.
+ // UUIDs (Universally Unique Identifiers), also known as GUIDs (Globally Unique Identifiers) or IIDs
+ // (Interface Identifiers), are 128-bit values guaranteed to be unique. A UUID is made unique over
+ // both space and time by combining a value unique to the computer on which it was generated—usually the
+ // Ethernet hardware address—and a value representing the number of 100-nanosecond intervals since
+ // October 15, 1582 at 00:00:00.
+ // We then hash this UUID with md5 to get 32 bytes, and then add 4 extra random bytes
+ // Collision is possible of course, but unlikely and suitable for most industry needs (e.g. aggregate tracking)
//
if (_openUDID==nil) {
+ CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
+ CFStringRef cfstring = CFUUIDCreateString(kCFAllocatorDefault, uuid);
@samsonjs

samsonjs Sep 17, 2012

I believe this cfstring variable should be released along with uuid a couple of lines later. Xcode reports it as a leak.

@ylechelle

ylechelle via email Sep 18, 2012

Owner
+ const char *cStr = CFStringGetCStringPtr(cfstring,CFStringGetFastestEncoding(cfstring));
unsigned char result[16];
- const char *cStr = [[[NSProcessInfo processInfo] globallyUniqueString] UTF8String];
CC_MD5( cStr, strlen(cStr), result );
+ CFRelease(uuid);
+
_openUDID = [NSString stringWithFormat:
@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%08x",
result[0], result[1], result[2], result[3],

0 comments on commit f028708

Please sign in to comment.