I’ve been trying to develop a good transposition method for basic encryption (not going to be used in reality)
Does this fit the bill:
for (int k = 0; k < Plaintext.Length; k++) //transpose
{
Swapchars(ResultArray, k, (key.length * k) % Plaintext.Length);
}
Thanks!
This only uses the key length, not the key contents. So
"aaa"and"bbb"as keys would encrypt the same way.Here is a simple way to incorporate the key contents (note, that this code is of course educational. It is not real crypto):
Instead of multiplying by
key.Length, we use the sum of all key characters which depends on the whole key. When you change any char, the whole key changes.There are still obvious weaknesses. The keys
"ab"and"ba"would encrypt the same way.