@Test public void testGenerateRandomBytes() { int[] sizeArray = new int[]{8, 9, 10}; for (int size : sizeArray) { byte[][] randomBytes = new byte[10][size]; for (int i = 0; i < 10; i++) { randomBytes[i] = NumericUtil.generateRandomBytes(size); } for (int i = 0; i < 10; i++) { assertEquals("Size should be " + size, size, randomBytes[i].length); for (int j = 0; j < 10; j++) { if (i == j) continue; assertNotEquals(NumericUtil.bytesToHex(randomBytes[i]), NumericUtil.bytesToHex(randomBytes[j])); } } } }
public static byte[] generateRandomBytes(int size) { byte[] bytes = new byte[size]; SECURE_RANDOM.nextBytes(bytes); return bytes; }
NumericUtil { public static byte[] generateRandomBytes(int size) { byte[] bytes = new byte[size]; SECURE_RANDOM.nextBytes(bytes); return bytes; } }
NumericUtil { public static byte[] generateRandomBytes(int size) { byte[] bytes = new byte[size]; SECURE_RANDOM.nextBytes(bytes); return bytes; }  }
NumericUtil { public static byte[] generateRandomBytes(int size) { byte[] bytes = new byte[size]; SECURE_RANDOM.nextBytes(bytes); return bytes; }  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 byte[] generateRandomBytes(int size) { byte[] bytes = new byte[size]; SECURE_RANDOM.nextBytes(bytes); return bytes; }  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);  }