Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8079225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:02:20+00:00 2026-06-05T16:02:20+00:00

This question is mainly about protecting the content inside my iOS app. I intend

  • 0

This question is mainly about protecting the content inside my iOS app. I intend to make an app that will download a lot of content (mainly PDF files) on user request. Once these PDFs are downloaded, they will be stored locally for easy offline access.

Now, I don’t want anyone to get hold of the .ipa file and manage to extract the PDF files.
If this is not possible, is it possible that even if they extract the PDFs, they canNOT view it or run them?

I am not sure how to handle this. Any suggestions are appreciated.

An alternative is, I may provide password protected files to the user to download. Store the associated password in a sqlite database. Then when the user opens the PDF from inside the APP, the app will find the password from the database and open it without any prompt to the user to enter the password. Is this possible? How?

Thanks and Regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:02:23+00:00Added an answer on June 5, 2026 at 4:02 pm

    Let’s assume that you somehow scramble your PDF before putting it on your download server and the app descrambles it before showing it to the user.

    In the app you can then perform the following:

    1. Load the scrambled PDF file into an NSData object.
    2. Make an NSMutableData object and descramble your PDF data into that buffer using whatever algorithm you have chosen.
    3. Now you have a usable PDF document in memory but only a scrambled version on disk. If you need to create a CGPDFDocumentRef you can do that by first creating a dataprovider using your descrambled NSMutableData object which is toll-free bridged to CFData by a simple cast

    Something like

    NSMutableData *data = descrambled PDF;
    CFDataRef myPDFData = (CFDataRef)data;
    CGDataProviderRef provider = CGDataProviderCreateWithCFData(myPDFData);
    CGPDFDocumentRef pdf = CGPDFDocumentCreateWithProvider(provider);
    

    (Credit for that snippet goes to this answer.)

    Since the app must be able to descramble the PDF and user has access to both the app and the scrambled PDF file anything you do to prevent them from extracting it will basically amount to security by obscurity. Therefore I wouldn’t bother with a complex encryption algorithm. You can probably just do something simple like XOR the data with a secret string hidden in your app binary.

    Defeating this approach will require an attacker to disassemble your binary, and if someone is that determined you can’t win, as evidenced by the sad state of current video game DRM.

    By the way: In the spirit of obscurity you might also want to name your scrambled downloaded PDFs something less obvious than valuabledocument.pdf. But real security it ain’t.

    Edit to illustrate XOR’ing data:

    Feed your scrambled NSData to something like this…

    // Fill this out with whatever you want. Use the same string
    // and algorithm to scramble the files on the server.
    static unsigned char secretString[SECRET_STRING_LENGTH];
    
    - (NSData *)scrambleOrDescrambleData:(NSData*)input
    {
        unsigned char *outputBytes = malloc(input.length);
        memcpy(outputBytes, input.bytes, input.length);
        for (int i = 0; i < input.length; i++)
        {
            outputBytes[i] = outputBytes[i] ^ secretString[i % SECRET_STRING_LENGTH];
        }
    
        NSData *outputData = [[NSData alloc] initWithBytes:outputBytes length:input.length];
        free(outputBytes);
    
        return outputData;
    }
    

    The handy thing about XOR is that doing it twice will give you back your original data, so scrambling and descrambling is the same code.

    I am avoiding the term encryption here, because this is really just obfuscating the data to keep it from casual observers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Mainly this is a question about how to get a similar behaviour as java
Context This is a question mainly about Lucene (or possibly Solr) internals. The main
This question is mainly to verify my current idea. I have a series of
This question is mainly aimed at shared libraries (.so files) compiled for Linux platforms.
This question and my answer below are mainly in response to an area of
Hey guys, hope this isn't too much of a n00b question I'm mainly a
This question is directly related to this SO question I posed about 15 minutes
This question is for experienced Unix/Linux developers. If you have found that you like
I tagged this question both Java and Scala because while I mainly develop on
I have a question about threading in Silverlight. I come mainly from a winForms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.