bitconverter

Converting from hex to string

为君一笑 提交于 2019-11-26 22:11:09
I need to check for a string located inside a packet that I receive as byte array. If I use BitConverter.ToString() , I get the bytes as string with dashes (f.e.: 00-50-25-40-A5-FF). I tried most functions I found after a quick googling, but most of them have input parameter type string and if I call them with the string with dashes, It throws an exception. I need a function that turns hex(as string or as byte ) into the string that represents the hexadecimal value(f.e.: 0x31 = 1). If the input parameter is string , the function should recognize dashes(example "47-61-74-65-77-61-79-53-65-72-76

Converting from hex to string

拥有回忆 提交于 2019-11-26 08:12:53
问题 I need to check for a string located inside a packet that I receive as byte array. If I use BitConverter.ToString() , I get the bytes as string with dashes (f.e.: 00-50-25-40-A5-FF). I tried most functions I found after a quick googling, but most of them have input parameter type string and if I call them with the string with dashes, It throws an exception. I need a function that turns hex(as string or as byte ) into the string that represents the hexadecimal value(f.e.: 0x31 = 1). If the