Page 1 of 1
php encode and decode file
Posted: Tue Jan 06, 2009 3:03 am
by karthi2009
how to encode and decode php file.
this is i am expecting any the experts tell me the solution .
thanks for advance.
Re: php encode and decode file
Posted: Tue Jan 06, 2009 4:12 am
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.
Re: php encode and decode file
Posted: Tue Jan 06, 2009 5:23 am
by viraj
Try
1.
Zend Guard
2.
MMCache
don't know there may be more
Re: php encode and decode file
Posted: Tue Jan 06, 2009 10:36 am
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.