public static function encrypt($varValue, $strKey=null)
	{
		// Recursively encrypt arrays
		if (\is_array($varValue))
		{
			foreach ($varValue as $k=>$v)
			{
				$varValue[$k] = static::encrypt($v);
			}

			return $varValue;
		}
		elseif ($varValue == '')
		{
			return '';
		}

		// Initialize the module
		if (static::$resTd === null)
		{
			static::initialize();
		}

		if (!$strKey)
		{
			$strKey = System::getContainer()->getParameter('contao.encryption_key');
		}

		$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size(static::$resTd));
		mcrypt_generic_init(static::$resTd, md5($strKey), $iv);
		$strEncrypted = mcrypt_generic(static::$resTd, $varValue);
		$strEncrypted = base64_encode($iv.$strEncrypted);
		mcrypt_generic_deinit(static::$resTd);

		return $strEncrypted;
	}
public static function encrypt($varValue, $strKey=null)
	{
		
		if (\is_array($varValue))
		{
			foreach ($varValue as $k=>$v)
			{
				$varValue[$k] = static::encrypt($v);
			}

			return $varValue;
		}
		elseif ($varValue == '')
		{
			return '';
		}

		
		if (static::$resTd === null)
		{
			static::initialize();
		}

		if (!$strKey)
		{
			$strKey = System::getContainer()->getParameter('contao.encryption_key');
		}

		$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size(static::$resTd));
		mcrypt_generic_init(static::$resTd, md5($strKey), $iv);
		$strEncrypted = mcrypt_generic(static::$resTd, $varValue);
		$strEncrypted = base64_encode($iv.$strEncrypted);
		mcrypt_generic_deinit(static::$resTd);

		return $strEncrypted;
	}
public static function encrypt ( $ varValue , $ strKey = null ) { // Recursively encrypt arrays if ( \ is_array ( $ varValue ) ) { foreach ( $ varValue as $ k => $ v ) { $ varValue [ $ k ] = static :: encrypt ( $ v ) ; } return $ varValue ; } elseif ( $ varValue == '' ) { return '' ; } // Initialize the module if ( static :: $ resTd === null ) { static :: initialize ( ) ; } if ( ! $ strKey ) { $ strKey = System :: getContainer ( ) -> getParameter ( 'contao.encryption_key' ) ; } $ iv = mcrypt_create_iv ( mcrypt_enc_get_iv_size ( static :: $ resTd ) ) ; mcrypt_generic_init ( static :: $ resTd , md5 ( $ strKey ) , $ iv ) ; $ strEncrypted = mcrypt_generic ( static :: $ resTd , $ varValue ) ; $ strEncrypted = base64_encode ( $ iv . $ strEncrypted ) ; mcrypt_generic_deinit ( static :: $ resTd ) ; return $ strEncrypted ; }
Encrypt a value

@param mixed  $varValue The value to encrypt
@param string $strKey   An optional encryption key

@return string The encrypted value
Encrypt a value