how to encode and decode php file.
this is i am expecting any the experts tell me the solution .
thanks for advance.
php encode and decode file
Moderator: General Moderators
-
karthi2009
- Forum Newbie
- Posts: 6
- Joined: Fri Jan 02, 2009 4:42 am
- Location: Tamilnadu, India
php encode and decode file
Last edited by karthi2009 on Tue Jan 06, 2009 4:23 am, edited 1 time in total.
Re: php encode and decode file
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.
- 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
ENCRYPT
DECRYPT:
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.
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);
}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);
}