class StringUtils {

	public static String generateRandom(int length) {
		String generatedStr = null;
		// Return null if length is invalid
		if (length < 0) {
			return generatedStr;
		}

		// Return empty string if length is zero
		if (length == 0) {
			return "";
		}

		char[] generatedChar = new char[length];
		int charsLength = chars.length;

		Random random = new SecureRandom();
		for(int i = 0; i < length; ++i) {
			int index = random.nextInt(charsLength);
			generatedChar[i] = (char) chars[index];
		}

		generatedStr = String.valueOf(generatedChar);
		return generatedStr;
	}

}