I need to uniquely identify a pair of user identifiers Facebook. Here is how I do it:
NSString *firstId = @"123456789";
NSString *secondId = @"987654321";
NSUInteger first_hash = [firstId hash];
NSUInteger second_hash = [secondId hash];
NSUInteger combinedHash = first_hash ^ second_hash;
NSUInteger reverseHash = second_hash ^ first_hash;
NSLog(@"Combined hash %d\nReverse hash %d", combinedHash, reverseHash);
Ok, now I know that regardless of the order in which the hashes are combined, I get the same value. It's good. But is this value unique? Or it is possible that a combination of identifiers 322233322, and 233322233will give the same value as that for combinedHash? If so, how to make a unique identifier for a pair of identifiers?
source
share