tags:

views:

48

answers:

4

Hi, I am using a csv file to authenticate user login. Is it possible to password protect the CSV file? I do not want anybody to be able to download the csv file through url. I googled and I found out that it is not possible to password protect a csv file. Is there any other way I can password protect the file?

+1  A: 

Compress it in a ZIP file using encryption. You'll have to decompress/unencrypt it each time you want to read from it, however.

See Powerarchiver, winrar, or other compression utilities for more information.

JYelton
could you please show me how will I encrypt/unencrypt using code in php?
developer
Instead of zipping it I’d just encrypt it. Checking the php doc the mcrypt_encrypt function would be one. http://de2.php.net/manual/en/function.mcrypt-encrypt.php (which probably requires mcrypt as a dependency)
Kissaki
just make sure you can't download it. that makes much more sense than encrypting it and leave it in public place
Thomas Weber
@developer: Kissaki is right, simply encrypting it will be likely better. Moreover, according to http://php.net/manual/en/book.zip.php, there doesn't seem to be an encrypt/decrypt built into the PHP zip library.
JYelton
+8  A: 

the short answer is no: CSV is a plain text format, it's not Excel.

the long answer is: you should never put security relevant information into a folder which is accessible via the webserver. move the file into a folder you can access from PHP but which is outside of your document root in Apache

Thomas Weber
And hash the passwords!
Guttsy
definitely do so, and make sure you use salted hashes
Thomas Weber
A: 

If you're worried about someone downloading the file, put it someplace that isn't downloadable. Your webserver will only return files from a specific set of directories. If your CSV file is not in one of them, nobody will be able to download it.

Jeff Dege
+1  A: 

If using Apache, use a .htaccess file to deny access to that file. Better still, store the file somewhere above the webroot. For example, if your webserver is located at /home/username/htdocs/, you could store the file at /home/username/data/logins.csv.

michaelc