コード例 #1
0
ファイル: ClientGame.cs プロジェクト: mosheepdev/Card-Game
        private ClientGame(string name, MainWindow window, ClientNetwork network)
        {
            MainWindow   = window;
            this.network = network;
            Chat         = new ChatHandler(this);
            Player       = new Player(this, MainWindow.PlayerCard1, MainWindow.PlayerCard2, MainWindow.PlayerCard3, MainWindow.PlayerCard4)
            {
                Name = name
            };
            Opponent = new Player(this, MainWindow.OpponentCard1, MainWindow.OpponentCard2, MainWindow.OpponentCard3, MainWindow.OpponentCard4);

            // Sends init packet to server
            var packet = new Packet(CMSGPackets.CMSG_INIT_PACKET);
            var rsa    = new RsaEncryptor(RSAKey.Modulus, RSAKey.Exponent);

            aes = new AesEncryptor(AesEncryptionType.Aes256Bits)
            {
                PaddingMode = PaddingMode.PKCS7
            };
            network.Encryptor = aes;
            packet.Write(rsa.Encrypt(aes.Encryptors));
            packet.Write(aes.Encrypt(name));
            rsa.Dispose();

            SendPacket(packet, false);
            networkConnectionTask = Task.Run(UpdateAsync, tokenSource.Token);
        }
コード例 #2
0
 public void Dispose()
 {
     _rsaEncryptor?.Dispose();
 }