Skip to main content
added 1121 characters in body
Source Link

You can use the method from Bouncy Castle Provider library:

org.bouncycastle.util.encoders.Hex.toHexString(byteArray);

The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.8.

Maven dependency:

<dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bcprov-jdk15on</artifactId>
    <version>1.60</version>
</dependency>

or from Apache Commons Codec:

org.apache.commons.codec.binary.Hex.encodeHexString(byteArray);

The Apache Commons Codec package contains simple encoder and decoders for various formats such as Base64 and Hexadecimal. In addition to these widely used encoders and decoders, the codec package also maintains a collection of phonetic encoding utilities.

Maven dependency:

<dependency>
    <groupId>commons-codec</groupId>
    <artifactId>commons-codec</artifactId>
    <version>1.11</version>
</dependency>
org.bouncycastle.util.encoders.Hex.toHexString(byteArray);

or

org.apache.commons.codec.binary.Hex.encodeHexString(byteArray);

You can use the method from Bouncy Castle Provider library:

org.bouncycastle.util.encoders.Hex.toHexString(byteArray);

The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.8.

Maven dependency:

<dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bcprov-jdk15on</artifactId>
    <version>1.60</version>
</dependency>

or from Apache Commons Codec:

org.apache.commons.codec.binary.Hex.encodeHexString(byteArray);

The Apache Commons Codec package contains simple encoder and decoders for various formats such as Base64 and Hexadecimal. In addition to these widely used encoders and decoders, the codec package also maintains a collection of phonetic encoding utilities.

Maven dependency:

<dependency>
    <groupId>commons-codec</groupId>
    <artifactId>commons-codec</artifactId>
    <version>1.11</version>
</dependency>
Source Link

org.bouncycastle.util.encoders.Hex.toHexString(byteArray);

or

org.apache.commons.codec.binary.Hex.encodeHexString(byteArray);