I need to uniquely identify a pair of Facebook
user ids. This is how I do that:
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); // both are equal
Ok, now I know that regardless the order in which the hashes are combined i'm getting the same value. That's good. But is this value guaranteed to be unique? Or it is possible that a combination of ids say 322233322
and 233322233
will produce the same value as for combinedHash
? If so then how do I make an unique identifier for a pair of ids?