Note that there are some explanatory texts on larger screens.

plurals
  1. PODecrypting 250MB PDF file
    text
    copied!<p>I have a 250Mb encrypted PDF file in my X-Code project, which I need to decrypt and display during run time. Since the file size is large, I can't decrypt it. So I split the original file into chunks of NSData, encrypted them into different part files. In the code, I am decrypting these multiple chunks and writing them into the same file and then displaying it. </p> <pre><code> NSData *decryptedData = [[NSData alloc] init]; NSString *thepath = [NSString stringWithFormat:@"%@/decryptedfile.%@",[paths objectAtIndex:0], fileType]; [decryptedData writeToFile:thepath atomically:YES]; [decryptedData release]; NSFileHandle *myFile = [NSFileHandle fileHandleForUpdatingAtPath:thepath]; [myFile truncateFileAtOffset:0]; for (int k=1; k&lt;50; k++) { //i had 49 parts, hence the condition NSString *partFilePath = [NSString stringWithFormat:@"%@/%@-part%d.pdf",[paths objectAtIndex:0], [fileName objectAtIndex:i], k]; NSData *tempDData = [[NSData alloc] initWithContentsOfFile:partFilePath]; [myFile writeData:[tempDData AES256DecryptWithKey:@"secretkey"]]; [tempDData release]; } [myFile closeFile]; </code></pre> <p>I had 49 parts, and am decrypting them each, writing them into a single file. This program runs fine in the simulator and am able to recover my original PDF. But on the device, my app gets terminated. Its getting terminated when the for loop iterates for the 31st time and when am trying write my decrypted data into the Documents folder of the app. In other words, when i try to add data more than 150MB, my app is terminated. Is there any other way i can implement this feature?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload