Skip to content

Instantly share code, notes, and snippets.

@Trinitek
Created December 9, 2017 20:16
Show Gist options
  • Select an option

  • Save Trinitek/8c616fd2f63094579cbb03e28b9ee202 to your computer and use it in GitHub Desktop.

Select an option

Save Trinitek/8c616fd2f63094579cbb03e28b9ee202 to your computer and use it in GitHub Desktop.
string BytesAsString(byte[] input)
{
var sb = new StringBuilder();
sb.Append("{\n ");
int i;
for (i = 0; i < input.Length; i++)
{
sb.Append($"0x{input[i]:x2}");
if (i < input.Length - 1)
{
sb.Append(", ");
}
if ((i + 1) % 16 == 0 && i < input.Length - 1)
{
sb.Append("\n ");
}
}
sb.Append("\n}");
return sb.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment