Convert short piece of code from Objective C to Swift 3
$10-30 USD
Pagado a la entrega
I need the code below from [login to view URL]
converted from Objective C to Swift
/*
In iOS, use the value returned by the identifierForVendor property of UIDevice as the computer’s GUID.
To compute the hash, first concatenate the GUID value with the opaque value (the attribute of type 4) and the bundle identifier. Use the raw bytes from the receipt without performing any UTF-8 string interpretation or normalization. Then compute the SHA-1 hash of this concatenated series of bytes.
*/
NSUUID *vendorIdentifier = [[UIDevice currentDevice] identifierForVendor];
uuid_t uuid;
[vendorIdentifier getUUIDBytes:uuid];
NSData *vendorData = [NSData dataWithBytes:uuid length:16];
// concacentate data for vendor identifier, opaque value and bundle identifier
NSMutableData *hashData = [NSMutableData new];
[hashData appendData:vendorData];
[hashData appendData:[login to view URL]];
[hashData appendData:[login to view URL]];
// calculate SHA1
NSData *hash = [hashData dataWithSHA1Hash];
if (![hash isEqualToData:[login to view URL]])
{
DTLogDebug(@"Incorrect SHA1 hash in receipt");
return YES;
}
Nº del proyecto: #12749380