encoded Data = (encoded Data | bit Shift Buffer)
This line:
j = j + 1 == key.Length ? 0 : j + 1;
could also be written as:
if ((j+1) == key.Length) j = 0; else j = j+1;