3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s1 = bchexdec('44e1ff2dfd8102cf7a47c21d5c9fd5701610d04953c6836596b4fe9dd2f53e3e'); $s2 = bchexdec('9a5f1c75e461d7ceb1cf3cab9013eb2dc85b6d0da8c3c6e27e3a5a5b3faa5bab'); echo bcdechex(invmod($s1, -$s2)); function invmod($a,$b) { $n=$b; $x=0; $lx=1; $y=1; $ly=0; while ($b) { $t=$b; $q=bcdiv($a,$b,0); $b=bcmod($a,$b); $a=$t; $t=$x; $x=bcsub($lx,bcmod(bcmul($q,$x),$n)); $lx=$t; $t=$y; $y=bcsub($ly,bcmod(bcmul($q,$y),$n)); $ly=$t; } if (bccomp($lx,0) == -1) $lx=bcadd($lx,$n); return $lx; } function bchexdec($hex) { if(strlen($hex) == 1) { return hexdec($hex); } else { $remain = substr($hex, 0, -1); $last = substr($hex, -1); return bcadd(bcmul(16, bchexdec($remain)), hexdec($last)); } } function bcdechex($dec) { $last = bcmod($dec, 16); $remain = bcdiv(bcsub($dec, $last), 16); if($remain == 0) { return dechex($last); } else { return bcdechex($remain).dechex($last); } }

preferences:
76.61 ms | 406 KiB | 5 Q