【发布时间】:2015-04-28 12:37:18
【问题描述】:
请有人解释下面突出显示的代码行。我完全不明白这条线是如何工作的。
你可以用这个例子来帮助我:
输入:攻击 关键词:柠檬 资源:LXFOPV我不明白那行如何帮助将A 编码为L 和其他字母...
ACSII 参与?
static String encrypt(String text, final String key) {
String res = "";
text = text.toUpperCase();
for (int i = 0, j = 0; i < text.length(); i++) {
char c = text.charAt(i);
if (c < 'A' || c > 'Z') continue;
////////////////////////////////////////////////////////////////////////////
//please someone explain this line
res += (char)((c + key.charAt(j) - 2 * 'A') % 26 + 'A');
////////////////////////////////////////////////////////////////////////
j = ++j % key.length();
}
return res;
}
【问题讨论】:
标签: java encryption vigenere