NetworkError:500 Erro Interno Do Servidor
-
21-12-2019 - |
Pergunta
Quando eu tento executar esse arquivo, ele me mostrar a página de preto..
eu iniciar o firebug mostra-me que NetworkError:500 Erro Interno Do Servidor eu tentei resolver, mas não consigo encontrar nenhum problema aqui..
então, você poderia me ajudar a descobrir o que é o erro ou o problema..??
class DesEncryptor
{
protected $_key;
protected $_iv;
protected $_blocksize = 8;
protected $_encrypt;
protected $_cipher;
/**
* Creates a symmetric Data Encryption Standard (DES) encryptor object
* with the specified key and initialization vector.
*
* @param $key
* @param $iv
* @param bool $encrypt
*/
public function __construct($key, $iv, $encrypt = true)
{
$this->_key = $key;
$this->_iv = $iv;
$this->_encrypt = $encrypt;
$this->_cipher = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_CBC, '');
mcrypt_generic_init($this->_cipher, $this->_key, $this->_iv);
}
public function __destruct()
{
mcrypt_generic_deinit($this->_cipher);
mcrypt_module_close($this->_cipher);
}
/**
* Transforms the specified region of the specified byte array using PCKS7 padding.
* @param $text
* @return string
*/
public function transformFinalBlock($text)
{
if ($this->_encrypt)
{
$padding = $this->_blocksize - strlen($text) % $this->_blocksize;
$text .= str_repeat(pack('C', $padding), $padding);
}
$text = $this->transformBlock($text);
if (!$this->_encrypt)
{
$padding = array_values(unpack('C', substr($text, -1)))[0];
$text = substr($text, 0, strlen($text) - $padding);
}
return $text;
}
/**
* Transforms the specified region of the specified byte array.
* @param $text
* @return string
*/
public function transformBlock($text)
{
if ($this->_encrypt)
{
return mcrypt_generic($this->_cipher, $text);
}
else
{
return mdecrypt_generic($this->_cipher, $text);
}
}
}
Quando eu depuração com var_dump(), descobri que na função transformFinalBlock
$padding = array_values(unpack('C', substr($text, -1)))[0];
ele me jogar de erro como " '[' é inesperado "
Caras, soluções plz...
Solução
Matriz de referência, que é o que você está fazendo com a linha $padding = array_values(unpack('C', substr($text, -1)))[0];
, só é possível como de o php 5.4, todas as versões anteriores, você terá que fazer o seguinte para aceder à sua matriz:
$arr = array_values(unpack('C', substr($text, -1)));
$padding = $arr[0];
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow