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; }
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; }
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(); }; }