Fabrizio
Fabrizio

Reputation: 407

Where can I put temporary files that I don't want show to the user?

in my Mac software I need decrypt a file and, after I do my operations on it, I will remove it. My problem is: Where can I put this file? I don't want show it to the user.

Upvotes: 1

Views: 254

Answers (2)

zigdon
zigdon

Reputation: 15063

I think your best bet would be to keep it in memory.

If that's not an option, it depends on what you want to do with it. It's possible you can open a temporary file, and immediately delete it - keeping the valid filehandle open, but not keeping a link to it on the disk.

Another option, perhaps - can you get your secondary program to read from STDIN or a pipe? You could then decrypt the file and pass it's content via a pipe? Clearly, the more complex this process is, the more weak links it might have, but sometimes you just have to get things working.

Upvotes: 1

Jonathan Grynspan
Jonathan Grynspan

Reputation: 43472

The following API will give you a directory path that is "out of the way":

NSTemporaryDirectory();

Do you mean "decrypt a file in a place the user can't access?" Any place your app can write to, the user can see. And in theory, a user can access any bit or byte on a computer to which they have physical access.

There are obfuscations and such that reduce the odds a user will come across sensitive data, but they are meant for particular situations.

Can you tell us more about your end goal here? Are you trying to implement a DRM/copy protection scheme? Are you trying to prevent cheating in a game? Do you just not trust your user? What?

Upvotes: 4

Related Questions