Encrypting a file.

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
ClarenceC
Forum Newbie
Posts: 2
Joined: Tue Feb 17, 2009 11:02 pm

Encrypting a file.

Post by ClarenceC »

Can anyone advise me how to encrypt a file. File possibilities will be excel, word or just .txt files. I have a site where users can upload files through an upload form, and I can download them from the admin section. What I can't figure out is how to encrypt the actual file so that while it sits in its folder on the server, if someone gets a hold of it, it will be encrypted. Then when I download it, it should decrypts itself so when I get it, it is usable again. Any ideas?
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: Encrypting a file.

Post by kaisellgren »

How about uploading the files outside the document root? Therefore the files are only accessible through your application. If you happen to have a vulnerability allowing someone to read those files, then your encryption/decryption would also be compromised, so, I do not think it is a necessity to encrypt the files.

What kind of information do those files consist of?
Post Reply