public static byte[] generateRandomBytes(final int numBytes){
  final SecureRandom rand=new SecureRandom();
  final byte[] input=new byte[numBytes];
  rand.nextBytes(input);
  return input;
}

public static byte [ ] generateRandomBytes ( final int numBytes ) { final SecureRandom rand = new SecureRandom ( ) ; final byte [ ] input = new byte [ numBytes ] ; rand . nextBytes ( input ) ; return input ; }
generates a byte array containing random data .
