title: Attempting to decrypt encrypted hexadecimal code, find key, and convert to english
body: <p>Goal: Decode encrypted hex, which requires finding an unknown, single character key</p>
  
  <p>I was purely trying to do the problem by XOR'ing each character in xOR with each of the ascii characters. I was expecting to get a String of hexes as one of my outputs. However, my catch statement says that every string it returns is not hex.</p>
  
  <p>I then planned to take these converted hexvalues and just cast them as chars.
  If you could offer me some guidance on how to fix this atrocity, it would be greatly appreicated.</p>
  
  <p>Thanks a bunch!</p>
  
  <pre><code>//intention of this program is to decrypt this string of encoded hex, find the key, and decrpt the message
  //however, its not really working. It doesnt print values prior to 112 even though those values arent blank
  // as I checked in debugger
  
  public static void main(String[] args) throws UnsupportedEncodingException
  {
      String xOr1 = ("1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736");
      String xOr = "z({zzz{{z-{z{z{{{}z*{y)~x~x~{{rzsz(";
      String result = "";
  
      System.out.println("xOr1 length is " + xOr1.length());
      String output = "";
  
      byte[] encoded = xOr1.getBytes();
      byte[] decoded;
      String sub;
  
      String matches = "(.*)abdef0123456789(.*)";
      int hexInt;
      for(int k = 0; k&lt; 256;k++)
      {
          decoded = new byte[encoded.length];
          result = "";
          System.out.println(k);
          for(int j = 0; j&lt;encoded.length; j++)
          {
              decoded[j] = (byte)((int)encoded[j] ^ k);
              result = Arrays.toString(decoded);
  
          }
          output = new String(decoded,"UTF-8");
          //System.out.println(output);
  
          try
          {
              for(int i = 0; i&lt; output.length() -2; i++)
              {
  
                  hexInt = Integer.parseInt(output,16);
                  System.out.println("You aren't dumb... " + output);
              }
          }
          catch(NumberFormatException nfe)
          {
              //System.out.println(output);
              System.out.println("bad boy");
          }
  
  
  
      }
  
  
  }
  </code></pre>