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

  • Home
  • SEARCH
  • 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 8322043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:14:27+00:00 2026-06-08T23:14:27+00:00

I am developing an ePub reader for iOS. The ePub files that I am

  • 0

I am developing an ePub reader for iOS. The ePub files that I am downloading from the server are encrypted using XOR algorithm. I am getting those files as .xlsx format with the key to decrypt it. I am decrypting and loading the file to reader as follows:

  1. Load the file as NSData from the downloaded directory.
  2. Decrypting the data with the key.
  3. Writing the decrypted Data to a temporary directory.
  4. Load the file from temporary directory to the reader.

I am using AePubReader to load the file.

Here is the decrypting code:

- (NSData *)obfuscate:(NSData *)data withKey:(NSString *)key
{
     NSMutableData *result = [data mutableCopy];


    // Get pointer to data to obfuscate
    char *dataPtr = (char *) [result mutableBytes];

    // Get pointer to key data
    char *keyData = (char *) [[key dataUsingEncoding:NSUTF8StringEncoding] bytes];

    // Points to each char in sequence in the key
    char *keyPtr = keyData;
    int keyIndex = 0;

    // For each character in data, xor with current value in key
    for (int x = 0; x < [data length]; x++) 
    {
        // Replace current character in data with 
        // current character xor'd with current key value.
        // Bump each pointer to the next character
        *dataPtr = *dataPtr++ ^ *keyPtr++; 

        // If at end of key data, reset count and 
        // set key pointer back to start of key value
        if (++keyIndex == [key length])
            keyIndex = 0, keyPtr = keyData;
    }

    return result;
}

But when I am trying to load the decrypted file to the reader, I am getting an error as follows:

2012-07-30 20:45:12.652 XYX[5986:12203] ERROR: ePub not Valid
2012-07-30 20:45:12.652 XYX[5986:12203] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
*** First throw call stack:

I checked for the url path, it is not empty and even checked if file exists at path. File is existing at the specified path.

Where I might be going wrong???Any help will be appreciated. Thanks in advance.

  • 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-08T23:14:29+00:00Added an answer on June 8, 2026 at 11:14 pm

    I solved it. As Paul commented, the problem was with:

    *dataPtr = *dataPtr++ ^ *keyPtr++;
    

    I changed it to:

    *dataPtr = *dataPtr ^ *keyPtr;
            dataPtr++;
            keyPtr++;
    

    Thank you Paul.

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

Sidebar

Related Questions

iam developing one application.In that i need to get the music files from the
I'm developing EPUB reader on iPad. So, I got a problem. We know that
I am developing epub reader using epublib. I want to add bookmark functionality in
While developing an application using gwt in ecliplse crashed. Now the server is running
I have the following problem. Developing APPs on IOS using Flex 4.6 I am
I'm developing a simple epub reader on iPhone but been wondering how to go
I am developing application for .Epub extension file reader.I have source code available. But
I am developing a ebook reader app. I have the .ePUB file for the
I am developing and EPUB reader . I want to know some things related
I'm developing epub reader program. To get contents of the epub file, I wanted

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.