Exemplo n.º 1
0
        public void Decrypt()
        {
            // Keys generated using https://pgpkeygen.com/
            string inputFileName  = "encrypted.txt";
            string outputFileName = "decrypted.txt";
            string privateKey     = "private_key.txt";
            string password       = "******";

            OpenPgp.DecryptFile(inputFileName, outputFileName, privateKey, password);
        }
Exemplo n.º 2
0
 private void postData(string text, PictureBox picbox)
 {
     debug_no       = 13;
     picbox.Visible = true;
     try
     {
         var client = new RestClient(statusStrip1.Text.ToString());
         client.Authenticator = new HttpBasicAuthenticator(textBox1.Text.ToString(), textBox2.Text.ToString());
         debug_no             = 14;
         client.AddDefaultHeader("x-api-key", textBox3.Text.ToString());
         client.AddDefaultHeader("ContentType", "application/json");
         var request = new RestRequest(text, Method.POST, DataFormat.Json);
         debug_no = 15;
         var response = client.Post(request);
         if (((RestSharp.RestResponseBase)response).StatusDescription == "OK")
         {
             var x   = ((RestSharp.RestResponseBase)response).Content.ToString();
             obj obj = JsonConvert.DeserializeObject <obj>(x);
             debug_no = 16;
             //BUG PATH FIX
             if (textBox4.Text.Substring(textBox4.Text.Length - 1) != "\\")
             {
                 textBox4.Text = textBox4.Text + "\\";
             }
             debug_no = 17;
             File.WriteAllBytes(textBox4.Text + obj.FileName, Convert.FromBase64String(obj.Result));
             debug_no = 18;
             OpenPgp.DecryptFile(textBox4.Text + obj.FileName, textBox4.Text + text.Split('/')[text.Split('/').Length - 1].ToString() + ".ZIP", textBox5.Text, textBox6.Text);
             debug_no = 19;
             File.Delete(textBox4.Text + obj.FileName);
             debug_no = 20;
             picbox.Load(AppDomain.CurrentDomain.BaseDirectory.ToString() + "ok.png");
             picbox.BackgroundImage = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory.ToString() + "ok.png");
             debug_no = 21;
             picbox.Refresh();
             debug_no = 22;
         }
         else
         {
             MessageBox.Show(((RestSharp.RestResponseBase)response).StatusDescription);
         }
     }
     catch (Exception ex)
     {
         picbox.Load(AppDomain.CurrentDomain.BaseDirectory.ToString() + "error.png");
         picbox.BackgroundImage = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory.ToString() + "error.png");
         picbox.Refresh();
         MessageBox.Show(debug_no.ToString() + "_" + ex.Message.ToString());
     }
 }