Can you update this function to work with php 8? The chr function does not output the same result in php 5 or 7. public static function base58check_encode($leadingByte, $NAME_1, $trailingByte = null) {
        $NAME_1 = chr($leadingByte) . $NAME_1;
        if ($trailingByte !== null) { $NAME_1 .= chr($trailingByte); }
        $checkSum = substr(hash('sha256', hash('sha256', $NAME_1, true), true), 0, 4);
        $NAME_1 .= $checkSum;
        $base58 = self::base58_encode(bcmath_Utils::NAME_2bc($NAME_1));
        for ($i = 0; $i < strlen($NAME_1); $i++) { // for each leading zero-byte, pad base58 with "1"
            if ($NAME_1[$i] != "\x00") { break; }
            $base58 = '1' . $base58;
        }
        return $base58;
    } Write your response with at least 1000 words.
user