Note that there are some explanatory texts on larger screens.

plurals
  1. POXOR file encryption in iOS
    primarykey
    data
    text
    <p>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:</p> <ol> <li>Load the file as NSData from the downloaded directory.</li> <li>Decrypting the data with the key.</li> <li>Writing the decrypted Data to a temporary directory.</li> <li>Load the file from temporary directory to the reader.</li> </ol> <p>I am using AePubReader to load the file.</p> <p>Here is the decrypting code:</p> <pre><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 &lt; [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; } </code></pre> <p>But when I am trying to load the decrypted file to the reader, I am getting an error as follows:</p> <pre><code>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: </code></pre> <p>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.</p> <p>Where I might be going wrong???Any help will be appreciated. Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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