private function _encryptInternal($input, $base, $pad, $password, $iv, $checkVal = false)
    {
        $this->_validateInput($input, $base, $checkVal);
        $this->_validateIv($iv);
        $hashPassword = $this->_hashPassword($password);
        $roundKeys = $this->_roundKeys($hashPassword, $iv);

        $binary = $this->_convertToBin($input, $base);

        for ($i = 1; $i <= $this->rounds; $i++) {
            $left = substr($binary, 0, $this->sideSize);
            $right = substr($binary, -1 * $this->sideSize);

            $key = $roundKeys[$i];
            $round = $this->_round($right, $key, $hashPassword, $iv);

            $newLeft = $right;
            $newRight = $this->_binaryXor($left, $round);

            $binary = $newLeft . $newRight;
        }

        $output = $this->_convertFromBin($binary, $base, $pad);
        $compare = DataConverter::binToDec($binary);

        return (gmp_cmp($this->minValue, $compare) > 0 || gmp_cmp($compare, $this->maxValue) > 0)
            ? $this->_encryptInternal($output, $base, $pad, $password, $iv, false)
            : $output;
    }