仿射解密代码失败,问题是我得到了一个完全错误的输出。
public class AffineCipherDecryption {
public void Affine(int a, int b, JTextComponent Message, JTextComponent DisplayResult){
StringBuilder builder = new StringBuilder();
int len = Message.getText().length();
BigInteger dda = BigInteger.valueOf(a);
BigInteger dd = dda.modInverse(BigInteger.valueOf(26));
int bb = dd.intValue();
for (int i = 0; i < len; i++){
char currentChar = Message.getText().charAt(i);
char finalChar = (char) ((bb*(currentChar - 'A') - b) % 26 + 'A');
builder.append(finalChar);
}
String result = builder.toString().toLowerCase();
DisplayResult.setText(result);
}
}
我修改了它,但输出仍然是错误的......