Exemple #1
0
 /**
  * @brief decryption of a file
  * @param string $source
  * @param string $target
  * @param string $key the decryption key
  *
  * This function decrypts a file
  */
 public static function decryptFile($source, $target, $key = '')
 {
     $handleread = fopen($source, "rb");
     if ($handleread != FALSE) {
         $handlewrite = fopen($target, "wb");
         while (!feof($handleread)) {
             $content = fread($handleread, 8192);
             $enccontent = OC_CRYPT::decrypt($content, $key);
             if (feof($handleread)) {
                 $enccontent = rtrim($enccontent, "");
             }
             fwrite($handlewrite, $enccontent);
         }
         fclose($handlewrite);
         fclose($handleread);
     }
 }
 /**
  * @brief decryption of a file
  * @param $filename
  * @param $key the decryption key
  *
  * This function decrypts a file
  */
 public static function decryptfile($filename, $key)
 {
     $handleread = fopen($filename . OC_Crypt::$encription_extension, "rb");
     if ($handleread != FALSE) {
         $handlewrite = fopen($filename, "wb");
         while (!feof($handleread)) {
             $content = fread($handleread, 8192);
             $enccontent = OC_CRYPT::decrypt($content, $key);
             fwrite($handlewrite, $enccontent);
         }
         fclose($handlewrite);
         unlink($filename . OC_Crypt::$encription_extension);
     }
     fclose($handleread);
 }