2 * Svjatoslav Commons - shared library of common functionality. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
5 package eu.svjatoslav.commons.data;
7 public class HexConverter {
9 static final String hexCharacters = "0123456789ABCDEF";
11 public static String byteArrayToHex(final byte[] bytes) {
16 final StringBuilder result = new StringBuilder(2 * bytes.length);
18 for (final byte b : bytes)
19 result.append(hexCharacters.charAt((b & 0xF0) >> 4)).append(
20 hexCharacters.charAt((b & 0x0F)));
22 return result.toString();