示例#1
0
        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);
        }
示例#2
0
        public string GetReceiverPrivateKey(string email)
        {
            var privateKey = SymetricService.RijndaelDecryptData(Convert.FromBase64String(this.User.PrivateKey),
                                                                 Convert.FromBase64String(User.Passphrase),
                                                                 Convert.FromBase64String(User.IV));

            return(privateKey);
        }
示例#3
0
 public FileEncryptModel()
 {
     EncryptInfo = new EncryptingFileInfo();
     this.LoadEmails();
     this.LoadAlgorithm();
     this.LoadPaddingModes();
     this.LoadCipherModes();
     SymetricService = new SymetricService();
     XmlService      = new XmlService();
 }
示例#4
0
        public SignUpModel()
        {
            XmlService      = new XmlService();
            RSAService      = new RSAService();
            HashService     = new HashService();
            SymetricService = new SymetricService();

            User      = new UserDto();
            User.Salt = Guid.NewGuid().ToString();
        }
示例#5
0
        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);
        }
示例#6
0
 public FileDecryptModel()
 {
     SymetricService = new SymetricService();
     XmlService      = new XmlService();
 }
示例#7
0
 public FileSignModel()
 {
     User            = new UserDto();
     RSAService      = new RSAService();
     SymetricService = new SymetricService();
 }