HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/quadcode/vendor/starkbank/ecdsa/src/utils/oid.php
<?php

namespace EllipticCurve\Utils;

use EllipticCurve\Utils\Binary;


class Oid
{
    public static function oidFromHex($hexadecimal)
    {
        $firstByte = substr($hexadecimal, 0, 2);
        $remainingBytes = substr($hexadecimal, 2);
        $firstByteInt = gmp_intval(Binary::intFromHex($firstByte));
        $oid = array(intdiv($firstByteInt, 40), $firstByteInt % 40);
        $oidInt = 0;
        while (strlen($remainingBytes) > 0) {
            $byte = substr($remainingBytes, 0, 2);
            $remainingBytes = substr($remainingBytes, 2);
            $byteInt = gmp_intval(Binary::intFromHex($byte));
            if ($byteInt >= 128) {
                $oidInt = (128 * $oidInt) + ($byteInt - 128);
                continue;
            }
            $oidInt = (128 * $oidInt) + $byteInt;
            $oid[] = $oidInt;
            $oidInt = 0;
        }
        return $oid;
    }
    
    public static function oidToHex($oid)
    {
        $hexadecimal = Binary::hexFromInt(40 * $oid[0] + $oid[1]);
        foreach (array_slice($oid, 2) as $number) {
            $hexadecimal .= Oid::oidNumberToHex($number);
        }
        return $hexadecimal;
    }
    
    private static function oidNumberToHex($number)
    {
        $hexadecimal = "";
        $endDelta = 0;
        while ($number > 0) {
            $hexadecimal = Binary::hexFromInt(($number % 128) + $endDelta) . $hexadecimal;
            $number = intdiv($number, 128);
            $endDelta = 128;
        }
        return $hexadecimal ? $hexadecimal : "00";
    }
}