mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Cryptography service now handles random byte generation
Protected strings are now protected in memory
This commit is contained in:
@@ -19,19 +19,28 @@ namespace ModernKeePass.Actions
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty TextProperty =
|
||||
DependencyProperty.Register("Text", typeof(string), typeof(ClipboardAction), new PropertyMetadata(string.Empty));
|
||||
DependencyProperty.Register(nameof(Text), typeof(string), typeof(ClipboardAction), new PropertyMetadata(string.Empty));
|
||||
public bool IsProtected
|
||||
{
|
||||
get { return (bool)GetValue(IsProtectedProperty); }
|
||||
set { SetValue(IsProtectedProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsProtectedProperty =
|
||||
DependencyProperty.Register(nameof(IsProtected), typeof(bool), typeof(ClipboardAction), new PropertyMetadata(false));
|
||||
|
||||
public object Execute(object sender, object parameter)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Text)) return null;
|
||||
|
||||
var settings = App.Services.GetRequiredService<ISettingsProxy>();
|
||||
var cryptography = App.Services.GetRequiredService<ICryptographyClient>();
|
||||
|
||||
_dispatcher = new DispatcherTimer {Interval = TimeSpan.FromSeconds(settings.GetSetting(Constants.Settings.ClipboardTimeout, 10))};
|
||||
_dispatcher.Tick += Dispatcher_Tick;
|
||||
|
||||
var dataPackage = new DataPackage { RequestedOperation = DataPackageOperation.Copy };
|
||||
dataPackage.SetText(Text);
|
||||
dataPackage.SetText(IsProtected ? cryptography.UnProtect(Text).GetAwaiter().GetResult() : Text);
|
||||
Clipboard.SetContent(dataPackage);
|
||||
_dispatcher.Start();
|
||||
|
||||
|
Reference in New Issue
Block a user