Exemple #1
0
 private static void TestCardan()
 {
     var message = "КРИПТОГР";
     var key = Key3();
     //var message = "ЭТОЛЕКЦИЯПОКРИПТОГРАФИИ";
     //var key = Key4();
     //var message = "ЭТОЛЕК ЦИЯПОК РИПТОГ РАФИИ1";
     //var message = "ЭТОЛЕКЦИЯПОКРИПТОГРАФИИ1";
     //var key = Key5();
     var encryptedMessage = new CardanGrilleCipher().Encrypt(message, key);
     var decryptedMessage = new CardanGrilleCipher().Decrypt(encryptedMessage, key);
     Console.WriteLine("Encoded message = {0}", encryptedMessage);
     Console.WriteLine("Decoded message = {0}", decryptedMessage);
 }
Exemple #2
0
 private void encryptButton_Click(object sender, EventArgs e)
 {
     if (cipherSelectBox.SelectedIndex == 0)
     {
         var key = (int)keyBox.Value;
         var message = sourceTextBox.Text;
         var encryptedMessage = new AffineCipher().Encrypt(message, key);
         processedTextBox.Text = encryptedMessage;
     }
     else
     {
         var key = new CardanGrilleKey()
         {
             MatrixOrder = (int)keyBox.Value,
             Positions = currentKeyGrille.Select(p => new Position(p.X, p.Y)).ToArray()
         };
         var message = sourceTextBox.Text;
         var encryptedMessage = new CardanGrilleCipher().Encrypt(message, key);
         processedTextBox.Text = encryptedMessage;
     }
 }