title: Polyalphabetic cipher
body: <p>I am writing a Java program for polyalphabetic cipher. I have this section of code:</p>
  
  <pre><code>while (i != 4 &amp;&amp; count != cipherlen) {
      if ((((int) ciphertext.charAt(i)) - 65) == 0) {
          plaintext[count] = (char) (90 - (((int) keyreader.charAt(i)) - 65));
      }
  
      if ((((int) keyreader.charAt(i)) - 65) &gt; (((int) ciphertext
              .charAt(i)) - 65)) {
          System.out.println("first");
  
          plaintext[count] = ((char) (90 - ((((int) keyreader.charAt(i)) - (65)) - (((int) ciphertext
                  .charAt(i)) - 65))));
          //System.out.println(text);
      }
      else {
          //System.out.println("second");
          plaintext[count] = ((char) ((((int) ciphertext.charAt(count)) - ((int) keyreader
                  .charAt(i))) + 64));
      }
  }
  </code></pre>
  
  <p>Its working properly for all the cases except when it encounters a value of, suppose cipher text is A then I am subtracting 65, in that case its giving some dummy value.</p>
  
  <p>Could you please help me determine what the problem is?</p>
  
  <p>Let <code>AAAD</code> be the key and <code>NIFQFWBACP</code> be the ciphertext, then the plain text generated is <code>MHEMEVA=BO</code></p>