Exemple #1
0
        private void GetDataFromSiteDB_Button_Click(object sender, EventArgs e)
        {
            Uri uri = new Uri(@"http://34.69.5.208/get_giv_mi_to_base");
            var s   = ServerWorker.GetRequest(uri);

            throw new NotImplementedException();
        }
Exemple #2
0
        //Пункт 2
        public CryptoWorker(string toEncrypt)
        {
            RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();

            privateKey = RSA.ExportParameters(true);
            publicKey  = RSA.ExportParameters(false);
            privateKey.ToString();

            UnicodeEncoding byteConverter = new UnicodeEncoding();

            byte[] encBytes = RSAEncrypt(byteConverter.GetBytes(toEncrypt), publicKey, false);

            string encrypt = byteConverter.GetString(encBytes);

            Debug.WriteLine("Encrypt str: " + encrypt);
            Debug.WriteLine("Encrypt bytes: " + string.Join(", ", encBytes));

            byte[] decBytes = RSADecrypt(encBytes, privateKey, false);

            Debug.WriteLine("Decrypt str: " + byteConverter.GetString(decBytes));
            Debug.WriteLine("Decrypt bytes: " + string.Join(", ", byteConverter.GetBytes(encrypt)));
            var s = RSA.ToXmlString(true);
            IEnumerable <KeyValuePair <string, string> > queries = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string> ("key", s)
            };

            //ServerWorker.PostRequest(new UriBuilder("http://34.69.5.208/get_run_mi_key/root?code_word=key").Uri, queries);
            ServerWorker.DataBaseWriting(s);
            RSA = new RSACryptoServiceProvider();
            RSA.FromXmlString(s);
        }