Comments (2)
Are you using the latest version? The identifier is indeed 36 chars, see the code below:
+ (NSString*) _generateFreshOpenUDID {
NSString* _openUDID = nil;
// August 2011: One day, this may no longer be allowed in iOS. When that is, just comment this line out.
// March 25th 2012: this day has come, let's remove this "outlawed" call...
#if TARGET_OS_IPHONE
// if([UIDevice instancesRespondToSelector:@selector(uniqueIdentifier)]){
// _openUDID = [[UIDevice currentDevice] uniqueIdentifier];
// }
#endif
// 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);
const char *cStr = CFStringGetCStringPtr(cfstring,CFStringGetFastestEncoding(cfstring));
unsigned char result[16];
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],
result[4], result[5], result[6], result[7],
result[8], result[9], result[10], result[11],
result[12], result[13], result[14], result[15],
arc4random() % 4294967295];
}
// Call to other developers in the Open Source community:
//
// feel free to suggest better or alternative "UDID" generation code above.
// NOTE that the goal is NOT to find a better hash method, but rather, find a decentralized (i.e. not web-based)
// 160 bits / 20 bytes random string generator with the fewest possible collisions.
//
return _openUDID;
}
from openudid.
No..i am using the code before this change is been done ( commented the //
_openUDID = [[UIDevice currentDevice] uniqueIdentifier]; // } ).
But the point is there must be other apps also which will be using the
older code and hence generating 40 char id. And when my app tries to read
it, 40 char id id being returned. Because code is trying to read the value
stored by other apps and if not found then only generate..am i correct?
Please suggest if my understanding is wrong..
Thanks a lot...
On Jun 20, 2012 4:40 PM, "Yann Lechelle" <
[email protected]>
wrote:
Are you using the latest version? The identifier is indeed 36 chars, see
the code below:+ (NSString*) _generateFreshOpenUDID { NSString* _openUDID = nil; // August 2011: One day, this may no longer be allowed in iOS. When that is, just comment this line out. // March 25th 2012: this day has come, let's remove this "outlawed" call... #if TARGET_OS_IPHONE // if([UIDevice instancesRespondToSelector:@selector (uniqueIdentifier)]){ // _openUDID = [[UIDevice currentDevice] uniqueIdentifier]; // } #endif // 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); const char *cStr = CFStringGetCStringPtr(cfstring,CFStringGetFastestEncoding(cfstring)); unsigned char result[16]; 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], result[4], result[5], result[6], result[7], result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15], arc4random() % 4294967295]; } // Call to other developers in the Open Source community: // // feel free to suggest better or alternative "UDID" generation code above. // NOTE that the goal is NOT to find a better hash method, but rather, find a decentralized (i.e. not web-based) // 160 bits / 20 bytes random string generator with the fewest possible collisions. // return _openUDID; }
Reply to this email directly or view it on GitHub:
#35 (comment)
from openudid.
Related Issues (20)
- openUDID location
- Update podspec to current head HOT 2
- EXC_BAD_ACCESS on iOS6
- is OpenUDID support for IOS7 HOT 1
- OpenUDID doesn't work on iOS 7 HOT 1
- OpenUDID Crashed: com.apple.root.default-overcommit-priority,EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0xf16ea5a6
- OpenUDID Crashed
- Cannot remove OpenUDID from project HOT 1
- Why deprecate OpenUDID ? HOT 1
- 64-bit Apple recommendation HOT 1
- OpenUDID UIPasteboard in ios8 crashed HOT 2
- Crash In iOS 8.4.1
- NSUserDefaults has not been synchronized.
- crash in ios9.0、9.1、9.2 HOT 1
- [OpenUDID value] get value is NULL,I do not know why HOT 1
- crash with methed initWithErr
- Crashed with method +[OpenUDID valueWithError:], on iPhone 5s, iOS 10.1.1 HOT 5
- apple allow to get UDID after deployment?
- kOpenUDIDRedundancySlots=100
- I found that the appUID was not stored
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openudid.