在以下代码中,永远不会执行 for 循环。我试图解决断点和手表的问题。返回密文的正确长度,但是 for 循环不会增加 until int i >= ciphertext.length()
。事实上,“调试”消息似乎没有执行任何操作。
private void decrypt_btnActionPerformed(java.awt.event.ActionEvent evt) {
String alphabet= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
String ciphertext="fRcXFBxXTRJ";
status_label.setText( "Decryption has begun" );
JOptionPane.showMessageDialog(null,"ciphertext-length: " + ciphertext.length() + "\n" + ciphertext,"Debug", JOptionPane.INFORMATION_MESSAGE);
for (int i = 0; i>=ciphertext.length(); i--){
System.out.println("inc:" + i);
String cipher_current_char = getLetterAtIndex(ciphertext, i);
int pos_char_in_alphabet = getIndexAtLetter(alphabet, cipher_current_char);
if(pos_char_in_alphabet-2<0){
plain_ta.setText(getLetterAtIndex(alphabet, (alphabet.length()+(pos_char_in_alphabet -2)+1 ) ));
status_label.setText( 100/i + "%");
}else{
cipher_current_char = getLetterAtIndex(ciphertext, i);
pos_char_in_alphabet = getIndexAtLetter(alphabet, cipher_current_char);
plain_ta.setText(getLetterAtIndex(alphabet, (pos_char_in_alphabet-2)));
status_label.setText( 100/i + "%");
}
}
}