code: public static String generateRandomString(int nbytes) {
  		byte[] salt = new byte[nbytes];
  		Random r = new SecureRandom();
  		r.nextBytes(salt);
  		return bytesToHex(salt);
  	}
docs: Generate a random string with a certain entropy.
  
  This creates a random string with the entropy of nbytes and encodes
  that string in hex format. That means, the returned string will be
  twice as long as the requested entropy.
  <p>
  The string will be suitable for use in URLs or HTTP headers etc. without
  further escaping.
  </p>
  
  
  @param nbytes Number of bytes for entryopy
  
  @return Hex encoded random string of length 2 x nbytes.