encrypting uploaded files HELP PLEASE!!!!

Discussion in 'PHP' started by ozzthegod, Mar 27, 2008.

  1. #1
    Hi,
    I am banging my head against the wall for last 5 days. I CANT find any way to encrypt uploaded files (any extension txt,pdf,mp3,exe...etc).

    I am working on a data management system and it needs to have encryption so the files people are storing with it can be accessed only from the app.
    app was created in Flex and it uses PHP to handle file upload.
    the biggest problem is that i have no idea on which server it will be hosted so the encryption i implement needs to be multi-platform(so no shell_exec unfortunately).

    i have tryed anything i could think of, i even tryed to pull data from the file, encrypt it and then write it back into the file but that doesnt

    work properly with anything that is not txt. so that rules out mcrypt, crypt...

    does anyone have any experience with this kind of problem if nothing else point me to the right direction.

    TNX.
     
    ozzthegod, Mar 27, 2008 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Can you store the files in a database? Most databases have encryption functions. Mysql can use AES and DES.
     
    jestep, Mar 27, 2008 IP
  3. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #3
    Or can't you change the file names and store them on a specific location and save the path in DB?
     
    mwasif, Mar 27, 2008 IP
  4. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #4
    well maybe if you want to encrypt the contents use
    fopen(),fwrite(),fclose() functions then base64_encode might be of good help

    ^^,
     
    bartolay13, Mar 27, 2008 IP
  5. lawrenz

    lawrenz Peon

    Messages:
    246
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    yup change the file name when you uploading it use $_FILES['user_file']['name'] = $your_new_filename";
     
    lawrenz, Mar 27, 2008 IP
  6. mythbuster08

    mythbuster08 Peon

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If crypt() only works with non txt files but scrambles up the data for text, the error most likely is in your code and is not really related to encryption.
    After encrypting ASCII files make sure to save in binary format?
     
    mythbuster08, Mar 28, 2008 IP
  7. ozzthegod

    ozzthegod Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    tnx for all replys
    files have changed names so one needs browse the database and compare with files so he would know what i what. but that is not sufficient,
    i cant store them in the database cause some of the files will be more than 10 mb in size i think it would kill a DB after a while :D imagine having 1GB of data in your DB :D

    i'll try with fopen,fwrite ... again maybe i did some thing wrong the first time.

    if anyone thinks of something please post it here.
     
    ozzthegod, Mar 28, 2008 IP