Code example for Random

Methods: nextBytes

0
    return new String(encodedBytes).replace("+", "-").replace("/", "_");
  } 
 
  private static byte[] generateRandomBytes(int length) {
    byte[] bytes = new byte[length];
    Random random = new Random(System.nanoTime());
    random.nextBytes(bytes);
    return bytes;
  } 
 
  /* 
   * Helper to convert Byte Array to a Hex String 
   * Input: byte[] array 
   * Output: Hex string 
   */ 
  public static String byte2hex(byte[] b) {
   
      // String Buffer can be used instead 
      String hs = "";
      String stmp = "";