Exemplo n.º 1
0
 public void ExchangeKeys(string targetUsername)
 {
     try
     {
         foreach (CryptographyHelper key in Ledger.KeysManifest)
         {
             if ((key.Receiver_Username == targetUsername ||
                  key.Sender_Username == targetUsername) &&
                 (key.Receiver_Username == this.Username ||
                  key.Sender_Username == this.Username)
                 )
             {
                 MessageBox.Show("Coordinator: Keys are already exchanged.");
                 return;
             }
         }
         CryptographyHelper newKey = new CryptographyHelper(
             Sender_Username: this.Username,
             Receiver_Username: targetUsername
             );
         Ledger.KeysManifest.Add(newKey);
     }
     catch (Exception ex)
     {
         MessageBox.Show($"Client : {ex.Message.ToString()}");
     }
 }
Exemplo n.º 2
0
        public void ExchangeKeysWithServer(string targetUsername)
        {
            foreach (CryptographyHelper key in Ledger.KeysManifest)
            {
                if ((key.Receiver_Username == targetUsername ||
                     key.Sender_Username == targetUsername) &&
                    (key.Receiver_Username == this.UsersList[0].Username ||
                     key.Sender_Username == this.UsersList[0].Username)
                    )
                {
                    MessageBox.Show("Coordinator: Keys are already exchanged.");
                    return;
                }
            }
            CryptographyHelper newKey = new CryptographyHelper(
                Sender_Username: this.UsersList[0].Username,
                Receiver_Username: targetUsername
                );

            Ledger.KeysManifest.Add(newKey);
        }