(byte[] bytes)
| 75 | |
| 76 | private static final char[] HEX_ARRAY = "0123456789abcdef".toCharArray(); |
| 77 | public static String bytesToHex(byte[] bytes) { |
| 78 | if (bytes == null) return ""; |
| 79 | char[] hexChars = new char[bytes.length * 2]; |
| 80 | for (int j = 0; j < bytes.length; j++) { |
| 81 | int v = bytes[j] & 0xFF; |
| 82 | hexChars[j * 2] = HEX_ARRAY[v >>> 4]; |
| 83 | hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F]; |
| 84 | } |
| 85 | return new String(hexChars); |
| 86 | } |
| 87 | |
| 88 | public static String bytesToHex(ByteBuf buf) { |
| 89 | return bytesToHex(byteBufToArray(buf)); |
no test coverage detected