public function setVector($vector = null)
    {
        $cipher = $this->_openCipher();
        $size   = mcrypt_enc_get_iv_size($cipher);
        if (empty($vector)) {
            $this->_srand();
            if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && version_compare(PHP_VERSION, '5.3.0', '<')) {
                $method = MCRYPT_RAND;
            } else {
                if (file_exists('/dev/urandom') || (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')) {
                    $method = MCRYPT_DEV_URANDOM;
                } elseif (file_exists('/dev/random')) {
                    $method = MCRYPT_DEV_RANDOM;
                } else {
                    $method = MCRYPT_RAND;
                }
            }
            $vector = mcrypt_create_iv($size, $method);
        } else if (strlen($vector) != $size) {

            throw new Zend_Filter_Exception('The given vector has a wrong size for the set algorithm');
        }

        $this->_encryption['vector'] = $vector;
        $this->_closeCipher($cipher);

        return $this;
    }
public function setVector($vector = null)
    {
        $cipher = $this->_openCipher();
        $size   = mcrypt_enc_get_iv_size($cipher);
        if (empty($vector)) {
            $this->_srand();
            if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && version_compare(PHP_VERSION, '5.3.0', '<')) {
                $method = MCRYPT_RAND;
            } else {
                if (file_exists('/dev/urandom') || (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')) {
                    $method = MCRYPT_DEV_URANDOM;
                } elseif (file_exists('/dev/random')) {
                    $method = MCRYPT_DEV_RANDOM;
                } else {
                    $method = MCRYPT_RAND;
                }
            }
            $vector = mcrypt_create_iv($size, $method);
        } else if (strlen($vector) != $size) {

            throw new Zend_Filter_Exception('The given vector has a wrong size for the set algorithm');
        }

        $this->_encryption['vector'] = $vector;
        $this->_closeCipher($cipher);

        return $this;
    }
public function setVector ( $ vector = null ) { $ cipher = $ this -> _openCipher ( ) ; $ size = mcrypt_enc_get_iv_size ( $ cipher ) ; if ( empty ( $ vector ) ) { $ this -> _srand ( ) ; if ( strtoupper ( substr ( PHP_OS , 0 , 3 ) ) === 'WIN' && version_compare ( PHP_VERSION , '5.3.0' , '<' ) ) { $ method = MCRYPT_RAND ; } else { if ( file_exists ( '/dev/urandom' ) || ( strtoupper ( substr ( PHP_OS , 0 , 3 ) ) === 'WIN' ) ) { $ method = MCRYPT_DEV_URANDOM ; } elseif ( file_exists ( '/dev/random' ) ) { $ method = MCRYPT_DEV_RANDOM ; } else { $ method = MCRYPT_RAND ; } } $ vector = mcrypt_create_iv ( $ size , $ method ) ; } else if ( strlen ( $ vector ) != $ size ) { throw new Zend_Filter_Exception ( 'The given vector has a wrong size for the set algorithm' ) ; } $ this -> _encryption [ 'vector' ] = $ vector ; $ this -> _closeCipher ( $ cipher ) ; return $ this ; }
Sets the initialization vector

@param string $vector (Optional) Vector to set
@return Zend_Filter_Encrypt_Mcrypt
Sets the initialization vector