在 WAMP PHP 7.3 上使用 Phpseclib 版本 2 和 3 找不到类“phpseclib\Crypt\Common\BlockCipher”

问题描述

Receiving Fatal error: Uncaught Error: Class 'PHPseclib\Crypt\Common\BlockCipher' not found in C:\wamp64\www\chuckles.net\oldencrypt\PHPseclib\Crypt\Rijndael.PHP on line 71 1 0.0002 403520 {main}( ) ...\example2.PHP:0 2 0.0008 405344 包括('C:\wamp64\www\chuckles.net\oldencrypt\PHPseclib\Crypt\Rijndael.PHP')...\example2.PHP:9

PHPseclib3\Crypt\Rijndael.PHP line  71 is: 
    class Rijndael extends BlockCipher
    {
        /**
         * The mcrypt specific name of the cipher
         *
         * Mcrypt is useable for 128/192/256-bit $block_size/$key_length. For 160/224 not.
         * \PHPseclib3\Crypt\Rijndael determines automatically whether mcrypt is useable
         * or not for the current $block_size/$key_length.
         * In case of,$cipher_name_mcrypt will be set dynamically at run time accordingly.
         *
         * @see \PHPseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
         * @see \PHPseclib3\Crypt\Common\SymmetricKey::engine
         * @see self::isValidEngine()
         * @var string
         * @access private
         */

实际脚本:

 <?PHP 
    error_reporting(E_ALL);
    set_include_path(get_include_path() . PATH_SEParaTOR . 'PHPseclib');
    //include "PHPseclib/autoload.PHP";
    include "PHPseclib/bootstrap.PHP";
    include('PHPseclib/Crypt/Rijndael.PHP');
    include('PHPseclib/Crypt/Random.PHP');
    use PHPseclib\Crypt\Rijndael as Crypt_Rijndael;
    $text = '57F0-ECD3-1A3B-341E-BA39-F81B-F020-0DE0';
    $secret = 'lkirwf897+22#bbtrm8814z5qq=498j5';
    $iv = '741952hheeyy66#cs!9hjv887mxx7@8y';
    
    echo $text;
    echo encrypt128($secret,$iv,$text);
    echo "\n";
    
    $text = encryptRJ256($secret,$text);
    echo $text;
    echo "\n";
    echo decryptRJ256($secret,$text);
    
    function encrypt128($secret,$str)
    { 
        return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256,$secret,$str,MCRYPT_MODE_CBC,$iv));
    }
    
    function encryptRJ256($key,$text)
    {
        $cipher = new Crypt_Rijndael('cbc'); 
        $cipher->setBlockLength(256);
        // keys are null-padded to the closest valid size
        // longer than the longest key and it's truncated
        $cipher->setKeyLength(256);
        $cipher->setKey($key);
        // the IV defaults to all-NULLs if not explicitly defined
        $cipher->setIV($iv);
        $cipher->disablePadding();
        $length = strlen($text);
        $pad = 32 - ($length % 32);
        $text = str_pad($text,$length + $pad,chr(0));
        return base64_encode($cipher->encrypt($text));
    }
    function decryptRJ256($key,$text)
    {
        $cipher = new Crypt_Rijndael('cbc'); // Could use CRYPT_RIJNDAEL_MODE_CBC
        $cipher->setBlockLength(256);
        // keys are null-padded to the closest valid size
        // longer than the longest key and it's truncated
        $cipher->setKeyLength(256);
        $cipher->setKey($key);
        // the IV defaults to all-NULLs if not explicitly defined
        $cipher->setIV($iv);
        $cipher->disablePadding();
        return $cipher->decrypt(base64_decode($text)); 
    }   
  
 

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...