Skip to main content
2 of 2
More descriptive title
Edgar Bonet
  • 45.2k
  • 4
  • 42
  • 81

How to convert an hex string to an array of bytes?

How to convert the char array to Byte array? I tried every method but it doesn't work.

char CardNumber[8] = "B763AB23"; // Length is 8, basically it's in Hex
                                 // B7 63 AB 23

I need to convert it into Byte array to byte CardNumberByte[4]; So basically, it should be like :

CardNumberByte[0] = B7;
CardNumberByte[1] = 63;
CardNumberByte[2] = AB;
CardNumberByte[3] = 23;

I am unable to find any solution for that.

RS System
  • 61
  • 1
  • 1
  • 3