public static string ToHex(byte[] buffer, int offset, int count)
{
if (buffer == null) throw new ArgumentNullException("buffer");
if (offset < 0) throw new ArgumentOutOfRangeException("offset");
if (count < 0) throw new ArgumentOutOfRangeException("count");
if (offset + count > buffer.Length) throw new ArgumentOutOfRangeException("count");
if (count == 0) return string.Empty;
var hexString = new StringBuilder(buffer.Length * 2);
hexString.Append('0', hexString.Capacity);
var end = offset + count;
var hexStringIndex = 0;
for (var index = offset; index < end; index++)
{
var value = buffer[index];
hexString[hexStringIndex] = HexChar[(value >> 4) & 15u];
hexString[hexStringIndex + 1] = HexChar[value & 15u];
hexStringIndex += 2;
}
return hexString.ToString();
}
public static char[] ToHexBuffer(byte[] buffer)