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 7774697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:26:37+00:00 2026-06-01T17:26:37+00:00

A certain piece of code works like this: Read a file from the disk

  • 0

A certain piece of code works like this:

  1. Read a file from the disk and store it as NSData in memory
  2. Encrypt (decrypt) it, thus resulting in an additional NSData object of the same size in memory
  3. Write the encrypted (decrypted) data to the disk

Now, for files like 10 or 100 mb in size, this works just fine and maintains a consistent rate of processing bytes per second (so processing a 100 mb file will take 10x the 10 mb one). If I go up to say 1.5 gigs, then the system has to keep 2 of those in memory so it starts swapping to disk and that brings the speed down dramatically.

So I thought maybe the following was possible:

  1. Look at the file and split it into 100mb chunks (for example)
  2. Read a chunk
  3. Encrypt (decrypt) it
  4. Append the encrypted chunk to the output file
  5. Throw the original chunk away, so that the whole process takes at most 200mb of RAM

My question is:

  1. Is that possible?
  2. If so, is that the best way to do that?
  3. If so, how would I go about implementing it?
  • 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-01T17:26:38+00:00Added an answer on June 1, 2026 at 5:26 pm

    What you want to do is entirely possible. Your questions demand an answer that’s a bit lengthy, so I refer you to this web page:

    https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Streams/Articles/ReadingInputStreams.html

    Note that the examples in the page deal with files. You can set up a buffer to the size you want and read as many bytes as you want at a time. You’ll even see an opportune place for you to call your encryption routine.

    With the NSMutableData instance you create, you can then have it write out to disk using -writeToFile:atomically: or -writeToURL:atomically:

    Give it a try, and best wishes to you in your endeavors.

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

Sidebar

Related Questions

I am implementing a piece of software that works like this: I have a
I have a piece of code related to MapKit which works fine on my
Suppose I want to measure the time that a certain piece of code takes.
I'm making a LaTeX document for someone. A certain piece of text looks bold
I'm trying to overwrite certain pieces in kernel memory (Linux 2.6.31, Ubuntu 9.10) in
In certain text editors, like E, I can select multiple locations and, as I
After certain R#-recommended edits R# colors the background of blocks of code in a
Let's say I have a piece of code that runs fine on an OS.
When I run this code on my computer with the help of Google App
Here is my code for a mouseover: $('.caption').mouseover(function() { $(this).fadeTo('slow',1); $(this).css('color','#ddd').animate({'color': 'white'}, 500); $(this).css('font-weight','bold');

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.