Skip to content

Instantly share code, notes, and snippets.

@jltrem
Created February 27, 2015 17:15
Show Gist options
  • Save jltrem/56c32209c616c6a1e1b8 to your computer and use it in GitHub Desktop.
Save jltrem/56c32209c616c6a1e1b8 to your computer and use it in GitHub Desktop.
[Fact]
public void test_byte_encoding_decoding()
{
var encoding = new UTF8Encoding();
byte[] inputBytes = encoding.GetBytes("sample");
var hexString = BitConverter.ToString(inputBytes);
byte[] outputBytes = hexString.Split('-').Select(hex => byte.Parse(hex, NumberStyles.HexNumber)).ToArray();
Assert.Equal(inputBytes, outputBytes);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment