I have finished the first case : both plaintext and key are isupper.(The Link) However, I got some problems when doing either one of them is islower. Can anyone give me some hints of the formula?
Maybe it gets clearer if you use
'A' instead of
char is a kind of integer, so
'A' is an 8-bit integer of value 65).
In case of a lowercase letter, subtract
'a' (or 97) instead of
'A' (or 65). And in the last step add the one that matches the case of the plaintext letter, not the key letter.
You could reduce your cases from four combinations to two by ignoring the keyword case, like
toupper(k[l]) - 'A'.