PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Encrypt filter

The Encrypt filter allows to encrypt a file.

This filter makes use of Zend_Filter_Encrypt. It supports the Mcrypt and OpenSSL extensions from PHP. Please read the related section for details about how to set the options for encryption and which options are supported.

This filter supports one additional option which can be used to save the encrypted file with another filename. Set the filename option to change the filename where the encrypted file will be stored. If you suppress this option, the encrypted file will overwrite the original file.

Example 433. Using the Encrypt filter with Mcrypt

<?php
$upload 
= new Zend_File_Transfer_Adapter_Http();

// Adds a filter to encrypt the uploaded file
// with mcrypt and the key mykey
$upload->addFilter('Encrypt',
    array(
'adapter' => 'mcrypt''key' => 'mykey'));

Example 434. Using the Encrypt filter with OpenSSL

<?php
$upload 
= new Zend_File_Transfer_Adapter_Http();

// Adds a filter to encrypt the uploaded file
// with openssl and the provided keys
$upload->addFilter('Encrypt',
    array(
'adapter' => 'openssl',
          
'public' => '/path/to/publickey.pem'));

Zend Framework