3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Buffer extends \SplFixedArray { private function fill(string $data = '') { for ($i = 0, $l = $this->getSize(); $i < $l; $i++) { $this[$i] = $data[$i] ?? 0; } } public function __construct($arg) { if (\is_int($arg)) { parent::__construct($arg); $this->fill(); return; } if (\is_string($arg)) { parent::__construct(\strlen($arg)); $this->fill($arg); return; } } public function setSize($value) { throw new \Error('Buffer cannot be resized'); } public function offsetSet($index, $byte) { if (\is_int($byte) && $byte >= 0 && $byte <= 255) { parent::offsetSet($index, $byte); return; } if (!\is_string($byte) || \strlen($byte) != 1 || ($byte = \ord($byte)) < 0 || $byte > 255) { throw new \Error('Buffer element value must be integer in the range 0 - 255 or single-byte string'); } parent::offsetSet($index, $byte); } public function offsetUnset($index) { throw new \Error('Buffer elements cannot be unset'); } public function __toString() { return \implode('', \array_map('chr', $this->toArray())); } } $publicKey = new Buffer(\hex2bin('F1F5AC76CC3BCA543DBF7DEBFE77101343B72ABE582FF1D2E8767916EA792F32')); $signature = new Buffer(\hex2bin('4D363B793632444DC36FCB78F7993FC1C04FCA43F498ABC883DE772A7E616C98290D326306ABC772370E73338FD34D24B207F0F69F8652004001909B6907E986')); $publicKey[31] &= 0x7f; $publicKey[31] |= ($signature[63] & 0x80); $signature[63] &= 0x7f; var_dump(bin2hex((string)$publicKey)); var_dump(bin2hex((string)$signature));

preferences:
105.63 ms | 1521 KiB | 5 Q