public bool EncryptFile() { if (!Validate()) { return(false); } var extension = Path.GetExtension(this.FileEncryptName); FileSaveName = Path.ChangeExtension(this.FileSaveName, extension); var publicKey = this.GetReceiverPublicKey(this.Email); try { SymetricService.EncryptFile(FileEncryptName, FileSaveName, this.EncryptInfo, publicKey); } catch (Exception ex) { this.WarningMessage = "There was an error when encrypting file."; return(false); } return(true); }
public string GetReceiverPrivateKey(string email) { var privateKey = SymetricService.RijndaelDecryptData(Convert.FromBase64String(this.User.PrivateKey), Convert.FromBase64String(User.Passphrase), Convert.FromBase64String(User.IV)); return(privateKey); }
public FileEncryptModel() { EncryptInfo = new EncryptingFileInfo(); this.LoadEmails(); this.LoadAlgorithm(); this.LoadPaddingModes(); this.LoadCipherModes(); SymetricService = new SymetricService(); XmlService = new XmlService(); }
public SignUpModel() { XmlService = new XmlService(); RSAService = new RSAService(); HashService = new HashService(); SymetricService = new SymetricService(); User = new UserDto(); User.Salt = Guid.NewGuid().ToString(); }
public bool DecryptFile() { if (!Validate()) { return(false); } var extension = Path.GetExtension(this.FileDecryptName); FileSaveName = Path.ChangeExtension(this.FileSaveName, extension); var privateKey = this.GetReceiverPrivateKey(this.User.Email); try { SymetricService.DecryptFile(FileDecryptName, FileSaveName, privateKey); } catch (Exception ex) { this.WarningMessage = $"Cannot decrypted symetric key.{Environment.NewLine}Reason: Wrong user's private key"; return(false); } return(true); }
public FileDecryptModel() { SymetricService = new SymetricService(); XmlService = new XmlService(); }
public FileSignModel() { User = new UserDto(); RSAService = new RSAService(); SymetricService = new SymetricService(); }