private void CheckIfFileIsEncrypted(EncryptFileServicer encryptFileServicer, DecryptFileBindingModel decryptFileBindingModel, CheckPasswordBindingModel checkBindingModel)
        {
            if (SaveZoneDbService.GetEntity(decryptFileBindingModel.FileSourcePath) != null)
            {
                if (SaveZoneDbService.GetEntity(decryptFileBindingModel.FileSourcePath).encrypted_name == decryptFileBindingModel.FileSourcePath)
                {
                    CheckPasswordForm.ShowDialog();

                    if (checkBindingModel.OKIsPressed == true)
                    {
                        decryptFile.AESDecryptFile(decryptFileBindingModel.FileName, decryptFileSource, decryptFileBindingModel, checkBindingModel);
                    }

                    CheckPasswordForm.Dispose();
                    CheckPasswordForm = new CheckPassword();

                    CheckIfFileIsDecrypted(decryptFileBindingModel);
                }
            }
            else
            {
                MessageBox.Show("File is not encrypted", "File not encrypted", MessageBoxButtons.OK, MessageBoxIcon.Error, 0,
                                MessageBoxOptions.DefaultDesktopOnly);
            }
        }
예제 #2
0
        private void CheckIfFileIsEncrypted(DecryptFileBindingModel decryptFileBindingModel, CheckPasswordBindingModel checkBindingModel)
        {
            //Checks from the database if the file is encrypted. If it is not the query will return null
            if (SaveZoneDbService.GetEntity(decryptFileBindingModel.FileSourcePath) != null)
            {
                //Checks from the database if the file the user wants to decrypt matches with the encrypted file name
                if (SaveZoneDbService.GetEntity(decryptFileBindingModel.FileSourcePath).encrypted_name == decryptFileBindingModel.FileSourcePath)
                {
                    //Shows the CheckPasswordForm for the user to input password and IV for decryption.
                    CheckPasswordForm.ShowDialog();

                    //When OK is pressed on CheckPasswordForm it tries to decrypt the file if everything is done correctlly
                    if (checkBindingModel.OKIsPressed == true)
                    {
                        decryptFile.AESDecryptFile(decryptFileBindingModel.FileName, decryptFileSource, decryptFileBindingModel, checkBindingModel);
                    }

                    //Resets the form for next use
                    CheckPasswordForm.Dispose();
                    CheckPasswordForm = new CheckPassword();

                    //Checks if the file has decrypted correctlly
                    CheckIfFileIsDecrypted(decryptFileBindingModel);
                }
            }
            else
            {
                MessageBox.Show("File is not encrypted", "File not encrypted", MessageBoxButtons.OK, MessageBoxIcon.Error, 0,
                                MessageBoxOptions.DefaultDesktopOnly);
            }
        }