I came across this code:
Byte Vigenere Cipher, error with decryption
But trying to follow the rules I made a new question about it.
The following algorithm is used and I'm trying to get a better understanding into it:
Byte[] result= new Byte[plaintext.Length];
key = key.Trim().ToUpper();
int keyIndex = 0;
int keylength = key.Length;
for (int i = 0; i < plaintext.Length; i++)
{
keyIndex = keyIndex % keylength;
int shift = (int)key[keyIndex] - 65;
result[i] = (byte)(((int)plaintext[i] + shift) % 256);
keyIndex++;
}
Am I right in thinking the key needs to be trimmed as it is in Unicode? therefore subtracting 65 from a capital produces a common character/symbol?