protected function encrypt($string)
	{
		// only if we want the cookie to be encrypted
		if ($this->config['cookie']['encrypt_cookie'])
		{
			// we require the mcrypt PECL extension for this
			if ( ! function_exists('mcrypt_encrypt'))
			{
				throw new \BadMethodCallException('The Session Cookie driver requires the PHP mcrypt extension to be installed.');
			}

			// create the encyption key
			$key = hash('SHA256', $this->config['cookie']['crypt_key'], true);

			// create the IV
			$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND);
			if (strlen($iv_base64 = rtrim(base64_encode($iv), '=')) != 22)
			{
				// invalid IV
				return false;
			}

			// construct the encrypted payload
			$string = $iv_base64.base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $string.md5($string), MCRYPT_MODE_CBC, $iv));
		}

		return $string;
	}