Please can someone explain the line of code highlighted below. I don't understand at all how this line works.
You can use this example to help me:
input: ATTACK keyword: LEMON res: LXFOPV
I don't understand how that line helps encode A
to L
and other letter...
ACSII involvement?
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;
}