title: Why my AES 256 decrypt method not working iOS 14
body: <p>I'm trying to decrypt a string value from JSON using AES 256 method after get the backend response, each value are parsing properly but when I try decrypt the string value encrypted, my method always return null, the JSON response is:</p>
  <pre><code>dataResponseString: {
  &quot;subjects&quot;: [
      {
          &quot;name&quot;: &quot;test1&quot;,
          &quot;version&quot;: 1,
          &quot;createdAt&quot;: &quot;2021-05-12T03:15:12.741Z&quot;,
          &quot;createdBy&quot;: &quot;dmostajo&quot;,
          &quot;subject&quot;: &quot;WLSdQGDlb2CbBtKoK/ukbYv1HOl5ZVZo9P5VRV9426GMurhKD5o7U53MfvYaLmogJCYz32s8uz4B0HxBawlph3sgfdDieA3Lxh8D4WLLXqwY2psVasukKV1HTR9Jst1cI3O/vorvheSRvBb4JZQYotmhVPsjEkSc2xJ5ewyBCL0uv3VRWwe4qhB94Q1F/EowW5s3aH9CRlf/H9hJg1ougyX1ZL02OydMrFMXCwZSALHKLT6kCase/oHTTGyuDvs8xzLk3QSBiUO2G9ppeXmRxYB/sPAFpDI8eV2T5/O+xlIP/LLE/eyKe+wEfxWlKG1uAwiVhfrHmFMueRG7Hv6DJ/s63M2o3vziB6zfX832rQc=&quot;
      },
      {
          &quot;name&quot;: &quot;test2&quot;,
          &quot;version&quot;: 1,
          &quot;createdAt&quot;: &quot;2021-04-15T16:16:35.206Z&quot;,
          &quot;createdBy&quot;: &quot;dmostajo&quot;,
          &quot;subject&quot;: &quot;WLSdQGDlb2CbBtKoK/ukbc1429tOxdpzEE6W/leNEoWJCIzf+R7D6u+FSu1JDXgIGiF5pgh5BJQK3yNJVYxLYsaL3kpP2yL2ALPILY6WdWBA/GJFo3s6Y0rMeEh4UBkb/yDNqbZhK2hrn3e+zvFQYG6i0+rE3rhXkTlRcRWmXB0JRTg7pTt2BtNOe+CynG3SgwowYv+R/244Ab6z/Tg+ejKs41wrKCJcBsiU5Yl18oUCeiycmQYtgRoX+yz2o5X1F/arIDi2pdCBIIS1n7sII+woRL2C0o9N5YJl3zzWnF0RwxmkSPKz7j71+sHO4OIGw+tiaKPDTfQf3K0ViQezEVHO9jAxPglkcEtMm5T1A/dWSTZQv4HjAwQ8ZjmZ5Y25Qki7oQgNStyKPxHafINj8g==&quot;
      }
  ]
  </code></pre>
  <p>}</p>
  <p>and whole code that I'm using is:</p>
  <ul>
  <li>To get response from backend:</li>
  </ul>
  <pre><code>-(void)getSubjects
  {
      NSLog(@&quot;Decoding AccessToken:%@&quot;,[JWTDecoder decodeJWTToken:[[NSUserDefaults standardUserDefaults] objectForKey:@&quot;access_token&quot;]]);
      NSString *strAuthHeader = [NSString stringWithFormat:@&quot;Bearer %@&quot;,[[NSUserDefaults standardUserDefaults] objectForKey:@&quot;access_token&quot;]];
      NSDictionary *authHeaders = @{ @&quot;authorization&quot;: strAuthHeader };
      NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@&quot;https://myclientservertest/api/v2/subjects&quot;]              cachePolicy:NSURLRequestUseProtocolCachePolicy
          timeoutInterval:10.0];
      [request setHTTPMethod:@&quot;GET&quot;];
      [request setAllHTTPHeaderFields:authHeaders];
      NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
      NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
      NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
      completionHandler:^(NSData *data, NSURLResponse *responseAuth, NSError *error)
      {
          if (error)
          {
              dispatch_async(dispatch_get_main_queue(),
              ^{
                  [NLCCommonViewController showAlert:ERR_NETWORK];
              });
          }
          else
          {
              NSString *dataResponseString= [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
              NSLog(@&quot;responseAuth:%@&quot;,responseAuth);
              NSLog(@&quot;dataResponseString:%@&quot;,dataResponseString);
              if([(NSHTTPURLResponse *)responseAuth statusCode] == 200)
              {
                  NSError *errorJson;
  //                NSData *data = [dataResponseString dataUsingEncoding:NSUTF8StringEncoding];
                  NSDictionary *json =[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&amp;errorJson];
                  NSMutableArray *subjects = [json objectForKey:@&quot;subjects&quot;];
                  for (NSMutableDictionary * dict in subjects)
                  {
                      NSString *appName = [dict valueForKey:@&quot;name&quot;];
                      NSString *version = [dict valueForKey:@&quot;version&quot;];
                      NSString *createdAt = [dict valueForKey:@&quot;createdAt&quot;];
                      NSString *createdBy = [dict valueForKey:@&quot;createdBy&quot;];
                      NSString *subject = [dict valueForKey:@&quot;subject&quot;];
                      NSLog(@&quot;subject:%@&quot;,subject);
                      NSString *secret =[self md5:[NSString stringWithFormat:@&quot;%@:CLIENT_VALUE&quot;,createdBy]];
                      NSData *subjectData = [[NSData alloc] initWithBase64EncodedString:subject options:0];
                      NSString *decrypted = [CustomAESHelper decryptData:subjectData withKey:secret];
                      NSLog(@&quot;decrypted:%@&quot;,decrypted);
                  }
              }
              else
              {
                  
              }
          }
      }];
      [dataTask resume];
  }
  </code></pre>
  <ul>
  <li>The md5 method is working properly:</li>
  </ul>
  <pre><code>- (NSString*)md5:(NSString*)str {
      NSString *salt = @&quot;&quot;;
      NSString *strWithSalt = [NSString stringWithFormat:@&quot;%@%@&quot;,str,salt];
      const char *cStr = [strWithSalt UTF8String];
      unsigned char result[CC_MD5_DIGEST_LENGTH];
      CC_MD5( cStr, (CC_LONG) strlen(cStr), result );
      return [[NSString stringWithFormat:@&quot;%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X&quot;,
               result[0], result[1],
               result[2], result[3],
               result[4], result[5],
               result[6], result[7],
               result[8], result[9],
               result[10], result[11],
               result[12], result[13],
               result[14], result[15]
               ] lowercaseString];
  }
  </code></pre>
  <ul>
  <li>The AES Helper:</li>
  </ul>
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import &lt;CommonCrypto/CommonCryptor.h&gt;
  
  @interface CustomAESHelper : UIViewController
  
  + (NSString*) encryptString:(NSString*)plaintext withKey:(NSString*)key;
  + (NSString*) encryptNSMutableArray:(NSMutableArray *)mutableArray withKey:(NSString *)key;
  + (NSString*) decryptData:(NSData*)ciphertext withKey:(NSString*)key;
  
  @end
  </code></pre>
  <pre><code>#import &quot;CustomAESHelper.h&quot;
  @implementation NSData (AESAdditions)
  - (NSData *)AES256EncryptWithKey:(NSString *)key {
      // 'key' should be 32 bytes for AES256, will be null-padded otherwise
      char keyPtr[kCCKeySizeAES256+1]; // room for terminator (unused)
      bzero(keyPtr, sizeof(keyPtr)); // fill with zeroes (for padding)
      
      // fetch key data
      [key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
      
      NSUInteger dataLength = [self length];
      
      //See the doc: For block ciphers, the output size will always be less than or
      //equal to the input size plus the size of one block.
      //That's why we need to add the size of one block here
      size_t bufferSize = dataLength + kCCBlockSizeAES128;
      void *buffer = malloc(bufferSize);
      
      size_t numBytesEncrypted = 0;
      CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding,
                                            keyPtr, kCCKeySizeAES256,
                                            NULL /* initialization vector (optional) */,
                                            [self bytes], dataLength, /* input */
                                            buffer, bufferSize, /* output */
                                            &amp;numBytesEncrypted);
      if (cryptStatus == kCCSuccess) {
          //the returned NSData takes ownership of the buffer and will free it on deallocation
          return [NSData dataWithBytesNoCopy:buffer length:numBytesEncrypted];
      }
      
      free(buffer); //free the buffer;
      return nil;
  }
  
  - (NSData *)AES256DecryptWithKey:(NSString *)key {
      // 'key' should be 32 bytes for AES256, will be null-padded otherwise
      char keyPtr[kCCKeySizeAES256+1]; // room for terminator (unused)
      bzero(keyPtr, sizeof(keyPtr)); // fill with zeroes (for padding)
  
      // fetch key data
      [key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
  
      NSUInteger dataLength = [self length];
  
      //See the doc: For block ciphers, the output size will always be less than or
      //equal to the input size plus the size of one block.
      //That's why we need to add the size of one block here
      size_t bufferSize = dataLength + kCCBlockSizeAES128;
      void *buffer = malloc(bufferSize);
  
      size_t numBytesDecrypted = 0;
      CCCryptorStatus cryptStatus = CCCrypt(kCCDecrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding,
                                            keyPtr, kCCKeySizeAES256,
                                            NULL /* initialization vector (optional) */,
                                            [self bytes], dataLength, /* input */
                                            buffer, bufferSize, /* output */
                                            &amp;numBytesDecrypted);
  
      if (cryptStatus == kCCSuccess) {
          //the returned NSData takes ownership of the buffer and will free it on deallocation
          return [NSData dataWithBytesNoCopy:buffer length:numBytesDecrypted];
      }
  
      free(buffer); //free the buffer;
      return nil;
  }
  
  @end
  
  @interface CustomAESHelper ()
  
  @end
  
  @implementation CustomAESHelper
  + (NSString*) encryptString:(NSString*)plaintext withKey:(NSString*)key {
       NSData *JSONData =  [[plaintext dataUsingEncoding:NSUTF8StringEncoding] AES256EncryptWithKey:key];
      
      // Get NSString from NSData object in Base64
      NSString *base64Encoded = [JSONData base64EncodedStringWithOptions:0];
  //    NSLog(@&quot;encryptString = %@&quot;,base64Encoded);
  //    NSLog(@&quot;encryptString = %@&quot;,[[NSString alloc] initWithData:JSONData
  //                                                      encoding:NSUTF8StringEncoding]);
  //    
  //    
  // NSLog(@&quot;decryptData = %@&quot;,[self decryptData:JSONData withKey:key]);
    return base64Encoded;
      
  }
  
  + (NSString*) encryptNSMutableArray:(NSMutableArray *)mutableArray withKey:(NSString *)key
  {
      NSData *data = [[NSKeyedArchiver archivedDataWithRootObject:mutableArray]AES256EncryptWithKey:key];
     
     // Get NSString from NSData object in Base64
     NSString *base64Encoded = [data base64EncodedStringWithOptions:0];
  //    NSLog(@&quot;encryptString = %@&quot;,base64Encoded);
  //    NSLog(@&quot;encryptString = %@&quot;,[[NSString alloc] initWithData:JSONData
  //                                                      encoding:NSUTF8StringEncoding]);
  //
  //
  // NSLog(@&quot;decryptData = %@&quot;,[self decryptData:JSONData withKey:key]);
   return base64Encoded;
  }
  
  + (NSString*) decryptData:(NSData*)ciphertext withKey:(NSString*)key {
      
      return [[NSString alloc] initWithData:[ciphertext AES256DecryptWithKey:key]
                                    encoding:NSUTF8StringEncoding] ;
  }
  
  @end
  </code></pre>
  <ul>
  <li>And Logs shows:</li>
  </ul>
  <pre><code>2021-05-14 12:13:06.806259-0400 MyProjects[1609:814424] subject:WLSdQGDlb2CbBtKoK/ukbYv1HOl5ZVZo9P5VRV9426GMurhKD5o7U53MfvYaLmogJCYz32s8uz4B0HxBawlph3sgfdDieA3Lxh8D4WLLXqwY2psVasukKV1HTR9Jst1cI3O/vorvheSRvBb4JZQYotmhVPsjEkSc2xJ5ewyBCL0uv3VRWwe4qhB94Q1F/EowW5s3aH9CRlf/H9hJg1ougyX1ZL02OydMrFMXCwZSALHKLT6kCase/oHTTGyuDvs8xzLk3QSBiUO2G9ppeXmRxYB/sPAFpDI8eV2T5/O+xlIP/LLE/eyKe+wEfxWlKG1uAwiVhfrHmFMueRG7Hv6DJ/s63M2o3vziB6zfX832rQc=
  2021-05-14 12:13:06.809211-0400 MyProjects[1609:814424] decrypted:(null)
  2021-05-14 12:13:06.809757-0400 MyProjects[1609:814424] subject:WLSdQGDlb2CbBtKoK/ukbc1429tOxdpzEE6W/leNEoWJCIzf+R7D6u+FSu1JDXgIGiF5pgh5BJQK3yNJVYxLYsaL3kpP2yL2ALPILY6WdWBA/GJFo3s6Y0rMeEh4UBkb/yDNqbZhK2hrn3e+zvFQYG6i0+rE3rhXkTlRcRWmXB0JRTg7pTt2BtNOe+CynG3SgwowYv+R/244Ab6z/Tg+ejKs41wrKCJcBsiU5Yl18oUCeiycmQYtgRoX+yz2o5X1F/arIDi2pdCBIIS1n7sII+woRL2C0o9N5YJl3zzWnF0RwxmkSPKz7j71+sHO4OIGw+tiaKPDTfQf3K0ViQezEVHO9jAxPglkcEtMm5T1A/dWSTZQv4HjAwQ8ZjmZ5Y25Qki7oQgNStyKPxHafINj8g==
  2021-05-14 12:13:06.811011-0400 MyProjects[1609:814424] decrypted:(null)
  </code></pre>
  <p>Is the first time that I'm working with this method encryption, the encrypt method working properly too, the strange issue that I have is on decrypt method, or am I doing some wrong missing some detail or something, I saw many answers and questions, or how can I convert the string value from JSON to NSData as cypher data properly? or which are your recommendations please, thanks!</p>
  <p>UPDATE 1:</p>
  <p>Reviewing, when I copy the subject string directly to decrypt without parsing the decrypt method are working properly:</p>
  <pre><code>NSString *test = @&quot;oTd6+L9Lt/cWCMUPE1XvqSrTA9orCIPTWGNqbCw55SJzvB0mmFBqZfFI7pmqy7MdPc8AhSrFDFXsCjR6O+GOhGcYV3punTShjynSREI863449fzED7I/Y9vZFQr3CB3Hfbw/fEXfCEorCXhlI703GWOT4be68pPpayLus1bZuLXUT4iek1P/Gj94UH0GaNQJZFT8lwywZ34mzPt7YfnqK2X4Amj2ebKCx9uoEcJM5wL96yqdf1vZIhxsWO2EujcZmpMU238DhhjmqUIYUg0rk9sKHbNww41MrTZgSDutWDM67OiT5SyHZZ+Dw8VdamISjJgiyQGQkbfRzJNGKYZlacy10bSeWJrOgXo/c7UN/FDvP/QZJXvJX0pJbeP3JZRyyk8Az+xg1RAukuEcRot0AEy4tDDg2F9X5V/gfWtMVhceDvecc+SlnL5lkT2Kw8sc3Vcx/In270C+t6slxxAkLa24AnBVGEUNxMAtwCq1veBZE6FBlEVdoamE1yLstFI44Qma3a8pUQVvqw1tncadZQrRSkzYIdJTTK1xxJ1biyoG2VXlX51WCl+W6DDaxkNnG4WVwIBpoEkG64j5b6eB0kuIgJDMUJKAtxX8FeGo4bEjKZZY5tV81XS1e/AwNsmcDtwnT6+DQDw41AW2tQQGzH/NgCphUJbN/GQ+4H5vs4k5fCXYRBrO9wJecuoxZXU3gjI69j7w/r5iL5Nkvz5a2h8jX4AsNSGTwCsaIVGP8/ozI7KiCLlHVB956816Cit3LSW3hOP1cKUfvTY8Ibxln0Q5EUzRryOC3J3hCPAop7CC1o4U0i1wvSRkjl9k2mSV1hBo16k6mGAVd35czo6NQaopZYTnDq6aJU2HhZIzlfV7jKRNoz81imO5QRqEEETvd6xEqkG7KhA7MmZhJAO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Base64EncodedString:test options:kNilOptions];
  NSLog(@&quot;dataTest: %@&quot;, dataTest);
  NSString *decryptTest = [CustomAESHelper decryptData:dataTest withKey:secret];
  NSLog(@&quot;decryptTest: %@&quot;, decryptTest);
  </code></pre>
  <pre><code>2021-05-15 20:33:05.424858-0400 MyProjects[2003:1228662] subject:WLSdQGDlb2CbBtKoK/ukbc1429tOxdpzEE6W/leNEoWJCIzf+R7D6u+FSu1JDXgIGiF5pgh5BJQK3yNJVYxLYsaL3kpP2yL2ALPILY6WdWBA/GJFo3s6Y0rMeEh4UBkb/yDNqbZhK2hrn3e+zvFQYG6i0+rE3rhXkTlRcRWmXB0JRTg7pTt2BtNOe+CynG3SgwowYv+R/244Ab6z/Tg+ejKs41wrKCJcBsiU5Yl18oUCeiycmQYtgRoX+yz2o5X1F/arIDi2pdCBIIS1n7sII+woRL2C0o9N5YJl3zzWnF0RwxmkSPKz7j71+sHO4OIGw+tiaKPDTfQf3K0ViQezEVHO9jAxPglkcEtMm5T1A/dWSTZQv4HjAwQ8ZjmZ5Y25Qki7oQgNStyKPxHafINj8g==
  2021-05-15 20:33:05.425797-0400 MyProjects[2003:1228662] dataSubject: {length = 304, bytes = 0x58b49d40 60e56f60 9b06d2a8 2bfba46d ... 8a3f11da 7c8363f2 }
  2021-05-15 20:33:05.425917-0400 MyProjects[2003:1228662] decryptSubject: (null)
  2021-05-15 20:33:05.426105-0400 MyProjects[2003:1228662] dataTest: {length = 3904, bytes = 0xa1377af8 bf4bb7f7 1608c50f 1355efa9 ... 5c446baf 5fe1e366 }
  2021-05-15 20:33:05.426219-0400 MyProjects[2003:1228662] decryptTest: [{&quot;position&quot;:0,&quot;shortName&quot;:&quot;Dan&quot;,&quot;class&quot;:&quot;Stakeholder&quot;,&quot;objectId&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Stakeholder\/p2&quot;,&quot;project&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Project\/p1&quot;,&quot;rank&quot;:2,&quot;projects&quot;:[&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Project\/p1&quot;]},{&quot;position&quot;:0,&quot;shortName&quot;:&quot;Mark&quot;,&quot;class&quot;:&quot;Stakeholder&quot;,&quot;objectId&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Stakeholder\/p1&quot;,&quot;project&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Project\/p1&quot;,&quot;rank&quot;:1,&quot;projects&quot;:[&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Project\/p1&quot;]},{&quot;position&quot;:0,&quot;project&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Project\/p1&quot;,&quot;objectId&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Implication\/p2&quot;,&quot;class&quot;:&quot;Implication&quot;,&quot;name&quot;:&quot;aes256 decrypt&quot;,&quot;onLeft&quot;:0},{&quot;position&quot;:0,&quot;project&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Project\/p1&quot;,&quot;objectId&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Implication\/p1&quot;,&quot;class&quot;:&quot;Implication&quot;,&quot;name&quot;:&quot;aes256 encrypt&quot;,&quot;onLeft&quot;:1},{&quot;position&quot;:0,&quot;project&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Project\/p1&quot;,&quot;objectId&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Experience\/p2&quot;,&quot;class&quot;:&quot;Experience&quot;,&quot;name&quot;:&quot;Trying test all options&quot;,&quot;onLeft&quot;:0},{&quot;position&quot;:0,&quot;project&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Project\/p1&quot;,&quot;objectId&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Experience\/p1&quot;,&quot;class&quot;:&quot;Experience&quot;,&quot;name&quot;:&quot;Test Dan code&quot;,&quot;onLeft&quot;:1},{&quot;position&quot;:0,&quot;task&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Task\/p2&quot;,&quot;class&quot;:&quot;Resource&quot;,&quot;objectId&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Resource\/p2&quot;,&quot;project&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Project\/p1&quot;,&quot;longDescription&quot;:&quot;&quot;,&quot;type&quot;:&quot;task&quot;,&quot;name&quot;:&quot;Check StackOverflow&quot;},{&quot;resourceCollapsed&quot;:1,&quot;position&quot;:0,&quot;project&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Project\/p1&quot;,&quot;dueDate&quot;:&quot;&quot;,&quot;completed&quot;:&quot;&quot;,&quot;type&quot;:&quot;task&quot;,&quot;completedDate&quot;:&quot;&quot;,&quot;resources&quot;:[&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Resource\/p2&quot;],&quot;longDescription&quot;:&quot;&quot;,&quot;objectId&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Task\/p2&quot;,&quot;class&quot;:&quot;Task&quot;,&quot;name&quot;:&quot;Test new libraries&quot;,&quot;calendarReference&quot;:&quot;&quot;},{&quot;position&quot;:1,&quot;task&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Task\/p1&quot;,&quot;class&quot;:&quot;Resource&quot;,&quot;objectId&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Resource\/p1&quot;,&quot;project&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Project\/p1&quot;,&quot;longDescription&quot;:&quot;&quot;,&quot;type&quot;:&quot;barrier&quot;,&quot;name&quot;:&quot;Still trying fixing ASAP&quot;},{&quot;resourceCollapsed&quot;:1,&quot;position&quot;:1,&quot;project&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Project\/p1&quot;,&quot;dueDate&quot;:&quot;&quot;,&quot;completed&quot;:&quot;&quot;,&quot;type&quot;:&quot;barrier&quot;,&quot;completedDate&quot;:&quot;&quot;,&quot;resources&quot;:[&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Resource\/p1&quot;],&quot;longDescription&quot;:&quot;&quot;,&quot;objectId&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Task\/p1&quot;,&quot;class&quot;:&quot;Task&quot;,&quot;name&quot;:&quot;Without success until yet&quot;,&quot;calendarReference&quot;:&quot;&quot;},{&quot;tasks&quot;:[&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Task\/p2&quot;,&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Task\/p1&quot;],&quot;intentions&quot;:&quot;Test AES 256 with help of DAN&quot;,&quot;resources&quot;:[&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Resource\/p2&quot;,&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Resource\/p1&quot;],&quot;class&quot;:&quot;Project&quot;,&quot;objectId&quot;:&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Project\/p1&quot;,&quot;implications&quot;:[&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Experience\/p2&quot;,&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Experience\/p1&quot;],&quot;stakeholders&quot;:[&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Stakeholder\/p2&quot;,&quot;x-coredata:\/\/6ABAC2F1-A324-4CA6-8966-D410039C7626\/Stakeholder\/p1&quot;],&quot;date&quot;:&quot;2021-05-14 22:16:26 +0000&quot;,&quot;name&quot;:&quot;Test 3 AES 256&quot;,&quot;objective&quot;:&quot;Test 3&quot;}]
  </code></pre>
  <p>So any help to get the properly string from JSON data response? am I doing some wrong parsing JSON with the encrypted value?</p>