Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to Convert and Print Byte array to Hex String in Java? Example

We often need to convert Byte arrays to Hex String in Java, In order to print Byte Array contents in a readable format. Since many cryptographic algorithms e.g. MD5 return the hash value as a byte array, In order to see and compare that byte array, you need to convert the byte array to Hex String. As we have seen, while generating MD5 checksum of File, there are multiple ways to convert byte array to Hexadecimal String in Java. You can either write your own method, or you can use an open-source library e.g. Apache commons-codec to create Hex String from a byte array in Java. Commons codec provides a utility class Hex, which contains an encodeHexString() method to create Hex String from a byte array.


This post first appeared on Javarevisited: Blog About Java Programmin, please read the originial post: here

Share the post

How to Convert and Print Byte array to Hex String in Java? Example

×

Subscribe to Javarevisited: Blog About Java Programmin

Get updates delivered right to your inbox!

Thank you for your subscription

×