2 * Svjatoslav Commons - shared library of common functionality.
3 * Copyright ©2012-2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 3 of the GNU Lesser General Public License
7 * or later as published by the Free Software Foundation.
10 package eu.svjatoslav.commons.data;
12 public class HexConverter {
14 static final String hexCharacters = "0123456789ABCDEF";
16 public static String byteArrayToHex(final byte[] bytes) {
21 final StringBuilder result = new StringBuilder(2 * bytes.length);
23 for (final byte b : bytes)
24 result.append(hexCharacters.charAt((b & 0xF0) >> 4)).append(
25 hexCharacters.charAt((b & 0x0F)));
27 return result.toString();