Php 使用BCMath时出错-调用未定义的方法PEAR_Error::int2bin()

Php 使用BCMath时出错-调用未定义的方法PEAR_Error::int2bin(),php,pear,bcmath,Php,Pear,Bcmath,我在使用BCMath时出现此错误- 致命错误:在中调用未定义的方法PEAR_error::int2bin() 第23行的login.php 我正在尝试同时使用Crypt_RSA和BCMath。这是我的密码- require_once("Crypt/RSA/MathLoader.php"); $wrapper_name = “BCMath”; $math_obj = &Crypt_RSA_MathLoader::loadWrapper($wrapper_name); $a = $math

我在使用BCMath时出现此错误-

致命错误:在中调用未定义的方法PEAR_error::int2bin() 第23行的login.php

我正在尝试同时使用Crypt_RSA和BCMath。这是我的密码-

require_once("Crypt/RSA/MathLoader.php");
$wrapper_name = “BCMath”;
$math_obj = &Crypt_RSA_MathLoader::loadWrapper($wrapper_name);

$a = $math_obj->int2bin("6465130539297209249500692895930266194225707667564124686892613724438982507603215802636578141547940687986170708901198917318074984831856438115515743080726101");

因此,几天前我在用php进行加密时遇到了类似的问题。我需要将十进制数转换成等价的二进制数。我所做的是将其转换为十六进制,然后将其解压为十六进制编码的数据

<?php 

$a = pack("H*", convBase('6465130539297209249500692895930266194225707667564124686892613724438982507603215802636578141547940687986170708901198917318074984831856438115515743080726101', '0123456789', '0123456789ABCDEF'));

function convBase($numberInput, $fromBaseInput, $toBaseInput)
{
    if ($fromBaseInput==$toBaseInput) return $numberInput;
    $fromBase = str_split($fromBaseInput,1);
    $toBase = str_split($toBaseInput,1);
    $number = str_split($numberInput,1);
    $fromLen=strlen($fromBaseInput);
    $toLen=strlen($toBaseInput);
    $numberLen=strlen($numberInput);
    $retval='';
    if ($toBaseInput == '0123456789')
    {
        $retval=0;
        for ($i = 1;$i <= $numberLen; $i++)
            $retval = bcadd($retval, bcmul(array_search($number[$i-1], $fromBase),bcpow($fromLen,$numberLen-$i)));
        return $retval;
    }
    if ($fromBaseInput != '0123456789')
        $base10=convBase($numberInput, $fromBaseInput, '0123456789');
    else
        $base10 = $numberInput;
    if ($base10<strlen($toBaseInput))
        return $toBase[$base10];
    while($base10 != '0')
    {
        $retval = $toBase[bcmod($base10,$toLen)].$retval;
        $base10 = bcdiv($base10,$toLen,0);
    }
    return $retval;
}
?>

但您了解问题所在,并为我提供了解决方案+1.