private String encryptString(String str) {
            StringBuffer sb = new StringBuffer (str);

            int lenStr = str.length();
            int lenKey = key.length();

            for (int i=0, j=0; i < lenStr; i++, j++ ) {
                if (j >= lenKey) j = 0;
                sb.setCharAt(i, (char)(str.charAt(i) ^ key.charAt(j)));
            }

            return sb.toString();
        }