Decode hex string to a byte array
if (encoded == null)
return null;
int lengthData = encoded.length();
if (lengthData % 2 != 0)
return null;
char[] binaryData = encoded.toCharArray();
int lengthDecode = lengthData / 2;
byte[] decodedData = new byte[lengthDecode];
byte temp1, temp2;
for( int i = 0; i<lengthDecode; i++ ){
temp1 = hexNumberTable[binaryData[i*2]];
if (temp1 == -1)
return null;
temp2 = hexNumberTable[binaryData[i*2+1]];
if (temp2 == -1)
return null;
decodedData[i] = (byte)((temp1 << 4) | temp2);
}
return decodedData;