Hello, there were problems when writing the program permutation cipher on c #, in which you need to change the word order. The key is a permutation of numbers from 0 to n. By default, I set the order to 3,2,5,7,4,6,1, which corresponds to the source text. With this piece of code, I changed the word order to 1,2,3,4,5,6,7. The word order has changed correctly. Each letter corresponds to one digit of the keyword, if there are more letters, then the keyword is repeated. And the task also says: Decryption is done in the same way, but a different key is used. To get the decryption key you need to encrypt the string "1234567"; at the same time we get "7215364". And how to get exactly this order of the key: "7215364", and then from it back 3,2,5,7,4,6,1, to get the source code? Can someone come across tell me.
private string get_abc(string key) // Сортировать буквы ключа по алфавиту { int i, j, x; string sw; for (j = 0; j < key.Length; j++) abc[j] = j; for (i = 0; i < key.Length - 1; i++) for (j = 0; j < key.Length - i - 1; j++) if (key[j] > key[j + 1]) { sw = key; key = key.Remove(j, 2).Insert(j, sw.Substring(j + 1, 1)).Insert(j + 1, sw.Substring(j, 1)); } return key; }