I believe that this should do the job, although it's untested.
vb.net Code:
Private Function HexToBytes(hex As String) As Byte() If hex.Length Mod 2 <> 0 Then 'Add a leading 0. hex = "0" & hex End If Dim index = 0 Dim bytes As New List(Of Byte) Do Until index = hex.Length bytes.Add(Convert.ToByte(hex.Substring(index, 2), 16)) Loop bytes.Reverse() Return bytes.ToArray() End Function




Reply With Quote
