framework/base/CSecurityManager.php
public function encrypt($data,$key=null)
	{
		if($key===null)
			$key=$this->getEncryptionKey();
		$this->validateEncryptionKey($key);
		$module=$this->openCryptModule();
		srand();
		$iv=@mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND);
		@mcrypt_generic_init($module,$key,$iv);
		$encrypted=$iv.@mcrypt_generic($module,$data);
		@mcrypt_generic_deinit($module);
		@mcrypt_module_close($module);
		return $encrypted;
	}
public function encrypt($data,$key=null)
	{
		if($key===null)
			$key=$this->getEncryptionKey();
		$this->validateEncryptionKey($key);
		$module=$this->openCryptModule();
		srand();
		$iv=@mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND);
		@mcrypt_generic_init($module,$key,$iv);
		$encrypted=$iv.@mcrypt_generic($module,$data);
		@mcrypt_generic_deinit($module);
		@mcrypt_module_close($module);
		return $encrypted;
	}
public function encrypt ( $ data , $ key = null ) { if ( $ key === null ) $ key = $ this -> getEncryptionKey ( ) ; $ this -> validateEncryptionKey ( $ key ) ; $ module = $ this -> openCryptModule ( ) ; srand ( ) ; $ iv = @ mcrypt_create_iv ( mcrypt_enc_get_iv_size ( $ module ) , MCRYPT_RAND ) ; @ mcrypt_generic_init ( $ module , $ key , $ iv ) ; $ encrypted = $ iv . @ mcrypt_generic ( $ module , $ data ) ; @ mcrypt_generic_deinit ( $ module ) ; @ mcrypt_module_close ( $ module ) ; return $ encrypted ; }
Encrypts data.
@param string $data data to be encrypted.
@param string $key the decryption key. This defaults to null, meaning using {@link getEncryptionKey EncryptionKey}.
@return string the encrypted data
@throws CException if PHP Mcrypt extension is not loaded or key is invalid
Encrypts data .