String str = "9B7D2C34A366BF890C730641E6CECF6F";
I want to convert str
into byte array, but str.getBytes()
returns 32 bytes instead of 16.
String str = "9B7D2C34A366BF890C730641E6CECF6F";
I want to convert str
into byte array, but str.getBytes()
returns 32 bytes instead of 16.
I think what the questioner is after is converting the string representation of a hexadecimal value to a byte array representing that hexadecimal value.
The apache commons-codec has a class for that, Hex.
String s = "9B7D2C34A366BF890C730641E6CECF6F";
byte[] bytes = Hex.decodeHex(s.toCharArray());