title: What is the best way to create a substitution cipher to map a string of normal alphabet to a string of jumbled alphabet, to encrypt a message?
body: <pre><code>public static String EncodeString() { 
      String plaintext = &quot;Hello Jon&quot;;
      String alphabet = &quot;abcdefghijklmnopqrstuvwxyz&quot;;
      String Substituion = &quot;zyxwvutsrqponmlkjihgfedcba&quot;;
      
      for(int i=0; i&lt;plaintext.length(); i++){
          for(int j=0; j&lt;alphabet.length(); j++){
              if(plaintext[i]==alphabet[j]) {
                  //not sure what to do here because the code above is giving an error
              }
              
          }
  
      }
  </code></pre>
  <p>For example &quot;abcdefghijklmnopqrstuvwxyz&quot; is the normal alphabet, jumbled alphabet is &quot;zyxwutsrqponmlkjihgfedcba&quot; and the string message is &quot;Hi Jon&quot;. So the message should be encrypted according to the jumbled alphabet, however the alphabet can be entered by the user meaning it will be different everytime.</p>
  <p>I know I can either use arrays, for loops or hashmaps, but which is the most effective?</p>
  <p>Above is the code that I am trying at the moment but I am a bit stuck, I know I'm doing something wrong but not sure what. Also it should return an encrypted string that is plaintext but encrypted, I haven't added that yet.</p>