簡體   English   中英

NetworkError:500內部服務器錯誤

[英]NetworkError: 500 Internal Server Error

當我嘗試執行此文件時,它將顯示黑頁。

我啟動螢火蟲,它向我顯示NetworkError:500 Internal Server Error我試圖解決,但在這里找不到任何問題。

所以你能幫我找到什么錯誤或問題嗎?

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);
    }
}
}

當我使用var_dump()進行調試時,我在函數transformFinalBlock中發現了這一點

$padding = array_values(unpack('C', substr($text, -1)))[0];

它會向我拋出“'['意外”之類的錯誤

伙計們,解決方案請...

數組取消引用,這是您在$padding = array_values(unpack('C', substr($text, -1)))[0];行中所做的工作 ,僅在php 5.4及更高版本中才可用,您將必須執行以下操作才能訪問數組:

$arr = array_values(unpack('C', substr($text, -1)));
$padding = $arr[0];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM