1

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??

DShah
  • 9,768
  • 11
  • 71
  • 127
  • csv is simple file I don't think you can have password protection. Though what you can do is encrypt it with a key... so that its non understandable. – Gaurav Shah Dec 03 '11 at 05:14
  • @Gaurav: But then how to view data when copied to computer?? Their i don't have any utility to decrypt – DShah Dec 03 '11 at 05:20
  • can you explain `data needs security, ` – Gaurav Shah Dec 05 '11 at 04:47
  • @GauravShah: My app is somewhat related to Personal Informations... so i m exporting that file in csv... as need by users... so if in case mobile gets lost then that file must needs password to open... this is scenario – DShah Dec 05 '11 at 05:36

2 Answers2

1

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.

Community
  • 1
  • 1
Michael Frederick
  • 16,664
  • 3
  • 43
  • 58
  • But how can i know that my device is connected to desktop? Also When will i Decrypt the file as I dont have any point to write this code?? Could you suggest some way out please?? – DShah Dec 03 '11 at 05:24
  • The idea would be to decrypt it once it is on your desktop. You would need a script or utility to do this. If you use a common encryption algorithm in your iOS app, you should be able to find a decryption algorithm pretty easily for perl/ruby/php or whatever other scripting language you want to use to decrypt the file. – Michael Frederick Dec 03 '11 at 06:08
  • This is not a good option... i cant let my app user to do such long procedure to copy data. also this is not the way of programming... but anyways... thanks for your suggestion... also suggest me if you have different idea.. – DShah Dec 03 '11 at 12:20
1

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/

Gaurav Shah
  • 5,223
  • 7
  • 43
  • 71