Пример #1
0
 private void saveSessionWork(String password = null)
 {
     List<String> cookieValue;
     CookieProcessor processor = new CookieProcessor();
     processor.buildWorkingCopy(ChromeHandler.chromeDir + "\\Cookies");
     byte[] data = processor.readCookies(".working", out cookieValue);
     File.Delete(".working");
     byte[] serialized = Utils.serialize(cookieValue);
     byte[] len = BitConverter.GetBytes(data.Length);
     byte[] built = new byte[len.Length + data.Length + serialized.Length];
     len.CopyTo(built, 0);
     data.CopyTo(built, len.Length);
     serialized.CopyTo(built, len.Length + data.Length);
     if (password == null)
     {
         DataInputBox box = new DataInputBox("Password entry", "Create password for securing session data", true);
         if (box.ShowDialog() == DialogResult.OK)
         {
             password = box.getInputText().Trim();
         }
     }
     if (password != null)
     {
         Cryptography.updateSalt();
         byte[] encrypted = Cryptography.Encrypt(built, password);
         if (encrypted == null)
         {
             MessageBox.Show("The inputted credentials were incorrect! Please try again.");
             return;
         }
         File.WriteAllBytes("session-data", encrypted);
         RestoreSessionButton.Enabled = true;
         MessageBox.Show("Data saved and secured at \"" + Environment.CurrentDirectory + "\\session-data\"", "Complete!");
     }
 }