RandomUtils { public static String getRandomHex(int len) { StringBuilder builder = new StringBuilder(); byte[] bytes = getRandomBytes(len); for (byte b : bytes) { builder.append((char) charset[b & 0x0F]); } return builder.toString(); } private  RandomUtils(); static String getRandomHex(int len); static byte[] getRandomBytes(int len);  }
@Test public void test() { int length = 40; String hex = RandomUtils.getRandomHex(40); assertEquals(length, hex.length()); }