public class Translator
{
	/*
	 * the cipher string. If you want to increase supported chars just add here.
	 */
	private final String ABC = "?abcdefghijklmnopqrstuvwxyz,.<>[]{}'ABCDEFGHIJKLMNOPQRSTUVWXYZ:;()-+=/*%!1234567890 ";
	
	/**
	 * Looks up an int value of the char from the cipher string
	 * @param c - char which value is being searched
	 * @return - an int value of the char
	 */
	
	private int charToInt(char c)
	{
		for (int i = 0; i < ABC.length(); i++)
		{
			if (ABC.charAt(i) == c)
				return i;
		}
		
		return -1;
	}
	
	/**
	 * Returns a char from the cipher string with the passed index
	 * @param a - index
	 * @return - char at that index
	 */
	
	private char intToChar(int a)
	{
		if (a >= ABC.length())
			a %= ABC.length();
		else if (a < 0)
			a += ABC.length();
		
		return ABC.charAt(a);
	}
	
	/**
	 * Checks whether all chars from the string are convertable
	 * @param str - checked string
	 * @return - true if ALL chars exist in the cipher string, false otherwise
	 */
	
	public boolean validate(String str)
	{
		for (int i = 0; i < str.length(); i++)
		{
			if (charToInt(str.charAt(i)) < 0)
				return false;
		}
		
		return true;
	}
	
	/**
	 * Transforms two chars into one depending on the operator passed.
	 * @param a - first char
	 * @param b - second char
	 * @param operator - arithmetical operator used in transformation
	 * @return combined char
	 */
	
	public char combine(char a, char b, char operator)
	{
		int char1 = charToInt(a);
		int char2 = charToInt(b);
		
		boolean plus = operator == '+';
		
		return plus ? intToChar(char1 + char2) : intToChar(char1 - char2);
	}
	
	/**
	 * Generates a key, which is a string of random chars from the cipher string
	 * @param length - length of the key
	 * @return - key
	 */
	
	public String generateKey(int length)
	{
		String key = "";
		
		while (key.length() < length)
		{
			int a = (int)(Math.random() * (ABC.length() + 1));
			key += intToChar(a);
		}
		
		return key;
	}
}

@@ -23,16 +23,322 @@
 r%0A%7B%0A%09/*%0A
+%09 * Errors that could occur%0A%09 */%0A%09public static final String ERROR_NONE%09    = %22%22;%0A%09public static final String ERROR_BAD_LENGTH = %22Error 1: Message and key have to be of the same length!%22;%0A%09public static final String ERROR_BAD_CHARS  = %22Error 2: Your text/key contains not yet supported characters!%22;%0A%09%0A%09/*%0A
 %09 * the 
@@ -1140,15 +1140,10 @@
 cks 
-whether
+if
  all
@@ -1153,23 +1153,19 @@
 ars 
-from
+in
  the 
-string
+text
  are
@@ -1180,116 +1180,207 @@
 able
-%0A%09 * @param str - checked string%0A%09 * @return - true if ALL chars exist in the cipher string, false otherwise
+ into values.%0A%09 * If key is passed also checks whether length of key and text equal.%0A%09 * @param str - message/text%0A%09 * @param key - key%0A%09 * @return - a string defining error nature or %22%22 for no error
 %0A%09 *
@@ -1391,23 +1391,22 @@
 %09public 
-boolean
+String
  validat
@@ -1417,16 +1417,28 @@
 ring str
+, String key
 )%0A%09%7B%0A%09%09f
@@ -1531,35 +1531,136 @@
 urn 
-false;%0A%09%09%7D%0A%09%09%0A%09%09return true
+ERROR_BAD_CHARS;%0A%09%09%7D%0A%09%09%0A%09%09if (!key.isEmpty() && str.length() != key.length())%0A%09%09%09return ERROR_BAD_LENGTH;%0A%09%09%0A%09%09return ERROR_NONE
 ;%0A%09%7D

Update Translator.java