2

During execution the method is called and the integer i displays as 0 on screen. However, no output is forthcoming from inside the for loop, suggesting the for loop doesnt execute. I have also tested this with breakpoints, and have obtained the same results. Any help is appreciated.

private void decrypt_btnActionPerformed(java.awt.event.ActionEvent evt) {
    int ciphertext_length = Ciphertext().length();
    String decrypted_char = "";
    int i = 0;

    System.out.println("increment" + i);    

    try {
        for (i = 0; i == ciphertext_length; i++) {

            System.out.println("test" + i);

            String cipher_current_char = getLetterAtIndex(Ciphertext(), i);
            int pos_char_in_alphabet = getIndexAtLetter(Alphabet(), cipher_current_char);

            decrypted_char = decrypted_char +
                getLetterAtIndex(Alphabet(), pos_char_in_alphabet - 5);

            status_label.setText(100 / i + "%");
        }
    } catch (Exception e) {
        e.getMessage();
    }

    plain_ta.setText(decrypted_char);
}
1
  • Are you getting any exceptions? You are just ignoring them in your catch block, so that would be hard to tell right now. Commented Jan 21, 2013 at 3:36

1 Answer 1

7
  for (i = 0; i==ciphertext_length; i++){

should in all likelihood be

  for (i = 0; i<ciphertext_length; i++){
Sign up to request clarification or add additional context in comments.

4 Comments

then you need to debug some more. What is the value of ciphertext_length?
String ciphertext="afRcXFBxXTRJ" : it can be any random string of base64 chars
ciphertext_length=ciphertext.length();
No, what is the actual value as shown in the debugger. I imagine Ciphertext() is not returning what you expect it to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.