/** * @brief encryption of a file * @param string $source * @param string $target * @param string $key the decryption key * * This function encrypts a file */ public static function encryptFile($source, $target, $key = '') { $handleread = fopen($source, "rb"); if ($handleread != FALSE) { $handlewrite = fopen($target, "wb"); while (!feof($handleread)) { $content = fread($handleread, 8192); $enccontent = OC_CRYPT::encrypt($content, $key); fwrite($handlewrite, $enccontent); } fclose($handlewrite); fclose($handleread); } }
/** * @brief encryption of a file * @param $filename * @param $key the encryption key * * This function encrypts a file */ public static function encryptfile($filename, $key) { $handleread = fopen($filename, "rb"); if ($handleread != FALSE) { $handlewrite = fopen($filename . OC_Crypt::$encription_extension, "wb"); while (!feof($handleread)) { $content = fread($handleread, 8192); $enccontent = OC_CRYPT::encrypt($content, $key); fwrite($handlewrite, $enccontent); } fclose($handlewrite); unlink($filename); } fclose($handleread); }