2009/07/24

C# - Convert Hexadecimal String into Byte Array

Hexadecimal String to Byte Array

public static byte[] StringToBytes(String s)

{

byte[] output = new byte[s.Length / 2];

for (int i = 0; i < i =" i">

{

String stringByte = s.Substring(i, 2);

output[i / 2] = Convert.ToByte(stringByte, 16);

}

return output;

}


No comments:

Post a Comment

Google Analytics

Blog Archive

Followers