I have application which exports data in csv file which is stored in Document's Directory.
Also I have enabled File Sharing in my app with iTunes so that whenever i will connect my iPhone with iTunes it will allow me to save csv file. But my data needs security, so i want generate Password for my CSV file, So that whenever we open file in computer, it will ask for Password. How to achieve generating Password protected file in iPhone??
Well, you would have to create a disk image (.dmg file) in order to have the file password protected once it was on your computer. I don't think this is possible in iOS. I think your only solution would be to use an encryption/decryption algorithm. Store encrypted data into the file, and use your algorithm to decrypt the file once it is on your desktop. Here is a solution for encrypting/decrypting NSData.
How about it doing it this way :
Use some generic encrypting algorithm
Either generate a key or ask from user (as per your needs ) while generating csv
Then when its copied to dekstop ask user to download a utility to decrypt..
Or create simple online decrptor in php .. should be simple enough..
Or use existing : http://www.tools4noobs.com/online_tools/decrypt/
Related
In my project I have stored my sqlite(DB file) file in Document directory and also set UIFilesharingMode - NO , but now user can able to acces the file using Xcode->orginizor and also he can able to modify in table and able to change the data in that dable .
My requirement is, how I can hide or restrict user to not access that file.
If any one have any intelligent idea please share me.
Thanks.
You have to use encryption. There's no way to prevent someone accessing Documents folder and there's nowhere for you to store the sqlite file.
I have an iOS application, which stores all downloaded *.pdf files in its cache. Is there a way to prevent this data from extracting? Encryption or something else? Thanks in advance.
There are quite a few ways to encrypt files, and I'm sure everyone will have an opinion on the best way to do so.
In a project I've recently been working on, we've been using CommonCrypto (https://github.com/AlanQuatermain/aqtoolkit). Just take any NSData, encrypt it, and save it to a file, and vice versa. You can even write an easy Transformer by subclassing NSValueTransformer, which abstracts all of the encryption to one spot and you will never have to worry about it again.
You can protect PDF files with a password. I assume you create the PDF files not within the application but externally. For example you can use Preview.app in Mac OS X to secure existing PDF files with a password (Hit Cmd-P, then select PDF in the print menu and there you can set security options. Or even more simple: in the menu choose Export...).
In iOS you can then open the PDF files like this:
CGPDFDocumentRef documentRef = CGPDFDocumentCreateWithURL((__bridge CFURLRef)[NSURL fileURLWithPath:filePath]);
if (!CGPDFDocumentIsUnlocked(documentRef))
CGPDFDocumentUnlockWithPassword(documentRef, password);
...
There are actually 2 Documents folders in which your app can store content. One can be extracted, and one is private. Check the accepted answer in this ticket.
Access files in "private Documents" folder transferred with iTunes
Assuming you want the PDF files from getting extracted on jailbroken devices, the most straight forward approach would be along the following lines:
generate a random string during the first launch of the app
save the random string either in NSUserDefaults in state file inside your own app's sandbox
using this random string create a secret key using a deterministic but hard to figure out algorithm
use this secret key, which you don't store anywhere but always generate on demand, symmetrically encrypt your buffer with AES or something similar
You would probably find the source code here very helpful.
I am developing a simple iPad application that should submit some text from a form to a .csv file. I could manage to update the .csv file which is saved locally in the documents folder on my computer. However, I need to keep the file on a server, probably download the file, append data, and upload it again (Export a bulk of data to the file on server). Any idea how I could do something like that?
I guess ftp might be the easiest way, see this question
your other options likely involve writing a server-side service to post data to.
I need to protect a file with password when I send it as email attachment from iPhone. I have zipped the file using libz.dylib zlib.h class. Basically I followed the approach discussed in http://www.cocoadev.com/index.pl?NSDataCategory ie., to create NSDataCategory and calling zlib methods to compress the file. So I have the .gz format file as NSData and I want to protect it with a password. My question is how to protect a .gz file with a password. And I have also a basic question of how the password protection on a file work? Will it encrypt the total file with the given password or will it just act as a gate keeper to open the file?
You can't add password encryption to a .gz file, there is no support in libz. What you are thinking of is .zip tools that also add a simple layer of encryption where the password is used to decrypt the file. You might want to have a look at lzmaSDK to implement that sort of feature, I have read that it supports AES. But, be aware that adding encryption code to your iPhone app is more trouble that it is worth because then you will need to also register to export the encryption. It will significantly complicate your app release process.
I would like to save a file downloaded from the internet in iPhone.
Can I use the url as the file name? If not, what transformation should I apply to the url to obtain a valid file name?
I need to find the local copy of the file later using its url.
Edit: Not asking where or how to write a file to disk. The question is limited to getting a valid file name from an url.
Can I use the url as the file name?
You can use just about anything you want for a file name. As long as it's a valid file name for the underlying file system.
If
not, what transformation should I
apply to the url to obtain a valid
file name?
This is unanswerable because there's no way to specify what "valid" means here.
I need to find the local copy of the
file later using its url.
You probably want to save it to your application's Documents directory. There already are plenty of questions relating to saving files on iPhone here on Stack Overflow, and I urge you to read some of them.
For lack of a better method, I'm using a persistent dictionary to map the urls to unique names.