Пример #1
0
        public override void Execute(object parameter)
        {
            var vm = (MainWindowViewModel)parameter;

            var dialog = new SaveFileDialog()
            {
                AddExtension     = true,
                DefaultExt       = Path.GetExtension(vm.FilePath),
                InitialDirectory = vm.FilePath,
            };

            if (dialog.ShowDialog() ?? false)
            {
                var rc5 = new Rc5CbcPad();
                using var input  = new BinaryReader(File.OpenRead(vm.FilePath));
                using var output = new BinaryWriter(File.Create(dialog.FileName));
                rc5.Encrypt(input, vm.KeyPhrase, output);
            }
        }
        public override void Execute(object parameter)
        {
            var vm = (Rc5ViewModel)parameter;

            var dialog = new SaveFileDialog()
            {
                AddExtension     = true,
                DefaultExt       = Path.GetExtension(vm.FilePath),
                InitialDirectory = vm.FilePath,
            };

            if (dialog.ShowDialog() ?? false)
            {
                var sw  = Stopwatch.StartNew();
                var rc5 = new Rc5CbcPad();
                using var input  = new BinaryReader(File.OpenRead(vm.FilePath));
                using var output = new BinaryWriter(File.Create(dialog.FileName));
                rc5.Encrypt(input, vm.KeyPhrase, output);
                sw.Stop();
                vm.EncryptionTime = $"Encryption took {sw.ElapsedMilliseconds} ms";
            }
        }