All pastes #738704 Raw Edit

Stuff

public text v1 · immutable
·published 2007-10-16 15:45 UTC
rendered paste body
private byte[] GetBytesFromHexString(string hexString)
		{
			// we must have an even number of characters
			if (hexString.Length % 2 != 0)
			{
				return null;
			}

			byte[] buffer = new byte[hexString.Length / 2];

			for (int x = 0; x < hexString.Length; x++)
			{
				string singleByteSection = hexString.Substring(x, 2);
				buffer[x / 2] = Convert.ToByte(singleByteSection, 16);
				x++;
			}

			return buffer;
		}