Convert short piece of code from Objective C to Swift 3

  • Estado Completado
  • Presupuesto $10 - $30 USD
  • Total de ofertas 3

Descripción del proyecto

I need the code below from [url removed, login to view]

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:[url removed, login to view]];

[hashData appendData:[url removed, login to view]];

// calculate SHA1

NSData *hash = [hashData dataWithSHA1Hash];

if (![hash isEqualToData:[url removed, login to view]])

{

DTLogDebug(@"Incorrect SHA1 hash in receipt");

return YES;

}

Obtén cotizaciones gratis para un proyecto como este
Completado por:
Habilidades necesarias

¿Buscas ganar algo de dinero?

  • Fija tu plazo y presupuesto
  • Describe tu propuesta
  • Recibes pagos por tu trabajo

Contrata Freelancers que también oferten en este proyecto

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online