views:

67

answers:

2

Hello guys, 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.

+4  A: 

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?

Jonathan Grynspan
Sorry Jonathan, you are right I didn't explain my end goal :/. The decrypted file is a file that will be execute by a secondary software so I think I can't keep it on memory :(.
Alleria
+1  A: 

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.

zigdon
+1 for keeping data in memory. Temporary directory and files can still remain on the user's filesystem if the application exits ungracefully.
Deep Kapadia
But even in memory, a black hat can access it. Without knowing more about @Alleria's intent, we don't know the proper solution.
Jonathan Grynspan
@Deep Kapadia - I was thinking of opening a file, and immediately deleting it. At that point the filehandle only exists in memory, and will be completely removed when the app exists for whatever reason.
zigdon
So, `tmpfile()`? :)
Jonathan Grynspan
Sorry Jonathan, you are right I didn't explain my end goal :/. The decrypted file is a file that will be execute by a secondary software so I think I can't keep it on memory :(.
Alleria