简体   繁体   English

Phpseclib PHP 致命错误:未捕获错误:Class

[英]Phpseclib PHP Fatal error: Uncaught Error: Class

I followed the installation instructions.我按照安装说明进行了操作。 I created the folder and ran the composer.我创建了文件夹并运行了作曲家。 I got the lock file and the vendor directory.我得到了锁定文件和供应商目录。 I placed the JSON, lock files, and vendor directory on the server (hosted by GoDaddy).我将 JSON、锁定文件和供应商目录放在服务器上(由 GoDaddy 托管)。

I created a simple PHP file with a decrypt function.我用解密 function 创建了一个简单的 PHP 文件。

<?php
require __DIR__ . '/vendor/autoload.php';
$ky = '2345678901234567890123456789012'; // 32 * 8 = 256 bit key
$iv = '2345678901234567890123456789012'; // 32 * 8 = 256 bit iv

function Decrypt($string_to_decrypt)
{
    global $ky;
    global $iv;
    
    $cipher = new Crypt_Rijndael(CRYPT_RIJNDAEL_MODE_CBC);
    $cipher->setBlockLength(256);
    $cipher->setKeyLength(256);
    $cipher->setKey($ky);
    $cipher->setIV($iv);

    $rtn= $cipher->decrypt($string_to_decrypt);
    error_log('decrypt = '. $rtn, 0);

    return($rtn);
}

I tried putting the following include in and it got further but then complained about the BlockCipher.我尝试将以下内容放入其中,它变得更进一步,但随后抱怨 BlockCipher。 I put another include in for that and got further.我为此添加了另一个包含并进一步。 I know this is not the correct way.我知道这不是正确的方法。 I would have thought the autoloader would have taken care of this.我原以为自动加载器会处理这个问题。

include('/home/n28d5aun99s6/public_html/Working/vendor/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php');

Can someone please tell me what I am doing wrong?有人可以告诉我我做错了什么吗?

You do not have proper reference to that class. It lives in phpseclib3\Crypt namespace but your code neither imports from there using use phpseclib3\Crypt\Rijndael nor have FQN given in when referenced in new .您没有对该 class 的正确引用。它位于phpseclib3\Crypt命名空间中,但您的代码既没有使用use phpseclib3\Crypt\Rijndael从那里导入,也没有在new中引用时给出 FQN。 Also the class name is Rijndael and not Crypt_Rijndael ( source ) so you should first ensure your code is working locally before uploading it anywhere otherwise you will be wasting time debugging.此外,class 名称是Rijndael而不是Crypt_Rijndael来源),因此您应该首先确保您的代码在本地工作,然后再将其上传到任何地方,否则您将浪费时间调试。

Also your hardcoded include solves nothing and should be removed.此外,您的硬编码include没有解决任何问题,应将其删除。

Please read the about namespaces in PHP as you seem to have knowledge deficit on that matter.阅读 PHP 中关于命名空间的内容,因为您似乎在这方面知识不足。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHP致命错误:未捕获错误:找不到类 - PHP Fatal error: Uncaught Error: Class not found 致命错误:类 &#39;phpseclib\\Crypt\\Base&#39; - Fatal error: Class 'phpseclib\Crypt\Base' 一个 class 得到“PHP 致命错误:未捕获的错误:类...”,但其他没有 - One class getting “PHP Fatal error: Uncaught Error: Class…” But not the others PHP致命错误:未捕获错误:找不到类&#39;Acme \\ RegisterUser&#39; - PHP Fatal error: Uncaught Error: Class 'Acme\RegisterUser' not found 致命错误:未捕获的错误:找不到类“Func”php - Fatal error: Uncaught Error: Class 'Func' not found php PHP 致命错误:未捕获的错误:找不到类“cake\\\\lib\\\\Dispatcher” - PHP Fatal error: Uncaught Error: Class 'cake\\lib\\Dispatcher' not found PHP - Phalcon致命错误:未捕获的错误:未在其中找到类“Phalcon\\Db” - PHP - Phalcon <b>Fatal error</b>: Uncaught Error: Class 'Phalcon\Db' not found in PHP致命错误:未捕获的错误:在Symfony上找不到类“ DOMDocument” - PHP Fatal error: Uncaught Error: Class 'DOMDocument' not found on Symfony 致命错误:未捕获错误:未找到 Class 'Ds\Map' PHP - Fatal error: Uncaught Error: Class 'Ds\Map' not found PHP PHP 致命错误:未捕获错误:未找到 Class 'Elliptic\EC' - PHP Fatal error: Uncaught Error: Class 'Elliptic\EC' not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM