@Test public void testBytesToHexStringNoPrefix() { byte[] bigNumBytes = new byte[]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; String bigNumHex = "01010101010101010101010101010101010101010101010101010101010101010101010101010101"; byte[] smallNumBytes = new byte[]{1, 1, 1}; String smallNumHex = "010101"; assertEquals(smallNumHex, NumericUtil.bytesToHex(smallNumBytes)); assertEquals(bigNumHex, NumericUtil.bytesToHex(bigNumBytes)); }
public static String bytesToHex(byte[] input) { StringBuilder stringBuilder = new StringBuilder(); if (input.length == 0) { return ""; } for (byte anInput : input) { stringBuilder.append(String.format("%02x", anInput)); } return stringBuilder.toString(); }
NumericUtil { public static String bytesToHex(byte[] input) { StringBuilder stringBuilder = new StringBuilder(); if (input.length == 0) { return ""; } for (byte anInput : input) { stringBuilder.append(String.format("%02x", anInput)); } return stringBuilder.toString(); } }
NumericUtil { public static String bytesToHex(byte[] input) { StringBuilder stringBuilder = new StringBuilder(); if (input.length == 0) { return ""; } for (byte anInput : input) { stringBuilder.append(String.format("%02x", anInput)); } return stringBuilder.toString(); }  }
NumericUtil { public static String bytesToHex(byte[] input) { StringBuilder stringBuilder = new StringBuilder(); if (input.length == 0) { return ""; } for (byte anInput : input) { stringBuilder.append(String.format("%02x", anInput)); } return stringBuilder.toString(); }  static byte[] generateRandomBytes(int size); static boolean isValidHex(String value); static String cleanHexPrefix(String input); static String prependHexPrefix(String input); static BigInteger bytesToBigInteger(byte[] value, int offset, int length); static BigInteger bytesToBigInteger(byte[] value); static BigInteger hexToBigInteger(String hexValue); static String bigIntegerToHex(BigInteger value); static String bigIntegerToHexWithZeroPadded(BigInteger value, int size); static byte[] bigIntegerToBytesWithZeroPadded(BigInteger value, int length); static byte[] hexToBytes(String input); static byte[] hexToBytesLittleEndian(String input); static byte[] reverseBytes(byte[] bytes); static String bytesToHex(byte[] input); static String beBigEndianHex(String hex); static String beLittleEndianHex(String hex); static int bytesToInt(byte[] bytes); static byte[] intToBytes(int intValue); }
NumericUtil { public static String bytesToHex(byte[] input) { StringBuilder stringBuilder = new StringBuilder(); if (input.length == 0) { return ""; } for (byte anInput : input) { stringBuilder.append(String.format("%02x", anInput)); } return stringBuilder.toString(); }  static byte[] generateRandomBytes(int size); static boolean isValidHex(String value); static String cleanHexPrefix(String input); static String prependHexPrefix(String input); static BigInteger bytesToBigInteger(byte[] value, int offset, int length); static BigInteger bytesToBigInteger(byte[] value); static BigInteger hexToBigInteger(String hexValue); static String bigIntegerToHex(BigInteger value); static String bigIntegerToHexWithZeroPadded(BigInteger value, int size); static byte[] bigIntegerToBytesWithZeroPadded(BigInteger value, int length); static byte[] hexToBytes(String input); static byte[] hexToBytesLittleEndian(String input); static byte[] reverseBytes(byte[] bytes); static String bytesToHex(byte[] input); static String beBigEndianHex(String hex); static String beLittleEndianHex(String hex); static int bytesToInt(byte[] bytes); static byte[] intToBytes(int intValue);  }