.net - Converting String Array into hexadecimal array -


i have string array

receivedbyte[0]=5a receivedbyte[1]=3a receivedbyte[2]=7a receivedbyte[3]=60 

i want treat them hex numbers , xor each of value 0x20. want data 0x5a ^0x20 in 0th location. , on.

i tried following , error comes says, input string not in correct format.

static public string[] escapefix(string[] receivedbyte)         {                      uint temp = convert.touint32(receivedbyte[1]);              temp = temp ^ 0x20;             receivedbyte[0] = convert.tostring(temp);             receivedbyte[1] = receivedbyte[2];             receivedbyte[2] = receivedbyte[3];             return receivedbyte;         } 

convert.touint32 tries parse decimal string, input hex, hence error. try byte.parse(receivedbytes[1], numberstyles.allowhexspecifier).

also uint.tostring() convert decimal representation. mean convert hex? should .tostring("x").

what code once parsing ok, in complete contradiction describe it's supposed to. you'll end [ "26", "7a", "60", "60" ], "26" (decimal) representation of 0x3a ^ 0x20, twenty-six.

why messing strings in first place? can't use byte[]? like:

public static byte[] escapefix(byte[] receivedbytes) {     return receivedbytes.select(b => (byte)(b ^ 0x20)).toarray(); } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -