php encode and decode file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
karthi2009
Forum Newbie
Posts: 6
Joined: Fri Jan 02, 2009 4:42 am
Location: Tamilnadu, India

php encode and decode file

Post by karthi2009 »

how to encode and decode php file.

this is i am expecting any the experts tell me the solution .

thanks for advance.
Last edited by karthi2009 on Tue Jan 06, 2009 4:23 am, edited 1 time in total.
User avatar
it2051229
Forum Contributor
Posts: 312
Joined: Tue Dec 25, 2007 8:34 pm

Re: php encode and decode file

Post by it2051229 »

I havent seen a PHP script that encrypts and decrypts files but it would be very interesting if there is. Maybe you asked the wrong question like Encrypting/Decrypting file contents.
User avatar
viraj
Forum Newbie
Posts: 11
Joined: Wed Nov 19, 2008 7:52 am
Location: Colombo - Sri Lanka

Re: php encode and decode file

Post by viraj »

Try
1. Zend Guard
2. MMCache

don't know there may be more
User avatar
volomike
Forum Regular
Posts: 633
Joined: Wed Jan 16, 2008 9:04 am
Location: Myrtle Beach, South Carolina, USA

Re: php encode and decode file

Post by volomike »

ENCRYPT

Code: Select all

 
        if (extension_loaded('mcrypt')) {
 
            $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
            $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
            $sData = mcrypt_encrypt(MCRYPT_RIJNDAEL_256,$sPrivateKey,$sData,
                MCRYPT_MODE_ECB,$iv);
 
        }
DECRYPT:

Code: Select all

       if (extension_loaded('mcrypt')) {
 
            $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
            $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
            $sData = mcrypt_decrypt(MCRYPT_RIJNDAEL_256,$sPrivateKey,$sData,
                MCRYPT_MODE_ECB, $iv);
 
        }
Now it's just a matter of either processing x number of file bytes in a row by reading file bytes, saving to another file, or putting everything in $sData and saving as a new file. I think $sData can handle about 2GB if I'm not mistaken, but it also depends on how much RAM and disk space you have, and which tmpfs (on Mac and Linux -- windows users would have a temp file) can temporarily do a land grab upon.
Post Reply