Пример #1
0
 public function getContent($fullpath)
 {
     $src = $this->hubic->fopen(self::getRealname($fullpath), 'rb');
     if (Helper::endsWith($fullpath, $this->config->get('encrypted_file_ext'))) {
         $crypt = new \AESCryptFileLib(new \MCryptAES256Implementation(), false);
         $contents = $crypt->decryptFile($src, $this->getKey());
     } else {
         $contents = stream_get_contents($src);
     }
     fclose($src);
     header("Content-Type: application/octet-stream");
     return $contents;
 }
 function testCorrectPassword()
 {
     //Attempt to decrypt corrupted file with good passphrase
     $decrypted_file = NULL;
     try {
         $mcrypt = new MCryptAES256Implementation();
         $lib = new AESCryptFileLib($mcrypt);
         $decrypted_file = $lib->decryptFile($this->file_enc, $this->passphrase, $this->file_dec);
     } catch (AESCryptCorruptedFileException $e) {
         //OK
         $this->pass("Yes, file correctly detected as corrupted");
     } catch (Exception $e) {
         $this->fail("Not an AESCryptCorruptedFileException: " . get_class($e));
     }
     $this->assertNull($decrypted_file);
 }
Пример #3
0
<?php

// Include the library
require_once 'AESCryptFileLib.php';
// Include an AES256 Implementation
require_once 'aes256/MCryptAES256Implementation.php';
// Construct the implementation
$mcrypt = new MCryptAES256Implementation();
// Use this to instantiate the encryption library class
$lib = new AESCryptFileLib($mcrypt);
// This example encrypts and decrypts the README.md file
$file_to_encrypt = "README.md";
$encrypted_file = "README.md.aes";
$decrypted_file = "README.decrypted.txt";
// Ensure target file does not exist
@unlink($encrypted_file);
// Encrypt a file
$lib->encryptFile($file_to_encrypt, "1234", $encrypted_file);
// Ensure file does not exist
@unlink($decrypted_file);
// Decrypt using same password
$lib->decryptFile($encrypted_file, "1234", $decrypted_file);
echo "Done";
Пример #4
0
        }
        $rating = sanitize($_GET['rating']);
        $starred = sanitize($_GET['starred']);
        $date = sanitize($_GET['date']);
        $tFile = $uhd . '/' . sanitize($_GET['view']);
        $file = $tFile . '.' . $rating . '.' . $starred . '.' . $date;
        $encfile = $file . '.aes';
        $file = 'tmp/' . $tFile;
        $encfile = 'files/' . $encfile;
        $aeskey = $_SESSION['pixx-userpass-hash'];
        require_once 'includes/aes256/AESCryptFileLib.php';
        require_once 'includes/aes256/MCryptAES256Implementation.php';
        $mcrypt = new MCryptAES256Implementation();
        $lib = new AESCryptFileLib($mcrypt);
        @unlink($file);
        $lib->decryptFile($encfile, $aeskey, $file);
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        $fileType = finfo_file($finfo, $file);
        finfo_close($finfo);
        header('Content-Type: ' . $fileType);
        readfile($file);
        unlink($file);
        exit;
    }
}
if (isset($_POST['star'])) {
    $file = sanitize($_POST['star']);
    $action = sanitize($_POST['action']);
    $fParts = explode('.', $file);
    if ($action == 'star') {
        $newStar = 'pixxstar';
Пример #5
0
Файл: dwn.php Проект: xobyx/save
$conn = mysqli_connect($config['ser'], $config['user'], $config['pass'], $config['db']);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT  path FROM files WHERE id='{$id}'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
    // output data of each row
    while ($row = mysqli_fetch_assoc($result)) {
        $file = $row['path'];
    }
}
$fname = '';
if (file_exists($file . '.aes')) {
    $fname = basename($file);
    @unlink("temp/" . $fname . '.tmp');
    // Decrypt using same password
    $lib->decryptFile($file . '.aes', $_SESSION['id'], "temp/" . $fname . '.tmp');
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=' . $fname);
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize("temp/" . $fname . '.tmp'));
    readfile("temp/" . $fname . '.tmp');
    exit;
} else {
    echo "file not found";
}
Пример #6
0
 $stm->bind_result($file_id, $location, $mem_id, $team_id, $permissions, $desc, $salt);
 $stm->store_result();
 if ($stm->fetch()) {
     if (file_exists($location)) {
         $temp1 = explode("/", $location);
         $filename = end($temp1);
         $temp3 = explode("_", $filename);
         $filename_temp3 = str_replace($temp3[0] . '_', "", $filename);
         $filename_temp = str_replace(".hree", "", $filename_temp3);
         $temp2 = 'data/temp/';
         $decrypted_file = $temp2 . $filename_temp;
         require_once 'aes256/AESCryptFileLib.php';
         require_once 'aes256/MCryptAES256Implementation.php';
         $mcrypt = new MCryptAES256Implementation();
         $lib = new AESCryptFileLib($mcrypt);
         $lib->decryptFile($location, $salt, $decrypted_file);
         header('Content-Description: File Transfer');
         header('Content-Type: application/octet-stream');
         header('Content-Disposition: attachment; filename=' . basename($decrypted_file));
         header('Expires: 0');
         header('Cache-Control: must-revalidate');
         header('Pragma: public');
         header('Content-Length: ' . filesize($decrypted_file));
         ob_end_flush();
         if (readfile($decrypted_file)) {
             unlink($decrypted_file);
         } else {
             echo 'the file you have requested seems expired.Please try uploading again.<a href="www.communitycloud.in">home</a>';
         }
     } else {
         echo 'the file you have requested seems expired.Please try uploading again.<a href="www.communitycloud.in">home</a>';