Stathis Andronikos
Stathis Andronikos

Reputation: 1259

Which is the equivalent binascii a2b_hex python method to java

I have a hex string and in python there is a method a2b_hex from binacii. I want an example to make the same in java.

Upvotes: 2

Views: 3238

Answers (1)

Nigel Tufnel
Nigel Tufnel

Reputation: 11534

You can convert a hex string to a byte array with DatatypeConverter.parseHexBinary:

import javax.xml.bind.DatatypeConverter;

String hexString = "dead";
byte[] bytes = DatatypeConverter.parseHexBinary(hexString);

Upvotes: 2

Related Questions