mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
Implements encryption algorithm change
Implements compression algorithm change
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using Windows.Storage;
|
using Windows.Storage;
|
||||||
using Windows.UI.Xaml;
|
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using ModernKeePass.ViewModels;
|
using ModernKeePass.ViewModels;
|
||||||
using ModernKeePassLib;
|
using ModernKeePassLib;
|
||||||
|
using ModernKeePassLib.Cryptography.Cipher;
|
||||||
using ModernKeePassLib.Interfaces;
|
using ModernKeePassLib.Interfaces;
|
||||||
using ModernKeePassLib.Keys;
|
using ModernKeePassLib.Keys;
|
||||||
using ModernKeePassLib.Serialization;
|
using ModernKeePassLib.Serialization;
|
||||||
@@ -53,6 +53,18 @@ namespace ModernKeePass.Common
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PwUuid DataCipher
|
||||||
|
{
|
||||||
|
get { return _pwDatabase.DataCipherUuid; }
|
||||||
|
internal set { _pwDatabase.DataCipherUuid = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public PwCompressionAlgorithm CompressionAlgorithm
|
||||||
|
{
|
||||||
|
get { return _pwDatabase.Compression; }
|
||||||
|
set { _pwDatabase.Compression = value; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Open a KeePass database
|
/// Open a KeePass database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -107,13 +119,6 @@ namespace ModernKeePass.Common
|
|||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
if (_pwDatabase == null || !_pwDatabase.IsOpen) return;
|
if (_pwDatabase == null || !_pwDatabase.IsOpen) return;
|
||||||
// Commit real changes to DB
|
|
||||||
/*var app = (App) Application.Current;
|
|
||||||
foreach (var entity in app.PendingDeleteEntities)
|
|
||||||
{
|
|
||||||
entity.Value.CommitDelete();
|
|
||||||
}
|
|
||||||
app.PendingDeleteEntities.Clear();*/
|
|
||||||
_pwDatabase.Save(new NullStatusLogger());
|
_pwDatabase.Save(new NullStatusLogger());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,13 +2,14 @@
|
|||||||
x:Class="ModernKeePass.Pages.SettingsDatabasePage"
|
x:Class="ModernKeePass.Pages.SettingsDatabasePage"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:local="using:ModernKeePass.Pages"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Page.Resources>
|
<Page.Resources>
|
||||||
<CollectionViewSource x:Name="RecycleBinGroups" Source="{Binding Groups}" />
|
<CollectionViewSource x:Name="RecycleBinGroups" Source="{Binding Groups}" />
|
||||||
|
<CollectionViewSource x:Name="Ciphers" Source="{Binding Ciphers}" />
|
||||||
|
<CollectionViewSource x:Name="Compressions" Source="{Binding Compressions}" />
|
||||||
</Page.Resources>
|
</Page.Resources>
|
||||||
<Page.DataContext>
|
<Page.DataContext>
|
||||||
<viewModels:SettingsDatabaseVm />
|
<viewModels:SettingsDatabaseVm />
|
||||||
@@ -17,5 +18,9 @@
|
|||||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||||
<ToggleSwitch Header="Recycle bin" OffContent="Disabled" OnContent="Enabled" IsOn="{Binding HasRecycleBin, Mode=TwoWay}" />
|
<ToggleSwitch Header="Recycle bin" OffContent="Disabled" OnContent="Enabled" IsOn="{Binding HasRecycleBin, Mode=TwoWay}" />
|
||||||
<ComboBox ItemsSource="{Binding Source={StaticResource RecycleBinGroups}}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" IsEnabled="{Binding HasRecycleBin}" />
|
<ComboBox ItemsSource="{Binding Source={StaticResource RecycleBinGroups}}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" IsEnabled="{Binding HasRecycleBin}" />
|
||||||
|
<TextBlock Text="Encryption Algorithm" FontSize="14" Margin="5,20,0,10" />
|
||||||
|
<ComboBox ItemsSource="{Binding Source={StaticResource Ciphers}}" SelectedIndex="{Binding CipherIndex, Mode=TwoWay}" />
|
||||||
|
<TextBlock Text="Compression Algorithm" FontSize="14" Margin="5,20,0,10" />
|
||||||
|
<ComboBox ItemsSource="{Binding Source={StaticResource Compressions}}" SelectedItem="{Binding CompressionName, Mode=TwoWay}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Page>
|
</Page>
|
||||||
|
@@ -1,10 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Windows.Storage;
|
using Windows.Storage;
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using ModernKeePass.Common;
|
using ModernKeePass.Common;
|
||||||
using ModernKeePass.Interfaces;
|
using ModernKeePass.Interfaces;
|
||||||
|
using ModernKeePassLib;
|
||||||
|
using ModernKeePassLib.Cryptography.Cipher;
|
||||||
|
|
||||||
namespace ModernKeePass.ViewModels
|
namespace ModernKeePass.ViewModels
|
||||||
{
|
{
|
||||||
@@ -26,6 +29,38 @@ namespace ModernKeePass.ViewModels
|
|||||||
|
|
||||||
public ObservableCollection<GroupVm> Groups { get; set; }
|
public ObservableCollection<GroupVm> Groups { get; set; }
|
||||||
|
|
||||||
|
public IEnumerable<string> Ciphers
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
for (var inx = 0; inx < CipherPool.GlobalPool.EngineCount; inx++)
|
||||||
|
{
|
||||||
|
yield return CipherPool.GlobalPool[inx].DisplayName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CipherIndex
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
for (var inx = 0; inx < CipherPool.GlobalPool.EngineCount; ++inx)
|
||||||
|
{
|
||||||
|
if (CipherPool.GlobalPool[inx].CipherUuid.Equals(_app.Database.DataCipher)) return inx;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
set { _app.Database.DataCipher = CipherPool.GlobalPool[value].CipherUuid; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<string> Compressions => Enum.GetNames(typeof(PwCompressionAlgorithm)).Take((int)PwCompressionAlgorithm.Count);
|
||||||
|
|
||||||
|
public string CompressionName
|
||||||
|
{
|
||||||
|
get { return Enum.GetName(typeof(PwCompressionAlgorithm), _app.Database.CompressionAlgorithm); }
|
||||||
|
set { _app.Database.CompressionAlgorithm = (PwCompressionAlgorithm)Enum.Parse(typeof(PwCompressionAlgorithm), value); }
|
||||||
|
}
|
||||||
|
|
||||||
public ISelectableModel SelectedItem
|
public ISelectableModel SelectedItem
|
||||||
{
|
{
|
||||||
get { return Groups.FirstOrDefault(g => g.IsSelected); }
|
get { return Groups.FirstOrDefault(g => g.IsSelected); }
|
||||||
|
Reference in New Issue
Block a user