function _powmod($base, $exponent, $modulus)
    {
        $square = $this->mod($base, $modulus);
        $result = 1;
        while($this->cmp($exponent, 0) > 0) {
            if ($this->mod($exponent, 2)) {
                $result = $this->mod($this->mul($result, $square), $modulus);
            }
            $square = $this->mod($this->mul($square, $square), $modulus);
            $exponent = $this->div($exponent, 2);
        }
        return $result;
    }
function _powmod($base, $exponent, $modulus)
    {
        $square = $this->mod($base, $modulus);
        $result = 1;
        while($this->cmp($exponent, 0) > 0) {
            if ($this->mod($exponent, 2)) {
                $result = $this->mod($this->mul($result, $square), $modulus);
            }
            $square = $this->mod($this->mul($square, $square), $modulus);
            $exponent = $this->div($exponent, 2);
        }
        return $result;
    }
function _powmod ( $ base , $ exponent , $ modulus ) { $ square = $ this -> mod ( $ base , $ modulus ) ; $ result = 1 ; while ( $ this -> cmp ( $ exponent , 0 ) > 0 ) { if ( $ this -> mod ( $ exponent , 2 ) ) { $ result = $ this -> mod ( $ this -> mul ( $ result , $ square ) , $ modulus ) ; } $ square = $ this -> mod ( $ this -> mul ( $ square , $ square ) , $ modulus ) ; $ exponent = $ this -> div ( $ exponent , 2 ) ; } return $ result ; }
Same as bcpowmod when bcpowmod is missing

@access private
@param int $base
@param int $exponent
@param int $modulus
@return int
Same as bcpowmod when bcpowmod is missing