Exemplo n.º 1
0
        public void TestMethod1()
        {
            //arrange
            var rsa     = new Rsa.Rsa();
            var message = "hello world";
            var data    = Encoding.Default.GetBytes(message);

            //act
            var enc    = rsa.Crypt(data, rsa.Key);
            var dec    = rsa.Decrypt(enc);
            var actual = Encoding.Default.GetString(dec);

            //assert
            Assert.AreEqual(message, actual);
        }
Exemplo n.º 2
0
        private async void Send(object sender, EventArgs e)
        {
            var data = Encoding.UTF32.GetBytes(messageBox.Text);

            messageBox.Text = string.Empty;

            try
            {
                foreach (var user in await ChatClient.GetUsersAsync())
                {
                    var encrypted = _rsa.Crypt(data, user.Key);
                    await ChatClient.SendMessageAsync(encrypted, Me, user);
                }
            }
            catch
            {
                MessageBox.Show("Произшла ошибка! Проверьте соединение с Интернетом",
                                "Ошибка",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                Close();
            }
        }