Ejemplo n.º 1
0
 public static FileEncrypter CreateFromFile(string name)
 {
     StreamReader sr = new StreamReader(new FileStream(name, FileMode.Open));
     string private_key = sr.ReadToEnd();
     sr.Close();
     FileEncrypter ret = new FileEncrypter();
     ret.ImportKey(private_key);
     return ret;
 }
Ejemplo n.º 2
0
        public static FileEncrypter CreateFromServer(string address)
        {
            XmlSerializer x = new XmlSerializer(typeof (PublicKeyCryptoResponse));
            var request = WebRequest.Create(address);
            WebResponse response = request.GetResponse();

            PublicKeyCryptoResponse pkres = (PublicKeyCryptoResponse) x.Deserialize(stream: response.GetResponseStream());

            guid = pkres.guid;
            FileEncrypter ret = new FileEncrypter();
            ret.ImportKey(pkres.public_key);
            return ret;
        }
Ejemplo n.º 3
0
        private FileExplorer.FileAction CreateFileAction(FileEncrypter encrypter)
        {
            return file =>
            {
                try
                {
                    if (_keyfile != null)
                        encrypter.Decrypt(file);
                    else
                        encrypter.Encrypt(file);

                    FileExplorer.ReplaceFile(file);
                }
                // ReSharper disable once EmptyGeneralCatchClause
                catch (Exception)
                {}

                ReportProgress(0);
                CurrentFile = file;
                SwitchFiles();
            };
        }