Monday, February 8, 2010

Convert HEX string into Byte Array in Java

 byte[] tokenSeed = new BigInteger("CA423C495478E12CCB329C5C2BA779D0", 16).toByteArray();

1 comment:

  1. If your big integer has the high bit set, the byte array you get back will have an extra byte to leave room for the sign bit. There's no way to avoid it.

    In this example, tokenSeed.length == 17, when the input was 32 hex characters.

    ReplyDelete

Followers

Search This Blog