<PackageReference Include="System.Text.Encodings.Web" Version="10.0.0-preview.6.25358.103" />

HexConverter

static class HexConverter
using System.Runtime.CompilerServices; namespace System { internal static class HexConverter { public enum Casing : uint { Upper = 0, Lower = 8224 } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void ToBytesBuffer(byte value, Span<byte> buffer, int startingIndex = 0, Casing casing = Casing.Upper) { uint num = (uint)(((value & 240) << 4) + (value & 15) - 35209); uint num2 = (uint)((int)((((0 - num) & 28784) >> 4) + num + 47545) | (int)casing); buffer[startingIndex + 1] = (byte)num2; buffer[startingIndex] = (byte)(num2 >> 8); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void ToCharsBuffer(byte value, Span<char> buffer, int startingIndex = 0, Casing casing = Casing.Upper) { uint num = (uint)(((value & 240) << 4) + (value & 15) - 35209); uint num2 = (uint)((int)((((0 - num) & 28784) >> 4) + num + 47545) | (int)casing); buffer[startingIndex + 1] = (char)(num2 & 255); buffer[startingIndex] = (char)(num2 >> 8); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static char ToCharUpper(int value) { value &= 15; value += 48; if (value > 57) value += 7; return (char)value; } } }