1

My app receives encrypted data from a GET request. I'm having a problem decrypting the data. I'm using the cross-platform CryptLib Library, CryptLib. Followed the documentation in the CryptLib.m but nothing seems to work. If anyone has some knowledge of CryptLib, some guidance would be much appreciated, Please see my code below.

Code

[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:
  ^(NSData * _Nullable encryptedData,
    NSURLResponse * _Nullable response,
    NSError * _Nullable error) {
      //has data
      NSString *jsonData = [[NSString alloc] initWithData:encryptedData encoding:NSUTF8StringEncoding];
      NSLog(@"Data received: %@", jsonData);


      NSString *key = @"3HS5UtP7hEc5Jsqg7P4KDQEH2y95v92Z";
      NSString *iv = @"ZkjH27Rh63RQtH8y";

    //Decrypted data is NULL!
      encryptedData = [[StringEncryption alloc] decrypt:encryptedData  key:key iv:iv];
      NSString * decryptedText = [[NSString alloc] initWithData:encryptedData encoding:NSUTF8StringEncoding];
      NSLog(@"decrypted data:: %@", decryptedText); //print the decrypted text


  }] resume];
YosiFZ
  • 7,792
  • 21
  • 114
  • 221
astric mobiles
  • 468
  • 3
  • 14

0 Answers0